Skip to content

Commit 035ad77

Browse files
committed
chore: add kpi tables requested
1 parent 29df7b7 commit 035ad77

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
defmodule ExCubicIngestion.Repo.Migrations.AddKpiTables do
2+
use Ecto.Migration
3+
4+
alias ExCubicIngestion.Repo
5+
alias ExCubicIngestion.Schema.CubicTable
6+
alias ExCubicIngestion.Schema.CubicOdsTableSnapshot
7+
8+
@ods_table_name_1 "cubic_ods_qlik__edw_kpi_availability_event"
9+
@ods_table_s3_prefix_1 "cubic/ods_qlik/EDW.KPI_AVAILABILITY_EVENT/"
10+
11+
@ods_table_name_2 "cubic_ods_qlik__edw_kpi_target"
12+
@ods_table_s3_prefix_2 "cubic/ods_qlik/EDW.KPI_TARGET/"
13+
14+
def up do
15+
ods_table_1_rec = Repo.insert!(%CubicTable{
16+
name: @ods_table_name_1,
17+
s3_prefix: @ods_table_s3_prefix_1,
18+
is_active: true,
19+
is_raw: true
20+
})
21+
Repo.insert!(%CubicOdsTableSnapshot{
22+
table_id: ods_table_1_rec.id,
23+
snapshot_s3_key: "#{@ods_table_s3_prefix_1}LOAD00000001.csv.gz"
24+
})
25+
26+
ods_table_2_rec = Repo.insert!(%CubicTable{
27+
name: @ods_table_name_2,
28+
s3_prefix: @ods_table_s3_prefix_2,
29+
is_active: true,
30+
is_raw: true
31+
})
32+
Repo.insert!(%CubicOdsTableSnapshot{
33+
table_id: ods_table_2_rec.id,
34+
snapshot_s3_key: "#{@ods_table_s3_prefix_2}LOAD00000001.csv.gz"
35+
})
36+
end
37+
38+
def down do
39+
ods_table_1_rec = CubicTable.get_by!(name: @ods_table_name_1)
40+
Repo.delete!(ods_table_1_rec)
41+
Repo.delete!(CubicOdsTableSnapshot.get_by!(table_id: ods_table_1_rec.id))
42+
43+
ods_table_2_rec = CubicTable.get_by!(name: @ods_table_name_2)
44+
Repo.delete!(ods_table_2_rec)
45+
Repo.delete!(CubicOdsTableSnapshot.get_by!(table_id: ods_table_2_rec.id))
46+
end
47+
end

0 commit comments

Comments
 (0)