Fixes for re-running reset scripts
This commit is contained in:
@@ -175,8 +175,8 @@ ORDER BY
|
||||
c.name,
|
||||
st.vendor;
|
||||
|
||||
-- Types are created by the reset script
|
||||
CREATE TABLE calculate_history (
|
||||
-- History and status tables
|
||||
CREATE TABLE IF NOT EXISTS calculate_history (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
end_time TIMESTAMP NULL,
|
||||
@@ -193,24 +193,18 @@ CREATE TABLE calculate_history (
|
||||
additional_info JSONB
|
||||
);
|
||||
|
||||
CREATE INDEX idx_status_time ON calculate_history(status, start_time);
|
||||
|
||||
CREATE TABLE calculate_status (
|
||||
CREATE TABLE IF NOT EXISTS calculate_status (
|
||||
module_name module_name PRIMARY KEY,
|
||||
last_calculation_timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX idx_last_calc ON calculate_status(last_calculation_timestamp);
|
||||
|
||||
CREATE TABLE sync_status (
|
||||
CREATE TABLE IF NOT EXISTS sync_status (
|
||||
table_name VARCHAR(50) PRIMARY KEY,
|
||||
last_sync_timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_sync_id BIGINT
|
||||
);
|
||||
|
||||
CREATE INDEX idx_last_sync ON sync_status(last_sync_timestamp);
|
||||
|
||||
CREATE TABLE import_history (
|
||||
CREATE TABLE IF NOT EXISTS import_history (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
table_name VARCHAR(50) NOT NULL,
|
||||
start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
@@ -225,5 +219,7 @@ CREATE TABLE import_history (
|
||||
additional_info JSONB
|
||||
);
|
||||
|
||||
CREATE INDEX idx_table_time ON import_history(table_name, start_time);
|
||||
CREATE INDEX idx_import_history_status ON import_history(status);
|
||||
-- Create all indexes after tables are fully created
|
||||
CREATE INDEX IF NOT EXISTS idx_last_calc ON calculate_status(last_calculation_timestamp);
|
||||
CREATE INDEX IF NOT EXISTS idx_last_sync ON sync_status(last_sync_timestamp);
|
||||
CREATE INDEX IF NOT EXISTS idx_table_time ON import_history(table_name, start_time);
|
||||
Reference in New Issue
Block a user