René's URL Explorer Experiment


Title: feat(db): auto-apply tracked script data migrations in db:migrate by TheodoreSpeaks · Pull Request #5497 · simstudioai/sim · GitHub

Open Graph Title: feat(db): auto-apply tracked script data migrations in db:migrate by TheodoreSpeaks · Pull Request #5497 · simstudioai/sim

X Title: feat(db): auto-apply tracked script data migrations in db:migrate by TheodoreSpeaks · Pull Request #5497 · simstudioai/sim

Description: Summary Self-hosted deployments only ran drizzle SQL migrations — one-off TS backfill scripts never reached them. This adds a minimal run-once script-migration mechanism to the existing db:migrate entrypoint, so compose/helm pick it up with zero config changes New packages/db/script-migrations/: ScriptMigration interface, explicit registry, and a runner invoked from migrate.ts after SQL migrations succeed, inside the same advisory-lock session. Applied scripts are recorded by name in a runner-managed script_migrations table (mirrors how drizzle manages __drizzle_migrations — deliberately not in schema.ts) Ports the order_key fractional-indexing backfill as entry 0001 (old apps/sim/scripts/backfill-table-order-keys.ts deleted): same per-table advisory lock + deterministic re-key from position, chunked writes now via 2-param unnest instead of VALUES lists. Per-table failures are isolated, then the migration throws so it stays pending and retries only still-unkeyed tables Moves the dependency-free fractional-indexing.ts into @sim/utils/fractional-indexing so it's available inside the slim migrations image; lib/table/order-key.ts stays as the app-side wrapper Hosted runs the same path once as a near-no-op (insert path dual-writes order_key unconditionally, so the pending set is empty), records the journal row, and skips thereafter Authoring rules are documented on the interface: idempotent/resumable, db-level imports only, scripts own their transactions, and a SQL migration must never drop a column a registered script still reads (delete the script from the registry in the same PR instead) Type of Change New feature Testing Verified end-to-end against a scratch pgvector container: all 255 SQL migrations + script migration apply on a fresh DB; seeded 12k rows (reverse-inserted, crossing the chunk boundary) with NULL order_key, re-ran db:migrate — 0 NULLs left, key order matches position order exactly, already-keyed tables untouched, third run no-ops. lint:check, check:api-validation:strict, type-check (utils/db/sim), and both package test suites pass Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary Self-hosted deployments only ran drizzle SQL migrations — one-off TS backfill scripts never reached them. This adds a minimal run-once script-migration mechanism to the existing db:migrate...

X Description: Summary Self-hosted deployments only ran drizzle SQL migrations — one-off TS backfill scripts never reached them. This adds a minimal run-once script-migration mechanism to the existing db:migrate...

