Commit 1199a38c authored by maeda's avatar maeda

Add redmine_plugin_migration generator (#31498).

Patch by Kouhei Sutou.


git-svn-id: https://svn.redmine.org/redmine/trunk@18223 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 337a8605
Description:
Generates a plugin migration.
Examples:
bin/rails generate redmine_plugin_migration my_plugin add_new_column_to_table
class RedminePluginMigrationGenerator < Rails::Generators::NamedBase
include Rails::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
argument :migration, :type => :string
class << self
def next_migration_number(dirname)
next_migration_number = current_migration_number(dirname) + 1
ActiveRecord::Migration.next_migration_number(next_migration_number)
end
end
def create_migration_file
plugin_name = file_name.underscore
plugin_path = File.join(Redmine::Plugin.directory, plugin_name)
migration_template "migration.rb",
"#{plugin_path}/db/migrate/#{@migration}.rb"
end
end
class <%= @migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
def change
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment