29 lines
934 B
TypeScript
29 lines
934 B
TypeScript
import { Kysely, sql, type ColumnDefinitionBuilder } from 'kysely'
|
|
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await db.schema
|
|
.alterTable('users')
|
|
.addColumn('password', 'text', col => col.notNull().defaultTo(''))
|
|
.addColumn('verified', 'boolean', col => col.defaultTo(false))
|
|
.addColumn(
|
|
'roles',
|
|
sql`text[]`,
|
|
(col: ColumnDefinitionBuilder) => col.notNull().defaultTo(sql`'{}'::text[]`)
|
|
)
|
|
.addColumn('token_key', 'uuid', col => col.defaultTo(sql`gen_random_uuid()`))
|
|
.addColumn('pending_email', 'text')
|
|
.addColumn('email_change_token', 'uuid')
|
|
.execute()
|
|
}
|
|
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await db.schema
|
|
.alterTable('users')
|
|
.dropColumn('password')
|
|
.dropColumn('verified')
|
|
.dropColumn('roles')
|
|
.dropColumn('token_key')
|
|
.dropColumn('pending_email')
|
|
.dropColumn('email_change_token')
|
|
.execute()
|
|
}
|