-
Notifications
You must be signed in to change notification settings - Fork 205
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
Unable to create a test database when DATABASE_URL is present #1190
Comments
IMHO this is correct behaviour as environment variables should always take precedence over static configuration. Setting the env variable AMBER_ENV=test will use the test database URL in the amber test environment config unless a DATABASE_URL environment variable specifies another database URL. I think this is the best option in that you can setup env variables to override static config. This is not a bug with Amber - this is mis-configuration of the environment in the docker-compose.yml file. |
I can see that and would tend to agree I think. |
@damianham This is a bug since amber generated the docker-compose.yml file and its pointing to the development database instead of the test one when running specs. There has been several debates if we should support the DATABASE_URL environment variable. I personally fall on the side of less magic, but I will leave that for others to argue. |
what we should probably do is have an extra test service in the docker-compose file that sets the AMBER_ENV variable to test and the DATABASE_URL variable to the test db then in
to run tests and it would be nice if it kept running and retested any changed files. |
I would recommend for Amber to support different environment variables for each piece of database configuration, e.g.:
And internally generating the connection URL, if required. This way, when running in Docker Compose, we only need the host to be customised, and Amber's defaults for the others can be used, e.g. having just: environment:
DB_HOST: db Leaving To avoid confusion around precedence of these environment variables vs the existing |
Description
When trying to create a
_test
database using a docker-compose service based project that is supplying a DATABASE_URL environment variable to the service, it does not create a test database, and shows anxxxxxxx_development database already exists
message.Steps to Reproduce
_development
DATABASE_URL to the mainapp
service, like:docker-compose run app bash
AMBER_ENV=test amber db create
Expected behavior: [What you expect to happen]
A
xxxxxxxx_test
database to be created.Actual behavior: [What actually happens]
A message appears with:
xxxxxxxx_development database already exists
and no test database is created.Reproduces how often: [What percentage of the time does it reproduce?]
Every time so far for my one project, have not tried this after generating a second project though.
Versions
On MacOS 10.14.6, Running Docker Desktop 2.2.0.4 with Docker Engine 19.03.8 and Compose 1.25.4
The text was updated successfully, but these errors were encountered: