class ScaffoldPlus::Generators::MigrationGenerator
Public Instance Methods
add_migration()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 65 def add_migration return unless @the_lines.any? migration_template "change_migration.rb", "db/migrate/#{migration_name}.rb" end
prepare_change_column()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 42 def prepare_change_column return unless options.change.present? options.change.each do |column| column, new_type = column.split(':') @the_lines << " change_column :#{table_name}, :#{column}, :#{new_type}" end end
prepare_change_table()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 25 def prepare_change_table return unless options.remove.present? or options.rename.present? @the_lines << " change_table :#{table_name} do |t|" if options.remove.present? options.remove.each do |column| @the_lines << " t.remove :#{column}" end end if options.rename.present? options.rename.each do |column| old_name, new_name = column.split(':') @the_lines << " t.rename :#{old_name}, :#{new_name}" end end @the_lines << " end" end
prepare_not_null()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 50 def prepare_not_null return unless options.not_null.present? options.not_null.each do |column| @the_lines << " change_column_null :#{table_name}, :#{column}, false" end end
prepare_set_default()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 57 def prepare_set_default return unless options.set_default.present? options.set_default.each do |column| column, preset = column.split(':') @the_lines << " change_column_default :#{table_name}, :#{column}, #{preset}" end end
prepare_the_lines()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 21 def prepare_the_lines @the_lines = [] end
Protected Instance Methods
migration_name()
click to toggle source
# File lib/generators/scaffold_plus/migration/migration_generator.rb, line 72 def migration_name "change_#{table_name}" end