-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from mbta/rr-add-transaction_origin_dimension
Added ODS Tables: cubic/ods_qlik/CCH_STAGE.CATEGORIZATION_RULE/ cubic/ods_qlik/CCH_STAGE.CATEGORY/ cubic/ods_qlik/CCH_STAGE.REPROCESS_ACTION/ cubic/ods_qlik/CCH_STAGE.TRANSACTION_TYPE/ cubic/ods_qlik/EDW.CASHBOX_EVENT_DIMENSION/ cubic/ods_qlik/EDW.CHGBK_ACTIVITY_TYPE_DIMENSION/ cubic/ods_qlik/EDW.PASS_LIAB_EVENT_TYPE_DIMENSION/ cubic/ods_qlik/EDW.PURSE_TYPE_DIMENSION/ cubic/ods_qlik/EDW.TRANSACTION_ORIGIN_DIMENSION/
- Loading branch information
Showing
2 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
ex_cubic_ingestion/priv/repo/migrations/20241104104113_add_even_more_ods_tables.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
defmodule ExCubicIngestion.Repo.Migrations.AddEvenMoreOdsTables do | ||
use Ecto.Migration | ||
|
||
alias ExCubicIngestion.Repo | ||
alias ExCubicIngestion.Schema.CubicTable | ||
alias ExCubicIngestion.Schema.CubicOdsTableSnapshot | ||
|
||
@ods_tables [ | ||
%{ | ||
name: "cubic_ods_qlik__cch_stage_categorization_rule", | ||
s3_prefix: "cubic/ods_qlik/CCH_STAGE.CATEGORIZATION_RULE/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__cch_stage_category", | ||
s3_prefix: "cubic/ods_qlik/CCH_STAGE.CATEGORY/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__cch_stage_reprocess_action", | ||
s3_prefix: "cubic/ods_qlik/CCH_STAGE.REPROCESS_ACTION/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__cch_stage_transaction_type", | ||
s3_prefix: "cubic/ods_qlik/CCH_STAGE.TRANSACTION_TYPE/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__edw_cashbox_event_dimension", | ||
s3_prefix: "cubic/ods_qlik/EDW.CASHBOX_EVENT_DIMENSION/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__edw_chgbk_activity_type_dimension", | ||
s3_prefix: "cubic/ods_qlik/EDW.CHGBK_ACTIVITY_TYPE_DIMENSION/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__edw_pass_liab_event_type_dimension", | ||
s3_prefix: "cubic/ods_qlik/EDW.PASS_LIAB_EVENT_TYPE_DIMENSION/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__edw_purse_type_dimension", | ||
s3_prefix: "cubic/ods_qlik/EDW.PURSE_TYPE_DIMENSION/" | ||
}, | ||
%{ | ||
name: "cubic_ods_qlik__edw_transaction_origin_dimension", | ||
s3_prefix: "cubic/ods_qlik/EDW.TRANSACTION_ORIGIN_DIMENSION/" | ||
} | ||
] | ||
|
||
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 |