是否可以从现有应用程序中完全删除数据库和所有迁移记录等,以便我可以从头开始重新设计数据库?

推荐答案

通过发布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,如果您想删除所有迁移,并且假设您只想删除迁移,请删除它们并编写新的migrations.

如果您也想更改型号,请使用rails d model.

Database相关问答推荐

任何必要的可空外键示例?

如何让 Google Drive Electron 表格像 MySQL 数据库一样工作吗?

创建一个spell check,判断具有合理运行时间的数据库

如何使用存储在数据库表中的属性配置 Spring bean

使用自动递增主键将 csv 导入 sqlite

如何识别 DB2 端口号

为什么null不等于null false

使用 Laravel 5.2 从存储在 Y-m-d 数据库中的日期计算年龄

matlab 数据文件到 pandas DataFrame

如何在数据库中存储具有动态数量属性的数据

ORM 性能成本

在 SQL 中与 NULL 值连接

如何使用 PHP 代码将图像上传到 MySQL 数据库

SQL - 如何转置?

如何动态更改 Ruby on Rails 中所有模型的 Active Record 数据库?

存储信用卡号 - PCI?

有哪些不同类型的索引,每种索引的好处是什么?

SQL 截断数据库?如何截断所有表格

使用 Django 的复合/复合主/唯一键

用于 sql 表中的状态列的类型