Skip to content

Commit

Permalink
Merge pull request #59 from GideonBature/main
Browse files Browse the repository at this point in the history
Add Seed for escrow_transactions table 🌱 #48
  • Loading branch information
diegoTech14 authored Dec 17, 2024
2 parents 542fd0b + 5a7cd94 commit 6a64309
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 2 deletions.
4 changes: 2 additions & 2 deletions seeds/safetrust/1733970410880_departments_seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ INSERT INTO apartments (
available_until
) VALUES (
uuid_generate_v4(),
(SELECT id FROM users WHERE email = '[email protected]'),
(SELECT id FROM users WHERE email = '[email protected]' LIMIT 1),
'Modern Loft in Heredia',
'Spacious and bright loft in the heart of San José, perfect for professionals and digital nomads.',
1250.00,
Expand All @@ -27,7 +27,7 @@ INSERT INTO apartments (
),
(
uuid_generate_v4(),
(SELECT id FROM users WHERE email = '[email protected]'),
(SELECT id FROM users WHERE email = '[email protected]' 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,
Expand Down
155 changes: 155 additions & 0 deletions seeds/safetrust/1734151104298_escrow_transactions.sql
Original file line number Diff line number Diff line change
@@ -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 = '[email protected]' 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 = '[email protected]' 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 = '[email protected]' 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 = '[email protected]' 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 = '[email protected]' 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 = '[email protected]' LIMIT 1),
NULL,
'{"reason": "User request failed"}'::jsonb,
NOW() - INTERVAL '4 days',
NOW() - INTERVAL '3 days',
NOW() - INTERVAL '2 days'
);

0 comments on commit 6a64309

Please sign in to comment.