Skip to content

Commit

Permalink
Merge branch 'feat/1610-notification-for-greyed-out-submission-button…
Browse files Browse the repository at this point in the history
…' of github.com:bcgov/nr-spar into feat/1610-notification-for-greyed-out-submission-button
  • Loading branch information
mgaseta committed Dec 5, 2024
2 parents 3f13c85 + ac5f1af commit b2de04b
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions backend/src/main/resources/db/migration/V46__fix_etl_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
-- Table ETL_EXECUTION_LOG does not exist as it was dropped from the database in
-- V33 and then not created again, however it does exist in the physical database
-- for TEST and PROD. This migration should ensure that any subsequent database
-- created from these migrations resembles the current state of the database,
-- while at the same time not modifying the physical table in TEST and PROD.

create table IF NOT EXISTS spar.etl_execution_log(
from_timestamp timestamp not null,
to_timestamp timestamp not null,
run_status varchar(100) not null,
updated_at timestamp default now() not null,
created_at timestamp default now() not null
);

comment on table spar.ETL_EXECUTION_LOG is 'ETL Tool monitoring table to store execution current instance of batch processing interfaces';
comment on column spar.ETL_EXECUTION_LOG.from_timestamp is 'From timestamp for the run (i.e. update_timestamp between from_timestamp and to_timetsamp)';
comment on column spar.ETL_EXECUTION_LOG.to_timestamp is 'To timestamp for the run (i.e. update_timestamp between from_timestamp and to_timetsamp)';
comment on column spar.ETL_EXECUTION_LOG.run_status is 'Status of ETL execution';
comment on column spar.ETL_EXECUTION_LOG.updated_at is 'Timestamp of the last time this record was updated';
comment on column spar.ETL_EXECUTION_LOG.created_at is 'Timestamp of the time this record was created';

-- etl execution log hist has a completely different definition than
-- the one that is defined in V33, where it gets dropped and re-created
-- Seeing as the table already exists and has data in it, this
-- attempts to not modify the physical table, but rather modify net
-- new migrations so that they create the same structure as currently
-- exists in TEST / PROD Databases.
--
-- new structure should only have:
-- entry_timestamp
-- log_details
-- as columns
alter table spar.etl_execution_log_hist
add column
IF NOT EXISTS entry_timestamp timestamp(6) not null default current_timestamp;

alter table spar.etl_execution_log_hist
add column
IF NOT EXISTS log_details jsonb not null;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS interface_id ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS execution_id ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS execution_status ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS execution_details ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS source_connect_timedelta ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS source_extract_timedelta ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS source_extract_row_count ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS target_connect_timedelta ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS target_load_timedelta ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS target_load_row_count ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS process_started_at ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS process_finished_at ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS process_timedelta ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS last_run_ts ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS current_run_ts ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS retry_process ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS updated_at ;

alter table spar.etl_execution_log_hist
drop column
IF EXISTS created_at ;

0 comments on commit b2de04b

Please sign in to comment.