Add province-scoped branches for loan paid letters and harden loans.user_id.
Expose GET /loan-paid-off-letters/branches?province_id= for form pickers, require loans.user_id, and proxy the Vite frontend under /online/. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -216,7 +216,7 @@ CREATE TABLE IF NOT EXISTS loan_orders (
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loans (
|
||||
id bigserial PRIMARY KEY,
|
||||
user_id bigint,
|
||||
user_id bigint NOT NULL,
|
||||
passport_serie character varying(255) NOT NULL,
|
||||
passport_id character varying(255) NOT NULL,
|
||||
account_number character varying(255) NOT NULL,
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE loans
|
||||
ALTER COLUMN user_id DROP NOT NULL;
|
||||
10
db/migrations/20260811082731_loans_user_id_not_null.up.sql
Normal file
10
db/migrations/20260811082731_loans_user_id_not_null.up.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Require loans.user_id; backfill any existing NULLs to the first user.
|
||||
UPDATE loans
|
||||
SET user_id = (SELECT id FROM users ORDER BY id ASC LIMIT 1)
|
||||
WHERE user_id IS NULL
|
||||
AND EXISTS (SELECT 1 FROM users);
|
||||
|
||||
DELETE FROM loans WHERE user_id IS NULL;
|
||||
|
||||
ALTER TABLE loans
|
||||
ALTER COLUMN user_id SET NOT NULL;
|
||||
@@ -533,7 +533,7 @@ INSERT INTO loan_orders (
|
||||
INSERT INTO loans (user_id, passport_serie, passport_id, account_number) VALUES
|
||||
(2, 'I-AG', '778899', 'ACC-LOAN-10001'),
|
||||
(3, 'I-MR', '998877', 'ACC-LOAN-10002'),
|
||||
(NULL, 'I-AG', '101010', 'ACC-LOAN-10003'),
|
||||
(1, 'I-AG', '101010', 'ACC-LOAN-10003'),
|
||||
(2, 'I-AG', '303030', 'ACC-LOAN-10004');
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user