Implement EventQueueService abstracted from product syncs along with its database changes
This commit is contained in:
@@ -2,16 +2,13 @@ import { Kysely, sql } from 'kysely'
|
||||
import { addDefaultColumns } from '../db';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
// TABLE: PRODUCT_SYNCS
|
||||
await db.schema.createTable("product_syncs")
|
||||
// TABLE: EVENTS
|
||||
await db.schema.createTable("events")
|
||||
.$call(addDefaultColumns)
|
||||
.addColumn("session_id", "uuid", (cb) => cb.notNull())
|
||||
.addColumn("session_name", "text", (cb) => cb.notNull())
|
||||
.addColumn("p_product_id_filter", sql`integer[]`)
|
||||
.addColumn("syncing_p_product_ids", sql`integer[]`, (cb) => cb
|
||||
.notNull()
|
||||
.defaultTo(sql`'{}'::integer[]`)
|
||||
)
|
||||
.addColumn("type", "text", (cb) => cb.notNull())
|
||||
.addColumn("source", "text", (cb) => cb.notNull())
|
||||
.addColumn("payload", "jsonb", (cb) => cb.notNull())
|
||||
.addColumn("state", "jsonb")
|
||||
.addColumn("started_at", "timestamptz")
|
||||
.addColumn("ended_at", "timestamptz")
|
||||
.addColumn("has_failed", "boolean", (cb) => cb.notNull().defaultTo(false))
|
||||
@@ -55,8 +52,8 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
// TABLE: PRODUCT_SYNCS
|
||||
await db.schema.dropTable("product_syncs").ifExists().execute()
|
||||
// TABLE: EVENTS
|
||||
await db.schema.dropTable("events").ifExists().execute()
|
||||
|
||||
// TABLE: CALCULATORS
|
||||
await db.schema.dropTable("calculators").ifExists().execute()
|
||||
|
||||
Reference in New Issue
Block a user