Skip to content

Support direct database URL for startup migrations#691

Draft
maxpetrusenkoagent wants to merge 1 commit into
docusealco:masterfrom
maxpetrusenkoagent:hermes/oss-pr-2026-06-15-docuseal-469
Draft

Support direct database URL for startup migrations#691
maxpetrusenkoagent wants to merge 1 commit into
docusealco:masterfrom
maxpetrusenkoagent:hermes/oss-pr-2026-06-15-docuseal-469

Conversation

@maxpetrusenkoagent

Copy link
Copy Markdown

Summary

  • add MIGRATION_DATABASE_URL support for production startup migrations
  • keep DATABASE_URL for normal application traffic, then temporarily switch to the direct migration URL only while DatabaseTasks.migrate runs
  • restore the application database connection after migrations, including failure cases
  • document the direct-connection setup for pooled PostgreSQL providers such as Neon

Fixes #469

Why

Neon documents pooled connections as appropriate for web application traffic, but schema migrations should use direct connections because migration tools may not support transaction pooling. DocuSeal currently runs production startup migrations through the same DATABASE_URL used by the app, which makes Neon users likely to point Rails migrations at the pooled -pooler URL.

Verification

  • ruby -Ilib -c lib/migration_database_url.rb
  • ruby -c config/initializers/migrate.rb
  • ruby -c spec/lib/migration_database_url_spec.rb
  • ruby /tmp/migration_database_url_harness.rb
  • git diff --cached --check
  • static scan of added lines for common secret/injection patterns
  • independent Codex review: CLEAN
  • independent Hermes subagent review: CLEAN

Local test caveat

Full bundle exec rspec spec/lib/migration_database_url_spec.rb and bundle exec rubocop ... could not run on this Mac because the local system Ruby is 2.6.10, while this repo requires Ruby 4.0.5 and Bundler 4.0.3. The new spec is included so CI can run it with the repo's configured Ruby version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with change_column_null on Neon PostgreSQL during Docuseal Migrations

1 participant