Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use database cleaner with sub nested connection. #418

Open
sarsena opened this issue Jan 6, 2016 · 1 comment
Open

Use database cleaner with sub nested connection. #418

sarsena opened this issue Jan 6, 2016 · 1 comment

Comments

@sarsena
Copy link

sarsena commented Jan 6, 2016

Below is my database.yml and I want to use DatabaseCleaner on the secondbase test. How would I specify the connection key when I call DatabaseCleaner[:active_record, { :connection => KEY }? Is there a way I can pass in a :connection_hash?

default: &default
  adapter: mysql2
  encoding: utf8
  reconnect: true
  username: <%= ENV['MYSQL_DB_USERNAME'] %>
  password: <%= ENV['MYSQL_DB_PASSWORD'] %>
  host: <%= ENV['MYSQL_DB_HOST'] %>
  database: <%= ENV['MYSQL_DB_NAME'] %>
  structure_dump: db_stored_code

development:
  <<: *default

test:
  <<: *default
  database: <%= ENV['MYSQL_TEST_DB_NAME'] %>

staging:
  <<: *default

production:
  <<: *default

secondbase:
  second_default: &second_default
    adapter: oracle_enhanced
    username: <%= ENV['ORACLE_DB_USERNAME'] %>
    password: <%= ENV['ORACLE_DB_PASSWORD'] %>
    reconnect: true
    database: <%= ENV['ORACLE_DB_NAME'] %>
    structure_dump: db_stored_code

  development:
    <<: *second_default

  test:
    <<: *second_default
    username: <%= ENV['ORACLE_TEST_DB_USERNAME'] %>
    password: <%= ENV['ORACLE_TEST_DB_PASSWORD'] %>

  staging:
    <<: *second_default

  production:
    <<: *second_default
@agrberg
Copy link

agrberg commented Mar 10, 2017

@sarsena I don't think it's the ideal solution but I was able to take care of my secondbase database cleaning with

DatabaseCleaner.clean_with(:truncation) # clean main DB
SecondBase.on_base { DatabaseCleaner.clean_with(:truncation) } # clean SecondBase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants