Skip to content

Instantly share code, notes, and snippets.

@clupprich
Created January 29, 2026 20:39
Show Gist options
  • Select an option

  • Save clupprich/a2c94896272fa42ad9a4ef6b3333faab to your computer and use it in GitHub Desktop.

Select an option

Save clupprich/a2c94896272fa42ad9a4ef6b3333faab to your computer and use it in GitHub Desktop.
Pre-Deploy Command for Multi-Service Rails apps on Railway
#!/usr/bin/env ruby
require_relative "../config/environment"
# This release script safely runs database migrations while gracefully handling concurrent migrations
# when multiple services deploy simultaneously.
# Save it to `bin/release`, and configure it as the pre-deploy command in your Railway services.
#
# Remember to set the executable flag (`chmod +x bin/release`).
begin
ActiveRecord::Tasks::DatabaseTasks.migrate_all
rescue ActiveRecord::ConcurrentMigrationError
print '.'
sleep 1
retry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment