Sha256: 0ed73fcc5a37bd027d41e9f4ea6ab7247a4c33183f0a3d69ef2a1003931fa842
Contents?: true
Size: 1.12 KB
Versions: 8
Compression:
Stored size: 1.12 KB
Contents
require 'rails/generators/active_record' module ActiveRecord module Generators class UpgradeGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path('../templates', __FILE__) desc 'Makes Active Record migrations to handle upgrades between versions' def self.next_migration_number(path) ActiveRecord::Generators::Base.next_migration_number(path) end def copy_migrations_and_model if merit_actions_exists? && target_data_column_doesnt_exist? migration_template 'add_target_data_to_merit_actions.rb', 'db/migrate/add_target_data_to_merit_actions.rb' end end private def target_data_column_doesnt_exist? !ActiveRecord::Base.connection.column_exists?(:merit_actions, :target_data) end # Might be foolishly running this before install. Ugly error if we don't # check. def merit_actions_exists? ActiveRecord::Base.connection.table_exists? :merit_actions end end end end
Version data entries
8 entries across 8 versions & 1 rubygems