Method: NandoMigrator#initialize
- Defined in:
- lib/nando/migrator.rb
#initialize ⇒ NandoMigrator
Returns a new instance of NandoMigrator.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nando/migrator.rb', line 16 def initialize @migration_table = ENV['MIGRATION_TABLE_NAME'] || 'schema_migrations' @migration_field = ENV['MIGRATION_TABLE_FIELD'] || 'version' @migration_dir = ENV['MIGRATION_DIR'] || 'db/migrate' # accepts urls in the same format as dbmate => protocol://username:password@host:port/database_name match = /([a-zA-Z]+)\:\/\/(\w+)\:(\w+)\@([\w\.]+)\:(\d+)\/(\w+)/.match(ENV['DATABASE_URL']) raise Nando::GenericError.new('No .env file was found, or no valid DATABASE_URL variable was found in it') if match.nil? @db_protocol = match[1] @db_username = match[2] @db_password = match[3] @db_host = match[4] @db_port = match[5] @db_name = match[6] @working_dir = ENV['WORKING_DIR'] || '.' @schema_variable = ENV['SCHEMA_VARIABLE'] || '#{schema_name}' end |