Open landovsky opened 6 years ago
Why are you using a different name in DATABASE_URL_TEST=postgres://postgres:hele@postgres/techloop_automator_testik
than in your config? Did you try changing in yaml file
test:
database: techloop_automator_testik
But also maybe try setting the config before loading the tasks? So move
StandaloneMigrations::Tasks.load_tasks
to after your config do/end block.
Same issue here. Here is a snippet that worked for me:
require 'tasks/standalone_migrations'
require 'yaml'
StandaloneMigrations::Configurator.environments_config do |env|
f = YAML.load_file('config.yml')
db = URI.parse(f['postgres'])
env.on "default" do |c|
c["adapter"] = db.scheme == 'postgres' ? 'postgresql' : db.scheme
c["host"] = db.host
c["port"] = db.port
c["username"] = db.user
c["password"] = db.password
c["database"] = db.path[1..-1]
c["encoding"] = 'utf8'
return c
end
end
Having this
.env vars
DATABASE_URL_TEST=postgres://postgres:hele@postgres/techloop_automator_testik
db/config.yml
Rakefile
When I run
rake db:create RAILS_ENV=test
, I get:>> it creates
techloop_automator_test
as opposed totechloop_automator_testik