[Regression on closed #498] Three migrations share the timestamp 1785200000000 again, so their run order depends on filename sorting
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/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ệ
- node.js, typescript
- Lĩnh vực
- build-system, database
Hướng nghiên cứu
Read the three migrations in src/database/migrations/ and the migration glob at src/database/data-source.ts:22; check whether any have already been applied in shared environments before renaming files and class suffixes. Add a CI check for duplicate timestamp prefixes as suggested, then verify the migrations have unique increasing timestamps and the check catches duplicates.
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/:
1785200000000-AddBountySponsorIdStatusIndex.ts(classAddBountySponsorIdStatusIndex1785200000000)1785200000000-AddMissingLookupIndexes.ts(classAddMissingLookupIndexes1785200000000)1785200000000-AddSplitPercentageChecks.ts(classAddSplitPercentageChecks1785200000000)
Problem — The timestamp collision closed as #498 is present again: three distinct migrations declare the identical timestamp 1785200000000, which is both the suffix of the class name and the value TypeORM derives the sort key from. TypeORM sorts pending migrations by that numeric timestamp; for equal timestamps the resulting order is whatever order the glob in src/database/data-source.ts:22 (__dirname + '/migrations/*{.ts,.js}') yielded, i.e. filesystem/locale-dependent filename sorting. The migrations bookkeeping table then records three rows with the same timestamp, so migration:revert (which reverts "the last executed migration" by that key) has no deterministic notion of which of the three is last.
Why it matters — Two concrete consequences:
npm run migration:revertcan revert a different migration than the one that ran last, and repeated reverts can interleave the three unpredictably. Rolling back a bad deploy is exactly when this matters.- Run order differing between environments (developer macOS checkout vs. a Linux CI container vs. a production image) means the three are not guaranteed to apply in the same sequence everywhere. Today the three happen to be mutually independent (two index migrations and one CHECK-constraint migration), so this does not corrupt anything yet — but the invariant "migration order is identical in every environment" is broken, and the next migration added at this timestamp, or any later migration that assumes one of these ran first, inherits a non-reproducible schema.
Reproduction / failure path
ls src/database/migrations | cut -d- -f1 | sort | uniq -dprints1785200000000.- Run
npm run migration:runon a database at the previous migration, thenselect timestamp, name from migrations order by id desc limit 3— three rows share1785200000000. npm run migration:revert— the migration chosen is not deterministically the last one authored.
Suggested fix
- Renumber two of the three to unique, strictly increasing timestamps (e.g. keep
1785200000000, and move the others to1785200000001and1785200000002), renaming both the file and the class-name suffix so file and class agree. - Only renumber migrations that have not yet been applied in any shared environment; if any of the three is already recorded in a deployed
migrationstable, update that row'stimestamp/namein the renumbering migration's accompanying note rather than silently re-running it. - Add a CI check that fails when two files in
src/database/migrationsshare a timestamp prefix. This is now the third timestamp collision in this directory (#322 for1784800000000, #498, and this one), so a one-line guard is cheaper than filing it again:! ls src/database/migrations | cut -d- -f1 | sort | uniq -d | grep .
- 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ự
-
ログイン中の404画面にヘッダーとナビを出すĐang mởCodex使用可 コード
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ryuki-moro/Nicomaru#218 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
sveltejs/svelte-eslint-parser#1008 ·
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
silverbucket/inbox-rs#351 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: The H2 series' and the H3C's fan 3 is labelled "Chamber Fan", Bambu calls it the exhaust fanĐang mởarea:ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug front P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
invoicerr-app/invoicerr#964 ·
Maintainer thường phản hồi trong vòng 1 ngày