Mejora migraciones con tabla de versiones

This commit is contained in:
2026-02-17 17:22:20 +01:00
parent 8427613114
commit 459523666f
7 changed files with 187 additions and 11 deletions

View File

@@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS order_tracking (
start_date TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
update_date TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
finish_date TIMESTAMP
)
);
-- Busqueda según id de rabbit
CREATE INDEX IF NOT EXISTS idx_order_correlation
@@ -40,7 +40,7 @@ CREATE INDEX IF NOT EXISTS pending_orders
WHERE order_tracking.finish_date IS NULL;
CREATE TABLE IF NOT EXISTS order_history(
id SERIAL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
order_id BIGINT NOT NULL,
previous_status order_status NOT NULL, -- Siempre hay un estado anterior, para casos excepcioneale "unknown"
new_status order_status NOT NULL,
@@ -78,7 +78,7 @@ CREATE TABLE if not exists objenious_operation (
request_id TEXT,
mass_action_id TEXT,
operation TEXT NOT NULL,
start_date TIMESTAMP NOT NULL DEFAULT now(),
start_date TIMESTAMP NOT NULL DEFAULT now(),
last_change_date TIMESTAMP NOT NULL DEFAULT now(),
end_date TIMESTAMP,
error TEXT,
@@ -109,3 +109,18 @@ CREATE TABLE if not exists objenious_operation_change (
CREATE INDEX operation_change
ON objenious_operation_change(operation_id);
CREATE TABLE IF NOT EXISTS db_versions (
version TEXT PRIMARY KEY, -- version semantica x.x.x
notes TEXT,
creation_date TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
stable BOOLEAN DEFAULT FALSE -- Si la version ha sido testada y se puede desplegar
);
INSERT INTO db_versions (
version,
notes
)
VALUES (
'0.1.0',
'Versión base'
);