module Lanes::Command::MigrationSupport
Public Instance Methods
create_migration()
click to toggle source
# File lib/lanes/command/migration_support.rb, line 6 def create_migration migration = existing_migration || migration_timestamp + "_create_#{table_name}.rb" self.fields = fields.map{ |field| ModelAttribute.parse(field) } template "db/create_table_migration.rb", "db/migrate/#{migration}" end
Private Instance Methods
existing_migration()
click to toggle source
# File lib/lanes/command/migration_support.rb, line 15 def existing_migration migrations = Pathname.glob("#{destination_root}/db/migrate/[0-9]*_create_#{table_name}.rb") migrations.any? ? migrations.first.basename.to_s : nil end
fields_with_index()
click to toggle source
# File lib/lanes/command/migration_support.rb, line 24 def fields_with_index fields.select { |a| !a.reference? && a.has_index? } end
migration_timestamp()
click to toggle source
# File lib/lanes/command/migration_support.rb, line 20 def migration_timestamp ENV['MIGRATION_TIMESTAMP'] || Time.now.utc.strftime("%Y%m%d%H%M%S") end