From c5ea22da67b02dc56a3b068bfaf3a0026b3fb443 Mon Sep 17 00:00:00 2001 From: Samat Jorobekov Date: Thu, 19 Dec 2024 13:36:03 +0300 Subject: [PATCH] Add data export migration --- .../migrations/20241219092946_data_export.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/db/migrations/20241219092946_data_export.ts diff --git a/src/db/migrations/20241219092946_data_export.ts b/src/db/migrations/20241219092946_data_export.ts new file mode 100644 index 00000000..4cd4b6b2 --- /dev/null +++ b/src/db/migrations/20241219092946_data_export.ts @@ -0,0 +1,30 @@ +import type {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + CREATE TABLE data_export ( + data_export_id BIGINT NOT NULL PRIMARY KEY DEFAULT get_id(), + title TEXT NOT NULL, + tenant_id TEXT, + chart_id BIGINT NOT NULL, + chart_rev_id BIGINT NOT NULL, + dataset_id BIGINT, + dataset_rev_id BIGINT NOT NULL, + connection_id BIGINT NOT NULL, + connection_rev_id BIGINT NOT NULL, + params JSONB NOT NULL DEFAULT '{}'::jsonb, + created_by TEXT NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + expired_at TIMESTAMPTZ NOT NULL, + job_id TEXT NOT NULL, + result_link TEXT, + error JSONB + ); + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + DROP TABLE data_export; + `); +}