mirror of
https://github.com/discourse/discourse.git
synced 2024-12-25 18:36:29 +08:00
40fa96777d
This moves us away from the delayed drops pattern which was problematic on two counts. First, it uses a hardcoded "delay for" duration which may be too short for certain deployment strategies. Second, delayed drop doesn't ensure that it only runs after the latest application code has been deployed. If the migration runs and the application code fails to deploy, running the migration after "delay for" has been met will cause the application to blow up. The new strategy allows post deployment migrations to be skipped if the env `SKIP_POST_DEPLOYMENT_MIGRATIONS` is provided. ``` SKIP_POST_DEPLOYMENT_MIGRATIONS=1 rake db:migrate -> deploy app servers SKIP_POST_DEPLOYMENT_MIGRATIONS=0 rake db:migrate ``` To aid with the generation of a post deployment migration, a generator has been added. Simply run `rails generate post_migration`.
14 lines
387 B
Ruby
14 lines
387 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails/generators/active_record/migration/migration_generator"
|
|
|
|
class Rails::PostMigrationGenerator < ActiveRecord::Generators::MigrationGenerator
|
|
source_root "#{Gem.loaded_specs["activerecord"].full_gem_path}/lib/rails/generators/active_record/migration/templates"
|
|
|
|
private
|
|
|
|
def db_migrate_path
|
|
Discourse::DB_POST_MIGRATE_PATH
|
|
end
|
|
end
|