From 673be5256123d73724bea8d18ce6b4a1d2c4fa7b Mon Sep 17 00:00:00 2001 From: Ted Alexander Date: Mon, 2 Mar 2026 14:41:42 -0500 Subject: [PATCH] Adding EDW.UNSETTLED_CRDB_SYS_CONF --- .../20260302193248_adding-tables-20260302.exs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ex_cubic_ingestion/priv/repo/migrations/20260302193248_adding-tables-20260302.exs diff --git a/ex_cubic_ingestion/priv/repo/migrations/20260302193248_adding-tables-20260302.exs b/ex_cubic_ingestion/priv/repo/migrations/20260302193248_adding-tables-20260302.exs new file mode 100644 index 0000000..ca4e95d --- /dev/null +++ b/ex_cubic_ingestion/priv/repo/migrations/20260302193248_adding-tables-20260302.exs @@ -0,0 +1,43 @@ +defmodule ExCubicIngestion.Repo.Migrations.AddingTables20260302 do + use Ecto.Migration + + alias ExCubicIngestion.Repo + alias ExCubicIngestion.Schema.CubicTable + alias ExCubicIngestion.Schema.CubicOdsTableSnapshot + + @ods_tables [ + %{ + name: "cubic_ods_qlik__edw_unsettled_crdb_sys_conf", + s3_prefix: "cubic/ods_qlik/EDW.UNSETTLED_CRDB_SYS_CONF/" + }, + ] + + def up do + Repo.transaction(fn -> + Enum.each(@ods_tables, fn ods_table -> + ods_table_rec = + Repo.insert!(%CubicTable{ + name: ods_table[:name], + s3_prefix: ods_table[:s3_prefix], + is_active: true, + is_raw: true + }) + + Repo.insert!(%CubicOdsTableSnapshot{ + table_id: ods_table_rec.id, + snapshot_s3_key: "#{ods_table[:s3_prefix]}LOAD00000001.csv.gz" + }) + end) + end) + end + + def down do + Repo.transaction(fn -> + Enum.each(@ods_tables, fn ods_table -> + ods_table_rec = CubicTable.get_by!(name: ods_table[:name]) + Repo.delete!(ods_table_rec) + Repo.delete!(CubicOdsTableSnapshot.get_by!(table_id: ods_table_rec.id)) + end) + end) + end +end