Seguimiento de ordenes desde la ingesta
This commit is contained in:
40
deployment/database/01-ordenes-sim.sql
Normal file
40
deployment/database/01-ordenes-sim.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
-- Tablas para el seguimiento de las operaciones de SIM sin importar
|
||||
-- la cmpañia.
|
||||
|
||||
CREATE TYPE order_types AS ENUM ('activate','preactivate','cancel','pause','reactivate','unknown');
|
||||
CREATE TYPE order_status AS ENUM (
|
||||
'pending', -- Mensaje creado/enviado a RabbitMQ
|
||||
'running', -- Consumidor ha cogido el mensaje (opcional)
|
||||
'finished', -- Procesado correctamente
|
||||
'failed', -- Falló, pero podría reintentarse (Pasar a delay?)
|
||||
'dlx' -- Falló definitivamente y está en Dead Letter Exchange
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS order_tracking (
|
||||
order_id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
correlation_id VARCHAR(255) NOT NULL, -- ID compartido con RabbitMQ (message_id)
|
||||
exchange VARCHAR(100), -- Exchange al que se envia (de momento solo hay 1 principal sin contar delay y dlx)
|
||||
routing_key VARCHAR(100), -- Routing key del mensaje
|
||||
|
||||
payload JSONB, -- Duda si es optimo guardar la copia, es útil en caso de fallo
|
||||
|
||||
-- Campos de reintentos?
|
||||
|
||||
status order_status NOT NULL DEFAULT 'PENDING',
|
||||
retry_count INT DEFAULT 0,
|
||||
error_message TEXT, -- Razón del fallo
|
||||
-- error_stacktrace TEXT, -- Recomendación, no se hasta que punto es necesario
|
||||
|
||||
start_date TIMESTAMP NOT NULL DEFAULT now(),
|
||||
update_date TIMESTAMP NOT NULL DEFAULT now(),
|
||||
finished_date TIMESTAMP
|
||||
)
|
||||
|
||||
CREATE TABALE IF NOT EXISTS order_history(
|
||||
history_id SERIAL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
order_id UUID REFERENCES queue_operations(operation_id) ON DELETE CASCADE,
|
||||
previous_status order_status NOT NULL, -- Siempre hay un estado anterior, para casos excepcioneale "unknown"
|
||||
new_status order_status NOT NULL,
|
||||
change_reason TEXT,
|
||||
change_date TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
);
|
||||
@@ -4,11 +4,13 @@ CREATE TYPE status_enum AS ENUM ('noRequestID','noMassID','running','finished','
|
||||
-- Tabla para gestionar las peticiones de cambio de objenious.
|
||||
-- Para una o mas lineas se pueden lanzar operacione que no sabemos
|
||||
-- con certeza cuando van a terminar.
|
||||
-- Estas tablas está fuertemente ligadas al sistema que usa la plataforma
|
||||
-- de objenioius y no debe unsarse para otra compañia.
|
||||
CREATE TABLE if not exists objenious_operation (
|
||||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
retry_count INT DEFAULT 0,
|
||||
max_retry INT DEFAULT 5,
|
||||
max_date_retry TIMESTAMP DEFAULT NULL,
|
||||
retry_count INT DEFAULT 0, -- No implementado en codigo
|
||||
max_retry INT DEFAULT 5, -- No implementado en codigo
|
||||
max_date_retry TIMESTAMP DEFAULT NULL, -- No implementado en codigo
|
||||
iccids TEXT,
|
||||
request_id TEXT,
|
||||
mass_action_id TEXT,
|
||||
Reference in New Issue
Block a user