简体   繁体   中英

Should I put the sqlite3 databases (for an RoR project) in the VCS?

What is the common way of dealing with the development.sqlite3 files with VCS (in particular, git)?

If I commit this file to the VCS, will it be merged with another developer's copy?

Or should each developer run the db:migrate task each time a new migration file is created?

The most common is to ignore this file. Moreover, we usually try to allow each developer use any database that is supported by Rails. Granted that this is not always possible, especially if there is a need to bypass ActiveRecord in some occasions. Nevertheless, for most simple applications this can be accomplished.

What we do is add these lines to .gitignore among other things we ignore:

db/*.sqlite3
config/database.yml

Then we include a database.yml.example file in config, where we keep the recommended way to configure the database for the application. Developers can copy that file as their database.yml, or select a different database.

sqlite is file-based database, so, if you commit this file to VCS each developer will see same database, as you commit (not merged with db-file of other developers but replace their db) and they need no run any db:migrate task.

But this file change to often (on each data saving), so it is bed idea to put it to VCS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM