Move migrations to separate app

This commit is contained in:
Darren Clarke 2024-08-07 16:05:26 +02:00
parent 87724bb7b8
commit c47223f5e9
21 changed files with 55 additions and 815 deletions

View file

@ -0,0 +1,36 @@
import { Kysely, sql } from "kysely";
export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createTable("FacebookBot")
.addColumn("id", "uuid", (col) =>
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
)
.addColumn("name", "text")
.addColumn("description", "text")
.addColumn("token", "text")
.addColumn("page_access_token", "text")
.addColumn("app_secret", "text")
.addColumn("verify_token", "text")
.addColumn("page_id", "text")
.addColumn("app_id", "text")
.addColumn("user_id", "uuid")
.addColumn("verified", "boolean", (col) => col.notNull().defaultTo(false))
.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("FacebookBotToken")
.on("FacebookBot")
.column("token")
.execute();
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema.dropTable("FacebookBot").ifExists().execute();
}