是否可以从现有应用程序中完全删除数据库和所有迁移记录等,以便我可以从头重新设计数据库?在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