28 lines
763 B
TypeScript
28 lines
763 B
TypeScript
import { Kysely, sql } from "kysely";
|
|
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await db.schema
|
|
.createTable("Setting")
|
|
.addColumn("id", "uuid", (col) =>
|
|
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
|
)
|
|
.addColumn("name", "text")
|
|
.addColumn("value", "jsonb")
|
|
.addColumn("created_at", "timestamptz", (col) =>
|
|
col.notNull().defaultTo(sql`now()`),
|
|
)
|
|
.addColumn("updated_at", "timestamptz", (col) =>
|
|
col.notNull().defaultTo(sql`now()`),
|
|
)
|
|
.execute();
|
|
|
|
await db.schema
|
|
.createIndex("SettingName")
|
|
.on("Setting")
|
|
.column("name")
|
|
.execute();
|
|
}
|
|
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await db.schema.dropTable("Setting").ifExists().execute();
|
|
}
|