Skip to content

Commit 673be52

Browse files
committed
Adding EDW.UNSETTLED_CRDB_SYS_CONF
1 parent 151c27e commit 673be52

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
defmodule ExCubicIngestion.Repo.Migrations.AddingTables20260302 do
2+
use Ecto.Migration
3+
4+
alias ExCubicIngestion.Repo
5+
alias ExCubicIngestion.Schema.CubicTable
6+
alias ExCubicIngestion.Schema.CubicOdsTableSnapshot
7+
8+
@ods_tables [
9+
%{
10+
name: "cubic_ods_qlik__edw_unsettled_crdb_sys_conf",
11+
s3_prefix: "cubic/ods_qlik/EDW.UNSETTLED_CRDB_SYS_CONF/"
12+
},
13+
]
14+
15+
def up do
16+
Repo.transaction(fn ->
17+
Enum.each(@ods_tables, fn ods_table ->
18+
ods_table_rec =
19+
Repo.insert!(%CubicTable{
20+
name: ods_table[:name],
21+
s3_prefix: ods_table[:s3_prefix],
22+
is_active: true,
23+
is_raw: true
24+
})
25+
26+
Repo.insert!(%CubicOdsTableSnapshot{
27+
table_id: ods_table_rec.id,
28+
snapshot_s3_key: "#{ods_table[:s3_prefix]}LOAD00000001.csv.gz"
29+
})
30+
end)
31+
end)
32+
end
33+
34+
def down do
35+
Repo.transaction(fn ->
36+
Enum.each(@ods_tables, fn ods_table ->
37+
ods_table_rec = CubicTable.get_by!(name: ods_table[:name])
38+
Repo.delete!(ods_table_rec)
39+
Repo.delete!(CubicOdsTableSnapshot.get_by!(table_id: ods_table_rec.id))
40+
end)
41+
end)
42+
end
43+
end

0 commit comments

Comments
 (0)