mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:03:22 +08:00
fe4e2a17cb
* FEATURE: Create rake for db migration in plugins before the dev-xp was clunky, we had to create a migration file in core and move it to the plugin. Now we automated this process, we still create the migration file in core but the rake task will move it to the plugin. the usage is: ``` rake plugin:generate_migration[plugin_name,migration_name,migration_args] rake plugin:generate_migration[discourse-automation,add_group_id_to_automation_rule,"group_id:integer"] ``` * DEV: change rake to be a generator for plugin migrations * DEV: trying to add extra class option to migration generator * DEV: revert to have only `plugin_migration_generator` * DEV: remove rake task for plugin migration creation * DEV: remove migration_generator.rb * DEV: remove if because options with `plugin_name` will always be true
20 lines
604 B
Ruby
20 lines
604 B
Ruby
# 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
|