diff --git a/lib/generators/rails/plugin_migration_generator.rb b/lib/generators/rails/plugin_migration_generator.rb new file mode 100644 index 00000000000..dd3afe509e5 --- /dev/null +++ b/lib/generators/rails/plugin_migration_generator.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "rails/generators/active_record/migration/migration_generator" + +class Rails::PluginMigrationGenerator < ActiveRecord::Generators::MigrationGenerator + class_option :plugin_name, + type: :string, + banner: "plugin_name", + desc: "The plugin name to generate the migration into.", + required: true + + source_root "#{Gem.loaded_specs["activerecord"].full_gem_path}/lib/rails/generators/active_record/migration/templates" + + private + + def db_migrate_path + "plugins/#{options["plugin_name"]}/db/migrate" + end +end