simple-kiosk-app/migration/2024-04-19.ts

22 lines
806 B
TypeScript
Raw Permalink Normal View History

2024-04-20 19:58:18 +09:00
import { Kysely } from 'kysely'
export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createTable('Order_State')
.addColumn('id', 'varchar', col => col.primaryKey().notNull())
.addColumn('orders', 'jsonb', col => col.notNull())
.addColumn('completed', 'boolean', col => col.notNull())
.addColumn('payment', 'varchar', col => col.notNull())
.execute()
await db.schema
.createTable('Order_Number')
// current date. (e.g. 2024-04-19)
.addColumn('id', 'varchar', col => col.primaryKey().notNull())
.addColumn('number', 'integer', col => col.notNull())
.execute()
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema.dropTable('Order_State').execute()
await db.schema.dropTable('Order_Number').execute()
}