From c7886579e4e0f1a87814128538e29123f04f40d7 Mon Sep 17 00:00:00 2001 From: Max Alexander Date: Thu, 16 Jul 2026 14:53:58 -0400 Subject: [PATCH] Add EC_STAGE.METRIC_HISTORY --- .../2025071612000_adding-tables-20260716.exs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ex_cubic_ingestion/priv/repo/migrations/2025071612000_adding-tables-20260716.exs diff --git a/ex_cubic_ingestion/priv/repo/migrations/2025071612000_adding-tables-20260716.exs b/ex_cubic_ingestion/priv/repo/migrations/2025071612000_adding-tables-20260716.exs new file mode 100644 index 0000000..055e442 --- /dev/null +++ b/ex_cubic_ingestion/priv/repo/migrations/2025071612000_adding-tables-20260716.exs @@ -0,0 +1,43 @@ +defmodule ExCubicIngestion.Repo.Migrations.AddingTables20260716 do + use Ecto.Migration + + alias ExCubicIngestion.Repo + alias ExCubicIngestion.Schema.CubicTable + alias ExCubicIngestion.Schema.CubicOdsTableSnapshot + + @ods_tables [ + %{ + name: "cubic_ods_qlik__ec_stage_metric_history", + s3_prefix: "cubic/ods_qlik/EC_STAGE.METRIC_HISTORY/" + }, + ] + + 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