Class: DataMigration::Generators::InstallGenerator
- Inherits:
-
ActiveRecord::Generators::MigrationGenerator
- Object
- ActiveRecord::Generators::MigrationGenerator
- DataMigration::Generators::InstallGenerator
- Defined in:
- lib/generators/data_migration/install_generator.rb
Instance Attribute Summary collapse
-
#table_columns ⇒ Object
readonly
Returns the value of attribute table_columns.
-
#table_exists ⇒ Object
readonly
Returns the value of attribute table_exists.
Instance Method Summary collapse
Instance Attribute Details
#table_columns ⇒ Object (readonly)
Returns the value of attribute table_columns.
10 11 12 |
# File 'lib/generators/data_migration/install_generator.rb', line 10 def table_columns @table_columns end |
#table_exists ⇒ Object (readonly)
Returns the value of attribute table_exists.
10 11 12 |
# File 'lib/generators/data_migration/install_generator.rb', line 10 def table_exists @table_exists end |
Instance Method Details
#create_migration_file ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/data_migration/install_generator.rb', line 11 def create_migration_file if ActiveRecord::Base.connection.table_exists?(name) puts "\e[31mWARNING: Table `#{name}` already exists\e[0m" @table_exists = true @table_columns = ActiveRecord::Base.connection.columns(name) end set_local_assigns! validate_file_name! migration_template "install_#{name}.rb", "#{DataMigration.config.schema_migrations_path}/install_#{file_name}.rb" end |
#migration_parent ⇒ Object
23 24 25 |
# File 'lib/generators/data_migration/install_generator.rb', line 23 def migration_parent "ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]" end |