beteran-api-kgon-server-ser.../migrations/202208051010_api_kgon_synchronization_history/up.sql

22 lines
810 B
SQL

CREATE TABLE IF NOT EXISTS api_kgon_synchronization_history (
id BIGSERIAL PRIMARY KEY,
item TEXT NOT NULL,
start_at BIGINT NOT NULL,
complete_at BIGINT NOT NULL,
code BIGINT NOT NULL,
message TEXT,
data TEXT,
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000)
);
CREATE INDEX idx_api_kgon_synchronization_history_item ON api_kgon_synchronization_history (item);
CREATE INDEX idx_api_kgon_synchronization_history_created_at ON api_kgon_synchronization_history (created_at);
-- trigger (synchronized_at)
CREATE TRIGGER tg_api_kgon_synchronization_history_synchronizations
AFTER INSERT
ON api_kgon_synchronization_history
FOR EACH ROW
EXECUTE PROCEDURE update_synchronizations();