From a3ed042f8aa7edc3c4333523800836c26f19267a Mon Sep 17 00:00:00 2001 From: Max Alexander Date: Mon, 30 Mar 2026 16:53:44 -0400 Subject: [PATCH] Chore: Add further tables --- .../20260330120000_adding-tables-20260330.exs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 ex_cubic_ingestion/priv/repo/migrations/20260330120000_adding-tables-20260330.exs diff --git a/ex_cubic_ingestion/priv/repo/migrations/20260330120000_adding-tables-20260330.exs b/ex_cubic_ingestion/priv/repo/migrations/20260330120000_adding-tables-20260330.exs new file mode 100644 index 0000000..e8e0909 --- /dev/null +++ b/ex_cubic_ingestion/priv/repo/migrations/20260330120000_adding-tables-20260330.exs @@ -0,0 +1,59 @@ +defmodule ExCubicIngestion.Repo.Migrations.AddingTables20260330 do + use Ecto.Migration + + alias ExCubicIngestion.Repo + alias ExCubicIngestion.Schema.CubicTable + alias ExCubicIngestion.Schema.CubicOdsTableSnapshot + + @ods_tables [ + %{ + name: "cubic_ods_qlik__edw_proc_cost_pg_loss_dtl", + s3_prefix: "cubic/ods_qlik/EDW.PROC_COST_PG_LOSS_DTL/" + }, + %{ + name: "cubic_ods_qlik__edw_proc_cost_chgbk_dtl", + s3_prefix: "cubic/ods_qlik/EDW.PROC_COST_CHGBK_DTL/" + }, + %{ + name: "cubic_ods_qlik__edw_process_cost_summary", + s3_prefix: "cubic/ods_qlik/EDW.PROCESS_COST_SUMMARY/" + }, + %{ + name: "cubic_ods_qlik__edw_frm_crdb_acq_bank_fee_detail", + s3_prefix: "cubic/ods_qlik/EDW.FRM_CRDB_ACQ_BANK_FEE_DETAIL/" + }, + %{ + name: "cubic_ods_qlik__edw_frm_bank_fee_summary", + s3_prefix: "cubic/ods_qlik/EDW.FRM_BANK_FEE_SUMMARY/" + }, + ] + + 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!(CubicOdsTableSnapshot.get_by!(table_id: ods_table_rec.id)) + Repo.delete!(ods_table_rec) + end) + end) + end +end