[Regression on closed #570 / #318] Still no initial-schema migration — migration:run on a fresh database fails on the first ALTER TABLE
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- postgresql, typescript
Hướng nghiên cứu
Read src/database/data-source.ts:22 and inspect all migrations in src/database/migrations/, especially the earliest migration at 1784272650000-EscrowFkIntegrityAndSponsorId.ts:32. Reproduce the failure with npm run migration:run against an empty PostgreSQL database, then establish a baseline that creates the current schema and works with existing deployments. Done means migrations succeed from an empty database and a required CI job verifies that path.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Location — src/database/migrations/ (the whole directory), entry point src/database/data-source.ts:22. The earliest migration is 1784272650000-EscrowFkIntegrityAndSponsorId.ts:32.
Problem — The missing initial-schema migration closed as #318 and re-filed and closed as #570 is still missing on the default branch. Of the 15 migration files, exactly one contains a CREATE TABLE (1784304511000-CreateIdempotencyKeys.ts, for idempotency_keys). Every other migration is an ALTER TABLE / CREATE INDEX / ADD CONSTRAINT against tables that no migration ever creates: escrows, bounties, payments, issues, milestones, maintenance_pools, repositories, teams, team_member_splits, reputation_snapshots, users, github_accounts, webhook_events.
The first migration to run begins with:
await queryRunner.query(
`ALTER TABLE "escrows" ADD COLUMN IF NOT EXISTS "sponsorId" varchar`,
);
Against an empty database this aborts with ERROR: relation "escrows" does not exist. (ADD COLUMN IF NOT EXISTS guards the column, not the table.) The schema therefore still only ever comes into existence through synchronize, which data-source.ts:25 correctly sets to false for the CLI — so the migration path and the only working schema-creation path are disjoint.
Why it matters — There is no way to stand up this application from the repository. A new contributor, a fresh CI database, a staging rebuild, or a production deploy all fail at the first migration. The practical workaround is to boot the app once with synchronize: true and then run migrations, which means the deployed schema is whatever the entity decorators happened to produce at that moment, with no reviewable record — the exact situation migrations were introduced (#14, #27) to eliminate. It also makes entity/migration drift undetectable: there is no baseline to diff against.
Reproduction / failure path
createdb mergefi_freshDATABASE_URL=postgresql://postgres:postgres@localhost:5432/mergefi_fresh npm run migration:run- Fails immediately:
QueryFailedError: relation "escrows" does not exist.
Suggested fix
- Generate a baseline migration that creates the full current schema and number it before
1784272650000: boot a scratch database withsynchronize: trueagainst the currententitieslist, then runnpm run migration:generate -- src/database/migrations/InitialSchemafrom an empty database and renumber the output to a timestamp lower than1784272650000. - Make it idempotent for already-deployed environments (
CREATE TABLE IF NOT EXISTS/CREATE TYPE ... IF NOT EXISTSguards), or document that existing databases must have the row inserted intomigrationsmanually so the baseline is recorded as applied without re-running. - Add the CI step that #320/#572 asked for and wire it to a genuinely empty Postgres service container:
migration:runon a fresh database must be a required job. Without it this will regress a fourth time — a migration suite that is never run from zero cannot be known to work.
- Ngôn ngữ chính
- TypeScript
- Star
- 2
- Fork
- 90
- Merge trung bình
- 31 phút
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MergeFi/backend
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MergeFi/backend
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zapcooking/frontend#946 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
WiliamRosa/cosmos-semantic-platform#40 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
liberation-data/drivine#733 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
makecindy/cindy#10062 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày