* use lower case db column names
* fix signup workspaceId
This commit is contained in:
Philipinho
2024-03-29 16:25:42 +00:00
parent 82da4ffdc2
commit b241523ff6
25 changed files with 248 additions and 407 deletions

View File

@ -6,51 +6,33 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn('id', 'uuid', (col) =>
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
)
.addColumn('pageId', 'uuid', (col) =>
.addColumn('page_id', 'uuid', (col) =>
col.references('pages.id').onDelete('cascade').notNull(),
)
.addColumn('title', 'varchar', (col) => col)
.addColumn('content', 'jsonb', (col) => col)
.addColumn('slug', 'varchar', (col) => col)
.addColumn('icon', 'varchar', (col) => col)
.addColumn('coverPhoto', 'varchar', (col) => col)
.addColumn('cover_photo', 'varchar', (col) => col)
.addColumn('version', 'int4', (col) => col.notNull())
.addColumn('lastUpdatedById', 'uuid', (col) => col.references('users.id'))
.addColumn('spaceId', 'uuid', (col) =>
.addColumn('last_updated_by_id', 'uuid', (col) =>
col.references('users.id'),
)
.addColumn('space_id', 'uuid', (col) =>
col.references('spaces.id').onDelete('cascade').notNull(),
)
.addColumn('workspaceId', 'uuid', (col) =>
.addColumn('workspace_id', 'uuid', (col) =>
col.references('workspaces.id').onDelete('cascade').notNull(),
)
.addColumn('createdAt', 'timestamp', (col) =>
.addColumn('created_at', 'timestamptz', (col) =>
col.notNull().defaultTo(sql`now()`),
)
.addColumn('updatedAt', 'timestamp', (col) =>
.addColumn('updated_at', 'timestamptz', (col) =>
col.notNull().defaultTo(sql`now()`),
)
.execute();
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema
.alterTable('page_history')
.dropConstraint('page_history_pageId_fkey')
.execute();
await db.schema
.alterTable('page_history')
.dropConstraint('page_history_lastUpdatedById_fkey')
.execute();
await db.schema
.alterTable('page_history')
.dropConstraint('page_history_spaceId_fkey')
.execute();
await db.schema
.alterTable('page_history')
.dropConstraint('page_history_workspaceId_fkey')
.execute();
await db.schema.dropTable('page_history').execute();
}