Changeset ef1c1c7 for server/db/reports_demo_data.sql
- Timestamp:
- 09/24/26 17:43:19 (6 days ago)
- Branches:
- main
- Children:
- 0cee8ec
- Parents:
- a531b45
- File:
-
- 1 edited
-
server/db/reports_demo_data.sql (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
server/db/reports_demo_data.sql
ra531b45 ref1c1c7 28 28 -- description/source) before re-inserting. 29 29 30 -- P7: users' cash (available + reserved) must equal their ledger at 31 -- COMMIT, so the balance moves by exactly what this script removes and 32 -- re-adds to the ledger, all in one transaction. The historical orders are 33 -- imported as completely filled. 34 35 BEGIN; 36 30 37 SET search_path TO project, public; 38 39 UPDATE users u 40 SET available_balance = u.available_balance - d.total 41 FROM (SELECT user_id, SUM(amount) AS total FROM transactions 42 WHERE description = 'P6 demo data' GROUP BY user_id) d 43 WHERE u.id = d.user_id; 31 44 32 45 DELETE FROM transactions WHERE description = 'P6 demo data'; … … 98 111 -- Executed orders: who participated in which market, across the same quarters. 99 112 -- ============================================================================ 100 INSERT INTO orders (id, user_id, market_id, side, type, status, quantity, price, placed_at, executed_at) VALUES113 INSERT INTO orders (id, user_id, market_id, side, type, status, quantity, filled_quantity, price, placed_at, executed_at) VALUES 101 114 ('e1111111-1111-1111-1111-111111111111', 'b1111111-1111-1111-1111-111111111111', 102 'a1111111-1111-1111-1111-111111111111', 'buy', 'market', 'executed', 0.5000, 40000.000000,115 'a1111111-1111-1111-1111-111111111111', 'buy', 'market', 'executed', 0.5000, 0.5000, 40000.000000, 103 116 '2025-07-15 10:00', '2025-07-15 10:00'), 104 117 ('e2222222-2222-2222-2222-222222222222', 'b1111111-1111-1111-1111-111111111111', 105 'a2222222-2222-2222-2222-222222222222', 'sell', 'market', 'executed', 3.0000, 4000.000000,118 'a2222222-2222-2222-2222-222222222222', 'sell', 'market', 'executed', 3.0000, 3.0000, 4000.000000, 106 119 '2025-10-15 10:00', '2025-10-15 10:00'), 107 120 ('e3333333-3333-3333-3333-333333333333', 'b2222222-2222-2222-2222-222222222222', 108 'a1111111-1111-1111-1111-111111111111', 'buy', 'market', 'executed', 1.2000, 55000.000000,121 'a1111111-1111-1111-1111-111111111111', 'buy', 'market', 'executed', 1.2000, 1.2000, 55000.000000, 109 122 '2026-01-15 10:00', '2026-01-15 10:00'), 110 123 ('e4444444-4444-4444-4444-444444444444', 'b2222222-2222-2222-2222-222222222222', 111 'a1111111-1111-1111-1111-111111111111', 'buy', 'market', 'executed', 1.0000, 60000.000000,124 'a1111111-1111-1111-1111-111111111111', 'buy', 'market', 'executed', 1.0000, 1.0000, 60000.000000, 112 125 '2026-04-15 10:00', '2026-04-15 10:00'), 113 126 ('e5555555-5555-5555-5555-555555555555', 'b3333333-3333-3333-3333-333333333333', 114 'a2222222-2222-2222-2222-222222222222', 'sell', 'market', 'executed', 2.0000, 3600.000000,127 'a2222222-2222-2222-2222-222222222222', 'sell', 'market', 'executed', 2.0000, 2.0000, 3600.000000, 115 128 '2026-01-15 10:00', '2026-01-15 10:00'); 129 130 UPDATE users u 131 SET available_balance = u.available_balance + d.total 132 FROM (SELECT user_id, SUM(amount) AS total FROM transactions 133 WHERE description = 'P6 demo data' GROUP BY user_id) d 134 WHERE u.id = d.user_id; 135 136 COMMIT;
Note:
See TracChangeset
for help on using the changeset viewer.
