discourse/lib/generators/rails/plugin_post_migration_generator.rb
Sam d9c0c2da53
DEV: add plugin post-migration generator and migration skill (#39125)
Add a dedicated Rails generator for plugin post-deployment migrations
and document the migration skill so plugin authors can place destructive
database changes in the correct directory.
2026-04-08 09:34:55 +10:00

19 lines
637 B
Ruby
Vendored

# frozen_string_literal: true
require "rails/generators/active_record/migration/migration_generator"
class Rails::PluginPostMigrationGenerator < ActiveRecord::Generators::MigrationGenerator
class_option :plugin_name,
type: :string,
banner: "plugin_name",
desc: "The plugin name to generate the post 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"]}/#{Discourse::DB_POST_MIGRATE_PATH}"
end
end