diff --git a/seeds/safetrust/1733970410880_departments_seed.sql b/seeds/safetrust/1733970410880_departments_seed.sql index 36126ec..43ec71b 100644 --- a/seeds/safetrust/1733970410880_departments_seed.sql +++ b/seeds/safetrust/1733970410880_departments_seed.sql @@ -13,7 +13,7 @@ INSERT INTO apartments ( available_until ) VALUES ( uuid_generate_v4(), - (SELECT id FROM users WHERE email = 'john.doe@example.com'), + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), 'Modern Loft in Heredia', 'Spacious and bright loft in the heart of San José, perfect for professionals and digital nomads.', 1250.00, @@ -27,7 +27,7 @@ INSERT INTO apartments ( ), ( uuid_generate_v4(), - (SELECT id FROM users WHERE email = 'john.doe@example.com'), + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), 'Modern Loft in San Jose', 'Spacious and bright loft in the heart of San José, perfect for professionals and digital nomads', 1250.00, diff --git a/seeds/safetrust/1734151104298_escrow_transactions.sql b/seeds/safetrust/1734151104298_escrow_transactions.sql new file mode 100644 index 0000000..61f13a8 --- /dev/null +++ b/seeds/safetrust/1734151104298_escrow_transactions.sql @@ -0,0 +1,155 @@ +-- Seed for `escrow_transcations` table: + +INSERT INTO escrow_transactions ( + id, + bid_request_id, + engagement_id, + contract_id, + signer_address, + transaction_type, + status, + http_status_code, + http_response_body, + http_error_details, + amount, + initial_deposit_percentage, + cancellation_reason, + cancelled_by, + refund_status, + metadata, + created_at, + updated_at, + completed_at +) VALUES +-- Scenario 1: Create escrow, pending status +( + uuid_generate_v4(), + (SELECT id FROM bid_requests LIMIT 1 OFFSET 0), + NULL, + NULL, + NULL, + 'CREATE_ESCROW', + 'PENDING', + 200, + '{"message": "Escrow created"}'::jsonb, + NULL, + 500.00, + 50, + NULL, + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), + NULL, + '{"note": "Escrow created by user"}'::jsonb, + NOW() - INTERVAL '2 days', + NOW() - INTERVAL '1 day', + NOW() +), +-- Scenario 2: Fund escrow, processing status +( + uuid_generate_v4(), + (SELECT id FROM bid_requests LIMIT 1 OFFSET 1), + NULL, + '46bb85be-4d2c-49af-88dd-cd80f46b1502', + NULL, + 'FUND_ESCROW', + 'PROCESSING', + 202, + '{"message": "Escrow funded, processing transaction"}'::jsonb, + NULL, + 300.00, + 50, + NULL, + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), + NULL, + '{"note": "High priority"}'::jsonb, + NOW() - INTERVAL '1 day', + NOW(), + NULL +), +-- Scenario 3: Complete escrow, completed status +( + uuid_generate_v4(), + (SELECT id FROM bid_requests LIMIT 1 OFFSET 2), + NULL, + '2f6104ff-13c7-44e0-b778-32ab6b747b5a', + NULL, + 'COMPLETE_ESCROW', + 'COMPLETED', + 400, + '{"message": "Escrow completed successfully"}'::jsonb, + NULL, + 400.00, + 50, + NULL, + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), + NULL, + '{"note": "Final payment", "reason": "User request"}'::jsonb, + NOW() - INTERVAL '4 days', + NOW() - INTERVAL '3 days', + NOW() - INTERVAL '2 days' +), +-- Scenario 4: Cancel escrow, cancelled status +( + uuid_generate_v4(), + (SELECT id FROM bid_requests LIMIT 1 OFFSET 3), + NULL, + 'd7c2578a-a30f-42f0-a7c5-fefe8f31815d', + NULL, + 'CANCEL_ESCROW', + 'CANCELLED', + 400, + '{"message": "Escrow cancelled"}'::jsonb, + '{"error": "Insufficient funds"}'::jsonb, + 400.00, + 50, + 'Insufficient funds', + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), + NULL, + '{"note": "User request", "reason": "Insufficient funds"}'::jsonb, + NOW() - INTERVAL '4 days', + NOW() - INTERVAL '3 days', + NOW() - INTERVAL '2 days' +), +-- Scenario 5: Refund escrow, refunded status +( + uuid_generate_v4(), + (SELECT id FROM bid_requests LIMIT 1 OFFSET 4), + NULL, + NULL, + NULL, + 'REFUND_ESCROW', + 'REFUNDED', + 206, + '{"message": "Escrow refunded successfully"}'::jsonb, + NULL, + 250.00, + 30, + NULL, + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), + 'COMPLETED', + '{"reason": "Refund issued"}'::jsonb, + NOW() - INTERVAL '3 days', + NOW() - INTERVAL '1 day', + NOW() - INTERVAL '1 hour' +), +-- Scenario 6: Cancel escrow, failed status +( + uuid_generate_v4(), + (SELECT id FROM bid_requests LIMIT 1 OFFSET 5), + NULL, + '94ad3e1d-453b-4399-a790-ad42bedd9350', + NULL, + 'CANCEL_ESCROW', + 'FAILED', + 500, + '{"message": "Escrow cancelled"}'::jsonb, + '{"error": "Server error"}'::jsonb, + 250.00, + 50, + 'Server error', + (SELECT id FROM users WHERE email = 'john.doe@example.com' LIMIT 1), + NULL, + '{"reason": "User request failed"}'::jsonb, + NOW() - INTERVAL '4 days', + NOW() - INTERVAL '3 days', + NOW() - INTERVAL '2 days' +);