mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix: defer fifo ayam migrations until seed exists
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
BEGIN;
|
||||
|
||||
DELETE FROM fifo_stock_v2_route_rules
|
||||
WHERE flag_group_code = 'AYAM'
|
||||
AND lane = 'USABLE'
|
||||
AND function_code = 'CHICKIN_OUT'
|
||||
AND source_table = 'project_chickins';
|
||||
-- no-op: moved to 20260306090012_fix_fifo_chickin_out_after_seed.down.sql
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -1,34 +1,6 @@
|
||||
BEGIN;
|
||||
|
||||
INSERT INTO fifo_stock_v2_route_rules(
|
||||
flag_group_code,
|
||||
lane,
|
||||
function_code,
|
||||
source_table,
|
||||
source_id_column,
|
||||
product_warehouse_col,
|
||||
quantity_col,
|
||||
used_quantity_col,
|
||||
pending_quantity_col,
|
||||
scope_sql,
|
||||
legacy_type_key,
|
||||
allow_pending_default,
|
||||
is_active
|
||||
)
|
||||
VALUES
|
||||
('AYAM', 'USABLE', 'CHICKIN_OUT', 'project_chickins', 'id', 'product_warehouse_id', 'usage_qty', NULL, 'pending_usage_qty', 'deleted_at IS NULL', 'PROJECT_CHICKIN', TRUE, TRUE)
|
||||
ON CONFLICT (flag_group_code, lane, function_code, source_table) DO UPDATE
|
||||
SET
|
||||
source_id_column = EXCLUDED.source_id_column,
|
||||
product_warehouse_col = EXCLUDED.product_warehouse_col,
|
||||
quantity_col = EXCLUDED.quantity_col,
|
||||
used_quantity_col = EXCLUDED.used_quantity_col,
|
||||
pending_quantity_col = EXCLUDED.pending_quantity_col,
|
||||
scope_sql = EXCLUDED.scope_sql,
|
||||
legacy_type_key = EXCLUDED.legacy_type_key,
|
||||
allow_pending_default = EXCLUDED.allow_pending_default,
|
||||
updated_at = NOW(),
|
||||
-- Keep existing is_active (do not override disable migration if it was intentional).
|
||||
is_active = fifo_stock_v2_route_rules.is_active;
|
||||
-- no-op: moved to 20260306090012_fix_fifo_chickin_out_after_seed.up.sql
|
||||
-- to ensure AYAM flag group exists before route-rule upsert.
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
BEGIN;
|
||||
|
||||
DELETE FROM fifo_stock_v2_flag_members
|
||||
WHERE flag_name = 'AYAM'
|
||||
AND flag_group_code = 'AYAM';
|
||||
-- no-op: moved to 20260306090013_add_ayam_flag_member_fifo_v2_after_seed.down.sql
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
BEGIN;
|
||||
|
||||
INSERT INTO fifo_stock_v2_flag_members(flag_name, flag_group_code, priority, is_active, created_at, updated_at)
|
||||
VALUES
|
||||
('AYAM', 'AYAM', 5, TRUE, NOW(), NOW())
|
||||
ON CONFLICT (flag_name) DO UPDATE
|
||||
SET
|
||||
flag_group_code = EXCLUDED.flag_group_code,
|
||||
priority = EXCLUDED.priority,
|
||||
is_active = TRUE,
|
||||
updated_at = NOW();
|
||||
-- no-op: moved to 20260306090013_add_ayam_flag_member_fifo_v2_after_seed.up.sql
|
||||
-- to ensure AYAM flag group exists before inserting AYAM member.
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
BEGIN;
|
||||
|
||||
DELETE FROM fifo_stock_v2_route_rules
|
||||
WHERE flag_group_code = 'AYAM'
|
||||
AND lane = 'USABLE'
|
||||
AND function_code = 'CHICKIN_OUT'
|
||||
AND source_table = 'project_chickins';
|
||||
|
||||
COMMIT;
|
||||
@@ -0,0 +1,34 @@
|
||||
BEGIN;
|
||||
|
||||
INSERT INTO fifo_stock_v2_route_rules(
|
||||
flag_group_code,
|
||||
lane,
|
||||
function_code,
|
||||
source_table,
|
||||
source_id_column,
|
||||
product_warehouse_col,
|
||||
quantity_col,
|
||||
used_quantity_col,
|
||||
pending_quantity_col,
|
||||
scope_sql,
|
||||
legacy_type_key,
|
||||
allow_pending_default,
|
||||
is_active
|
||||
)
|
||||
VALUES
|
||||
('AYAM', 'USABLE', 'CHICKIN_OUT', 'project_chickins', 'id', 'product_warehouse_id', 'usage_qty', NULL, 'pending_usage_qty', 'deleted_at IS NULL', 'PROJECT_CHICKIN', TRUE, TRUE)
|
||||
ON CONFLICT (flag_group_code, lane, function_code, source_table) DO UPDATE
|
||||
SET
|
||||
source_id_column = EXCLUDED.source_id_column,
|
||||
product_warehouse_col = EXCLUDED.product_warehouse_col,
|
||||
quantity_col = EXCLUDED.quantity_col,
|
||||
used_quantity_col = EXCLUDED.used_quantity_col,
|
||||
pending_quantity_col = EXCLUDED.pending_quantity_col,
|
||||
scope_sql = EXCLUDED.scope_sql,
|
||||
legacy_type_key = EXCLUDED.legacy_type_key,
|
||||
allow_pending_default = EXCLUDED.allow_pending_default,
|
||||
updated_at = NOW(),
|
||||
-- Keep existing is_active (do not override disable migration if it was intentional).
|
||||
is_active = fifo_stock_v2_route_rules.is_active;
|
||||
|
||||
COMMIT;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
BEGIN;
|
||||
|
||||
DELETE FROM fifo_stock_v2_flag_members
|
||||
WHERE flag_name = 'AYAM'
|
||||
AND flag_group_code = 'AYAM';
|
||||
|
||||
COMMIT;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
BEGIN;
|
||||
|
||||
INSERT INTO fifo_stock_v2_flag_members(flag_name, flag_group_code, priority, is_active, created_at, updated_at)
|
||||
VALUES
|
||||
('AYAM', 'AYAM', 5, TRUE, NOW(), NOW())
|
||||
ON CONFLICT (flag_name) DO UPDATE
|
||||
SET
|
||||
flag_group_code = EXCLUDED.flag_group_code,
|
||||
priority = EXCLUDED.priority,
|
||||
is_active = TRUE,
|
||||
updated_at = NOW();
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user