Opengraph URL: https://github.com/simstudioai/sim/pull/5497

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a360e1ba-f496-648a-a847-1d5c01c87dfa
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idEB30:18732E:B3B100:F6B302:6AFB52EC
html-safe-nonced176f2d49d31860397c1e6fc19f588a6a806de1c8f4bd7a0ac7534901ab09d6d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjMwOjE4NzMyRTpCM0IxMDA6RjZCMzAyOjZBRkI1MkVDIiwidmlzaXRvcl9pZCI6IjQxMjg1NjU4ODA5MDIzNDEzNTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4688a5f653019ecb93eb99a875144095d1054e0f64ff6c86adb4e523811f7794
hovercard-subject-tagpull_request:4010697172
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5497/files
twitter:imagehttps://avatars.githubusercontent.com/u/19564703?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/19564703?s=400&v=4
og:image:altSummary Self-hosted deployments only ran drizzle SQL migrations — one-off TS backfill scripts never reached them. This adds a minimal run-once script-migration mechanism to the existing db:migrate...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/5497/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F5497%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F5497%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/5497/files
Reloadhttps://github.com/simstudioai/sim/pull/5497/files
Reloadhttps://github.com/simstudioai/sim/pull/5497/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
TheodoreSpeakshttps://github.com/TheodoreSpeaks
staginghttps://github.com/simstudioai/sim/tree/staging
feat/self-host-migrationhttps://github.com/simstudioai/sim/tree/feat/self-host-migration
Conversation 14 https://github.com/simstudioai/sim/pull/5497
Commits 3 https://github.com/simstudioai/sim/pull/5497/commits
Checks 17 https://github.com/simstudioai/sim/pull/5497/checks
Files changed https://github.com/simstudioai/sim/pull/5497/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5497/files
feat(db): auto-apply tracked script data migrations in db:migrate https://github.com/simstudioai/sim/pull/5497/files#top
Show all changes 3 commits https://github.com/simstudioai/sim/pull/5497/files
3a828bd feat(db): auto-apply tracked script data migrations in db:migrate TheodoreSpeaks Jul 7, 2026 https://github.com/simstudioai/sim/pull/5497/commits/3a828bd49610cc9fa19be7aeb164891f324efcc5
a39cf8e fix(db): reset session lock_timeout before script migrations, guard j… TheodoreSpeaks Jul 8, 2026 https://github.com/simstudioai/sim/pull/5497/commits/a39cf8e93b65d785feb1914bb85cc886333dfef8
4983f86 improvement(db): re-verify advisory-lock session before script migrat… TheodoreSpeaks Jul 8, 2026 https://github.com/simstudioai/sim/pull/5497/commits/4983f868125a1501dc37e3dbbfadc9d8f2ecf701
Clear filters https://github.com/simstudioai/sim/pull/5497/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5497/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5497/files
order-key.ts https://github.com/simstudioai/sim/pull/5497/files#diff-3c79b7b93620e6a36152091377fe2473de2a59afa3dcb0a0317d71db98067bad
backfill-table-order-keys.ts https://github.com/simstudioai/sim/pull/5497/files#diff-0582a89d1d3876c84e93e729a19a891585e8a51c163e4ec5136c4de8005bff24
repair-table-order-key-collation.ts https://github.com/simstudioai/sim/pull/5497/files#diff-fa3e0a19d36fa434d84a425bc715993332c9e57cc5e416d15e7c58209e01f384
0001_backfill_table_order_keys.ts https://github.com/simstudioai/sim/pull/5497/files#diff-cbcb601558d0451a28fe1b0408c66abef06b857547a3ba2b7686c78f545b89ae
index.ts https://github.com/simstudioai/sim/pull/5497/files#diff-4c8058a0b924ce061c5ce010c1308148ea03720952dda10d03cee092b61adbd6
types.ts https://github.com/simstudioai/sim/pull/5497/files#diff-586653e13e7dffc1ec80d3b3d8132d3eaa6cfe4d0b3f459f83b5d9296f849e47
migrate.ts https://github.com/simstudioai/sim/pull/5497/files#diff-779c3d10c90f2f40f5bde1dbd478e3b67c3f73e6bd798c8e7a8f3eeca3141eeb
package.json https://github.com/simstudioai/sim/pull/5497/files#diff-21f8eb1d7a149d42ab0454ea905d44f624ff1d0aeb6d7a88d75b42962ca6b053
fractional-indexing.test.ts https://github.com/simstudioai/sim/pull/5497/files#diff-6c5cc7a4db3c76857a49bbf7112d4a9f130ed604a68e8ae43848f57f04a18962
fractional-indexing.ts https://github.com/simstudioai/sim/pull/5497/files#diff-199bd5d0f58d46f7505303d6fd63132ec06e8aeaed7ffc3a56c75a89cc675bf4
apps/sim/lib/table/order-key.tshttps://github.com/simstudioai/sim/pull/5497/files#diff-3c79b7b93620e6a36152091377fe2473de2a59afa3dcb0a0317d71db98067bad
View file https://github.com/simstudioai/sim/blob/4983f868125a1501dc37e3dbbfadc9d8f2ecf701/apps/sim/lib/table/order-key.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5497/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/5497/files#diff-3c79b7b93620e6a36152091377fe2473de2a59afa3dcb0a0317d71db98067bad
https://github.com/simstudioai/sim/pull/5497/files#diff-3c79b7b93620e6a36152091377fe2473de2a59afa3dcb0a0317d71db98067bad
apps/sim/scripts/backfill-table-order-keys.tshttps://github.com/simstudioai/sim/pull/5497/files#diff-0582a89d1d3876c84e93e729a19a891585e8a51c163e4ec5136c4de8005bff24
View file https://github.com/simstudioai/sim/blob/6d5ac583bc0b4279b116c7861adc46572d9f1533/apps/sim/scripts/backfill-table-order-keys.ts
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/simstudioai/sim/pull/5497/files
apps/sim/scripts/repair-table-order-key-collation.tshttps://github.com/simstudioai/sim/pull/5497/files#diff-fa3e0a19d36fa434d84a425bc715993332c9e57cc5e416d15e7c58209e01f384
View file https://github.com/simstudioai/sim/blob/4983f868125a1501dc37e3dbbfadc9d8f2ecf701/apps/sim/scripts/repair-table-order-key-collation.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5497/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/5497/files#diff-fa3e0a19d36fa434d84a425bc715993332c9e57cc5e416d15e7c58209e01f384
https://github.com/simstudioai/sim/pull/5497/files#diff-fa3e0a19d36fa434d84a425bc715993332c9e57cc5e416d15e7c58209e01f384
https://github.com/simstudioai/sim/pull/5497/files#diff-fa3e0a19d36fa434d84a425bc715993332c9e57cc5e416d15e7c58209e01f384
packages/db/script-migrations/0001_backfill_table_order_keys.tshttps://github.com/simstudioai/sim/pull/5497/files#diff-cbcb601558d0451a28fe1b0408c66abef06b857547a3ba2b7686c78f545b89ae
View file https://github.com/simstudioai/sim/blob/4983f868125a1501dc37e3dbbfadc9d8f2ecf701/packages/db/script-migrations/0001_backfill_table_order_keys.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5497/{{ revealButtonHref }}
packages/db/script-migrations/index.tshttps://github.com/simstudioai/sim/pull/5497/files#diff-4c8058a0b924ce061c5ce010c1308148ea03720952dda10d03cee092b61adbd6
View file https://github.com/simstudioai/sim/blob/4983f868125a1501dc37e3dbbfadc9d8f2ecf701/packages/db/script-migrations/index.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5497/{{ revealButtonHref }}
packages/db/script-migrations/types.tshttps://github.com/simstudioai/sim/pull/5497/files#diff-586653e13e7dffc1ec80d3b3d8132d3eaa6cfe4d0b3f459f83b5d9296f849e47
View file https://github.com/simstudioai/sim/blob/4983f868125a1501dc37e3dbbfadc9d8f2ecf701/packages/db/script-migrations/types.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5497/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/5497/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5497/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.