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

Ensure /db is included in git repo of plugin #11692

Closed

Conversation

schneems
Copy link
Member

@schneems schneems commented Aug 1, 2013

While generating a plugin that does not use the database, an empty db/ folder will be created if the seeds.rb file is removed from the folder. Git does not recognise empty directories, so it will not add the /db folder to source. See the output here: https://github.com/schneems/default-rails-plugin

Then any tests run on a remote machine will fail:

http://stackoverflow.com/questions/17955787/sqlite3cantopenexception-unable-to-open-database-file-while-testing-ruby-gem

Either we can include the seeds.rb file in the generate output of rails plugin new or we could add a blank .gitignore file to ensure that the /db folder is included in the git repo.

I don't see a good reason for removing the file (it only has comments anyway) and all tests pass even when we keep the file in the repo.

You won't run into this problem is you run a migration in your plugin's tests since that creates a db/migrate folder.

All tests pass Railties.

@josevalim
Copy link
Contributor

@schneems Good catch!

Maybe we should change the sqlite3 adapter to ensure the directory for the file exists when it receives the configuration? Even if we put a .gitkeep or .gitignore, that doesn't change people can still remove the directories or clean up their .gitnore files, bringing the weird errors back.

@schneems
Copy link
Member Author

schneems commented Aug 1, 2013

I'll look into pushing the fix to sqlite3

While generating a plugin that does not use the database, and empty `db/` folder will be created if the `seeds.rb` file is removed from the folder. Git does not recognise empty directories, so it will not add the `/db` folder to source. See the output here: https://github.com/schneems/default-rails-plugin

Then any tests run on a remote machine will fail:

http://stackoverflow.com/questions/17955787/sqlite3cantopenexception-unable-to-open-database-file-while-testing-ruby-gem

Either we can include the `seeds.rb` file in the generate output of `rails plugin new` or we could add a blank `.gitignore` file to ensure that the `/db` folder is included in the git repo. 

I don't see a good reason for removing the file (it only has comments anyway) and all tests pass even when we keep the file in the repo. 

You won't run into this problem is you run a migration in your plugin's tests since that creates a `db/migrate` folder.

All tests pass Railties.
schneems added a commit to schneems/rails that referenced this pull request Aug 5, 2013
If the `db/` directory is not present on a remote machine it will blow up in unexpected ways with error messages that do not indicate there is a missing directory:

```
SQLite3::CantOpenException: unable to open database file
```

This PR checks to see if a directory exists for the sqlite3 file and if not creates it for you.

This PR is an alternative to rails#11692 as suggested by @josevalim
@schneems
Copy link
Member Author

schneems commented Aug 5, 2013

closing in favor of #11763

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

Successfully merging this pull request may close these issues.

None yet

2 participants