简体   繁体   中英

How Do I Delete A blog That I Created in Ruby on Rails?

If I understand correctly, if I run:

rm deveopment.sqlite3 schema.rb

It will delete the database file and the schema files and then I re-create the rake db migrate file but would I have to delete the whole blog and start from scratch or will these commands let me keep the blog structure files loaded and just recreate the database? Not sure which option is the best.

The .sqlite3 file is the actual DataBase in a SQLite installation.

The schema.rb file is a point-in-time representation of the database structure. This means that every time you alter the structure of a database (add a table, remove a table, add a field to a table, add or remove an index etc.) this file will be changed by rake to reflect the current structure of the database. Note that no data is in that file.

If you erase the database (and the schema.rb file for that matter) a

rake db:setup

would actually execute the following three rake commands:

rake db:create

rake db:migrate

rake db:seed

So if you have your migrations intact and your seed file intact, erasing the schema.rb and the *.sqlite3 files will erase that database (and all its data) and the reflect of the current database schema, but not the migration files or the seed data. You will be able to regenerate the database (with only the seed data, no other data) with a

rake db:setup

Take note that the development.sqlite3 is one of the 3 different databases that might exist, others being production and test.

But, if you are willing to reset the base, a better approach would be a

rake db:reset

Please read Migrations Guide if you need more information about it.

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