是否可以從現有應用程序中完全刪除數據庫和所有遷移記錄等,以便我可以從頭重新設計數據庫?在Rails中銷燬/刪除數據庫
13
A
回答
39
通過發行rake -T
您有以下數據庫任務:
rake db:create # Create the database from DATABASE_URL or config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)
rake db:drop # Drops the database using DATABASE_URL or the current Rails.env (use db:drop:all to drop all databases)
rake db:fixtures:load # Load fixtures into the current environment's database
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false)
rake db:migrate:status # Display status of migrations
rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB supported by AR
rake db:schema:load # Load a schema.rb file into the database
rake db:seed # Load the seed data from db/seeds.rb
rake db:setup # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)
rake db:structure:dump # Dump the database structure to db/structure.sql
rake db:version # Retrieves the current schema version number
因此,要發佈bundle exec rake db:drop:all
,並且如果要刪除所有遷移,並且假設你只想刪除遷移,刪除它們並寫入新的遷移。
如果您也想更換模型,請使用rails d model
。
4
這將擺脫分貝:
rake db:drop
併爲每個遷移,你必須:
rails d migration migration_name
0
是的,它可能會刪除數據庫和遷移。
rake db:drop
rake db:rollback
rails d migration 'migration name'
rake db:create
rake db:migrate
rake db:seed
rake db:test:prepare
相關問題
- 1. Rails,銷燬與刪除?
- 2. 如何從數據庫中刪除/銷燬rails應用程序中的用戶?
- 3. 部分刪除/銷燬$ _SESSION數據? PHP
- 4. 從QGraphicsScene中刪除/銷燬/刪除QGraphicsItem
- 5. 在backbonejs中銷燬模型後從數據表中刪除行
- 6. Rails devise在註銷後從數據庫中刪除用戶
- 7. Kendo UI Tooltip刪除/銷燬?
- 8. 在Rails中刪除連接表記錄銷燬
- 9. Rails應用銷燬/刪除方法不工作在Heroku,但
- 10. Rails的數據庫ID號不被更新與銷燬電話
- 11. 無法使用rake銷燬數據庫
- 12. Rails控制檯凍結手動刪除/銷燬操作
- 13. 刪除輪胎搜索索引銷燬
- 14. 刪除/銷燬完成期貨asyncio Python
- 15. 刪除銷燬所有情況後
- 16. Backbone.js發送變量與銷燬/刪除
- 17. Laravel 5刪除與銷燬方法
- 18. 刪除/銷燬和編輯路由
- 19. jQuery刪除是否也銷燬resizables/draggables?
- 20. 在Rails中銷燬基於HTML類名的數據
- 21. 在rails和Mongoid中銷燬方法
- 22. 無法在Rails中銷燬對象
- 23. 如何在使用Rails 4刪除和銷燬Mongoid中的嵌入式文檔
- 24. 在rails中,如何銷燬'連接表項'而不刪除真實記錄?
- 25. 銷燬數據表重用
- 26. 爲什麼刪除和銷燬方法不刪除模型 - laravel
- 27. rails polymorphic_url銷燬行動
- 28. 銷燬會話,Rails設計
- 29. Rails:無法銷燬關聯
- 30. Rails 3 public_activity,銷燬記錄
非常感謝。還有什麼我應該清理? (我剛開始學習Rails)。 – fearofawhackplanet