Created
January 29, 2026 20:39
-
-
Save clupprich/a2c94896272fa42ad9a4ef6b3333faab to your computer and use it in GitHub Desktop.
Pre-Deploy Command for Multi-Service Rails apps on Railway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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