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

Inconsistent behavior on db:prepare task #36383

Closed
morgoth opened this issue Jun 3, 2019 · 5 comments
Closed

Inconsistent behavior on db:prepare task #36383

morgoth opened this issue Jun 3, 2019 · 5 comments
Labels

Comments

@morgoth
Copy link
Member

morgoth commented Jun 3, 2019

The db:prepare task works different for PG adapter than SQLite3 one.

db:prepare task introduced in #35768 in case of missing database is supposed to create it, load schema and seeds.

This is working fine on PostgreSQL database, however when using SQLite3 database, seeds are not loaded.
This is happening, because db:migrate does not raise ActiveRecord::NoDatabaseError which db:prepare relies on

rescue ActiveRecord::NoDatabaseError

Not sure what the proper fix would be. Raising ActiveRecord::NoDatabaseError on SQLite3 would be backward incompatible change, so maybe we should add some internal method for existence check of db, that could be used instead of relying on raising error?
/cc @robertomiranda

@robertomiranda
Copy link
Contributor

@morgoth thanks for raising up this issue, I've been thinking about this and probably a db_exists? method on the different adapters will work better.

@itsWill
Copy link
Contributor

itsWill commented Jun 3, 2019

The source of this issue is the same as the one for this one: #32914

The fact that Sqlite will silently create a new database instead of throwing an error upon connecting to a non existing database.

For what its worth, on my approach to solve the above issue I used the db_exists? method @robertomiranda mentioned above: #36025 and I think it worked quite well.

Note: my PR doesn't solve this issue, but having the db_exists? method across adapters is a good step to solving both.

itsWill pushed a commit to itsWill/rails that referenced this issue Jun 17, 2019
When SQLite connects it will silently create a database if the database does not
exist. This behaviour causes different issues because of inconsistent behaviour
between adapters: rails#36383, rails#32914. This commit adds a `database_exists?` method
as a way to check the database without creating it. This is a stepping stone to
fully resolving the above issues.
robertomiranda pushed a commit to robertomiranda/rails that referenced this issue Jul 8, 2019
When SQLite connects it will silently create a database if the database does not
exist. This behaviour causes different issues because of inconsistent behaviour
between adapters: rails#36383, rails#32914. This commit adds a `database_exists?` method
as a way to check the database without creating it. This is a stepping stone to
fully resolving the above issues.
@rails-bot
Copy link

rails-bot bot commented Sep 1, 2019

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 6-0-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Sep 1, 2019
@morgoth
Copy link
Member Author

morgoth commented Sep 1, 2019

it's still an issue being worked on #36620 but got a little stale there ;)

@rails-bot rails-bot bot removed the stale label Sep 1, 2019
@rails-bot
Copy link

rails-bot bot commented Nov 30, 2019

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 6-0-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

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

Successfully merging a pull request may close this issue.

3 participants