Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0
Why this matters
Migration order by timestamp: 1788000000018_unified-contract-events.js renames the loan_events table to contract_events and creates a VIEW named loan_events (lines 7,52-69). The next migration 1789000000000_ensure-core-tables.js:31-37 guards with IF NOT EXISTS (SELECT FROM pg_tables WHERE tablename='loan_events') THEN CREATE TABLE loan_events (...). pg_tables only lists ordinary tables (relkind r/p) and excludes views, so the guard evaluates TRUE and runs CREATE TABLE loan_events, which fails with relation loan_events already exists because the view occupies that name. On any from-scratch sequential migration the run aborts.
Acceptance criteria
Files to touch
backend/migrations/1789000000000_ensure-core-tables.js
backend/migrations/1788000000018_unified-contract-events.js
Out of scope
- Scores column rename runtime mismatch (already filed)
- Indexer inserting into the view (already filed)
Why this matters
Migration order by timestamp: 1788000000018_unified-contract-events.js renames the loan_events table to contract_events and creates a VIEW named loan_events (lines 7,52-69). The next migration 1789000000000_ensure-core-tables.js:31-37 guards with IF NOT EXISTS (SELECT FROM pg_tables WHERE tablename='loan_events') THEN CREATE TABLE loan_events (...). pg_tables only lists ordinary tables (relkind r/p) and excludes views, so the guard evaluates TRUE and runs CREATE TABLE loan_events, which fails with relation loan_events already exists because the view occupies that name. On any from-scratch sequential migration the run aborts.
Acceptance criteria
Files to touch
backend/migrations/1789000000000_ensure-core-tables.jsbackend/migrations/1788000000018_unified-contract-events.jsOut of scope