Created
October 17, 2024 21:07
-
-
Save Grubba27/1f764790df4ed7a039c47061890ab063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "rails/generators/active_record/migration/migration_generator" | |
class Rails::MigrationGenerator < ActiveRecord::Generators::MigrationGenerator | |
class_option :plugin_name, | |
type: :string, | |
banner: "plugin_name", | |
desc: "The plugin name to generate the migration into." | |
source_root "#{Gem.loaded_specs["activerecord"].full_gem_path}/lib/rails/generators/active_record/migration/templates" | |
private | |
def db_migrate_path | |
if options["plugin_name"] | |
"plugins/#{options["plugin_name"]}/db/migrate" | |
else | |
"db/migrate" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
if options["plugin_name"] | |
"plugins/#{options["plugin_name"]}/db/migrate" | |
else | |
"db/migrate" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment