From e850f4ddee3b0fb57480cded93fde36c5bad37d5 Mon Sep 17 00:00:00 2001 From: Ted Alexander Date: Fri, 31 Oct 2025 13:39:51 -0400 Subject: [PATCH 1/2] Adding EDW.TRANSIT_ACCOUNT_BALANCE --- .../20251030204555_adding-tables-20251030.exs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs diff --git a/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs b/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs new file mode 100644 index 0000000..4d4eb25 --- /dev/null +++ b/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs @@ -0,0 +1,43 @@ +defmodule ExCubicIngestion.Repo.Migrations.AddMoreTablesForIngestion do + use Ecto.Migration + + alias ExCubicIngestion.Repo + alias ExCubicIngestion.Schema.CubicTable + alias ExCubicIngestion.Schema.CubicOdsTableSnapshot + + @ods_tables [ + %{ + name: "cubic_ods_qlik__edw_transit_account_balance", + s3_prefix: "cubic/ods_qlik/EDW.TRANSIT_ACCOUNT_BALANCE/" + }, + ] + + 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 From 451fde0ff26781fcefdff9a3bd0d6fc4a82cf5e1 Mon Sep 17 00:00:00 2001 From: Ted Alexander Date: Fri, 31 Oct 2025 16:11:36 -0400 Subject: [PATCH 2/2] Fixing module name --- .../repo/migrations/20251030204555_adding-tables-20251030.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs b/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs index 4d4eb25..188ef4e 100644 --- a/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs +++ b/ex_cubic_ingestion/priv/repo/migrations/20251030204555_adding-tables-20251030.exs @@ -1,4 +1,4 @@ -defmodule ExCubicIngestion.Repo.Migrations.AddMoreTablesForIngestion do +defmodule ExCubicIngestion.Repo.Migrations.AddMoreTablesForIngestion20251030 do use Ecto.Migration alias ExCubicIngestion.Repo