diff --git a/db/migrations/20231229091800_add_service_fee.up.sql b/db/migrations/20231229091800_add_service_fee.up.sql index 6bd7cb6a..3dcf2dc9 100644 --- a/db/migrations/20231229091800_add_service_fee.up.sql +++ b/db/migrations/20231229091800_add_service_fee.up.sql @@ -1,7 +1,7 @@ +alter table invoices ALTER COLUMN fee SET DEFAULT 0; alter table invoices ADD COLUMN IF NOT EXISTS service_fee bigint default 0; alter table invoices ADD COLUMN IF NOT EXISTS routing_fee bigint default 0; --- maybe manually migrate existing data? --- alter table invoices ALTER COLUMN fee SET DEFAULT 0; --- update invoices set fee = 0 where fee IS NULL; --- update invoices set routing_fee = fee where routing_fee=0; +-- migrate existing data +update invoices set fee = 0 where fee IS NULL; +update invoices set routing_fee = fee where fee > 0;