Clean up the post deployment migration generator (#24233)
This commit is contained in:
parent
3c7053a2db
commit
a2a66300d9
6 changed files with 62 additions and 25 deletions
10
lib/generators/post_deployment_migration/USAGE
Normal file
10
lib/generators/post_deployment_migration/USAGE
Normal file
|
@ -0,0 +1,10 @@
|
|||
Description:
|
||||
Generate a Rails migration in the db/post_migrate/ dir.
|
||||
|
||||
Interacts with the post_deployment_migrations initializer.
|
||||
|
||||
Example:
|
||||
bin/rails generate post_deployment_migration IsolateChanges
|
||||
|
||||
Creates a migration in db/post_migrate/<timestamp>_isolate_changes.rb
|
||||
which will have `disable_ddl_transaction!` and a `change` method included.
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails/generators/active_record'
|
||||
|
||||
class PostDeploymentMigrationGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path('templates', __dir__)
|
||||
|
||||
include Rails::Generators::Migration
|
||||
|
||||
def create_post_deployment_migration
|
||||
migration_template 'migration.erb', "db/post_migrate/#{file_name}.rb"
|
||||
end
|
||||
|
||||
def self.next_migration_number(path)
|
||||
ActiveRecord::Generators::Base.next_migration_number(path)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue