mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-12 13:37:19 +02:00
47 lines
1.8 KiB
JavaScript
Executable file
47 lines
1.8 KiB
JavaScript
Executable file
#!/usr/bin/env -S node
|
|
import type { Contract as End } from '../../snapshots/7de60ab4aee8baa42480f8a2d3559ff4027deae801de73c6a93c9eeb4170f558/contract';
|
|
import endContract from '../../snapshots/7de60ab4aee8baa42480f8a2d3559ff4027deae801de73c6a93c9eeb4170f558/contract.json' with { type: 'json' };
|
|
import { Migration, MigrationCLI, col, fn, primaryKey } from '@internal/postgres/migration';
|
|
|
|
export default class M extends Migration<never, End> {
|
|
override readonly endContractJson = endContract;
|
|
|
|
override get operations() {
|
|
return [
|
|
this.createSchema({ schema: 'public' }),
|
|
this.createTable({
|
|
schema: 'public',
|
|
table: 'Post',
|
|
columns: [
|
|
col('authorId', 'uuid', { notNull: true, codecRef: { codecId: 'pg/uuid@1' } }),
|
|
col('id', 'uuid', { notNull: true, codecRef: { codecId: 'pg/uuid@1' } }),
|
|
col('title', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
|
],
|
|
constraints: [primaryKey(['id'])],
|
|
}),
|
|
this.createTable({
|
|
schema: 'public',
|
|
table: 'User',
|
|
columns: [
|
|
col('createdAt', 'timestamptz', {
|
|
notNull: true,
|
|
default: fn('now()'),
|
|
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
|
}),
|
|
col('email', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
|
col('id', 'uuid', { notNull: true, codecRef: { codecId: 'pg/uuid@1' } }),
|
|
col('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
|
],
|
|
constraints: [primaryKey(['id'])],
|
|
}),
|
|
this.addUnique({
|
|
schema: 'public',
|
|
table: 'User',
|
|
constraint: 'User_email_key',
|
|
columns: ['email'],
|
|
}),
|
|
];
|
|
}
|
|
}
|
|
|
|
MigrationCLI.run(import.meta.url, M);
|