sea-orm-cli generate
should work without having to give a database name
#2166
reivilibre
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my environment I have set
DATABASE_URL=postgres:
. In this setting, SQLx and the sea-orm-cli migrate tool take this to mean 'use the default database according to environment variables, falling back to some other default (usually localhost, with the user's name and the database name that matches the user)'.I'm not sure how many of these sqlx's driver supports, but the env vars are documented at https://www.postgresql.org/docs/current/libpq-envars.html. SQLx supports at least the basic ones!
This is pretty useful in a development environment because
psql
and any other postgres-based tools all work with this convention.But currently if you try to use this, you'll find that it works for applying database migrations, but not for generating entities:
I don't see anywhere the database name is actually emitted in the output, so I suggest that it is not really necessary and it would be fine to default to the default database.
Beta Was this translation helpful? Give feedback.
All reactions