Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Add TEST_DATABASE_URL to the default .env #123

Merged
merged 3 commits into from
Jan 13, 2021

Conversation

jvanbaarsen
Copy link
Contributor

Currently it is a bit implicit that you can use the TEST_DATABASE_URL
env variable. I was able to figure this out by looking through the
source code, and since someone posted this on the issue tracker it means
more people find it a bit implicit.

Fixes: redwoodjs/redwood#1620

Currently it is a bit implicit that you can use the `TEST_DATABASE_URL`
env variable. I was able to figure this out by looking through the
source code, and since someone posted this on the issue tracker it means
more people find it a bit implicit.

Fixes: redwoodjs/redwood#1620
@dthyresson
Copy link

Should TEST_DATABASE_URL be included in the .example and .defaults as well?

Since

# schema.prisma defaults
DATABASE_URL=file:./dev.db

is in defaults? Would TEST_DATABASE_URL be set to the same?

Or a different database?

Perhaps a comment describes its purpose?

@jvanbaarsen
Copy link
Contributor Author

@dthyresson I was in doubt about this. The reason for me not to include it was that the DATABASE_URL in .env is pretty much specific for Postgresql. This is also the only provider where you need to set the TEST_DATABASE_URL. For SQLite this works out of the box (Because it will just create a .db file in the temp directory).

What I want to achieve with this is mostly awareness that this option is available for you to set, since this caused me a bunch of confusion.

@dthyresson
Copy link

I was in doubt about this.

Thanks @jvanbaarsen -- perhaps @thedavidprice @cannikin or @peterp can determine if it should or not. Agree that the goals is not to be confused if you need to test against a postgres database

@cannikin
Copy link
Member

My first thought is to add to .env.defaults with the current default path of .redwood/test.db but commented out with a note about usage:

# These environment variables will be used by default if you do not create any
# yourself in .env. This file should be safe to check into your version control
# system. Any custom values should go in .env and .env should *not* be checked
# into version control.

# schema.prisma defaults
DATABASE_URL=file:./dev.db

# location of the test database for api service scenarios (defaults to ./.redwood/test.db it not set)
# TEST_DATABASE_URL=file:./.redwood/test.db

# disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true

@thedavidprice
Copy link
Contributor

I +1 Rob's suggestion above.

Also, we most definitely need to finish the Test Documentation! I've added a note about this on that PR as well.

Copy link
Contributor

@thedavidprice thedavidprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding to .env, add to .env.defaults with the current default path of .redwood/test.db but commented out with a note about usage:

# These environment variables will be used by default if you do not create any
# yourself in .env. This file should be safe to check into your version control
# system. Any custom values should go in .env and .env should *not* be checked
# into version control.

# schema.prisma defaults
DATABASE_URL=file:./dev.db

# location of the test database for api service scenarios (defaults to ./.redwood/test.db it not set)
# TEST_DATABASE_URL=file:./.redwood/test.db

# disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true

@cannikin
Copy link
Member

Yes, this should go in .env.defaults please!

@jvanbaarsen
Copy link
Contributor Author

Allright! I'll update this PR 👍

.env Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include TEST_DATABASE_URL in docs and .env.example
4 participants