mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FEATURE: Create rake for db migration in plugins (#29163)
* 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
This commit is contained in:
parent
f227f66b11
commit
fe4e2a17cb
19
lib/generators/rails/plugin_migration_generator.rb
Normal file
19
lib/generators/rails/plugin_migration_generator.rb
Normal file
|
@ -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
|
Loading…
Reference in New Issue
Block a user