Rake db:drop not clearing out my old tables

我是研究僧i 提交于 2019-12-12 01:43:19

问题


My User migration used to look like this:

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :login
      etc

Now it looks like this:

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :username
      etc

Why, then, do I see this?

rake db:drop
rake db:create
rake db:migrate
rails console
> User.new
+----+-------+------------------+---------------+-------------------+------------+------------+
| id | login | crypted_password | password_salt | persistence_token | created_at | updated_at |
+----+-------+------------------+---------------+-------------------+------------+------------+
|    |       |                  |               |                   |            |            |
+----+-------+------------------+---------------+-------------------+------------+------------+
1 row in set

I am using PostgreSQL.


回答1:


Incrementing the filename of the User migration solved the problem. I presume Rails was caching the contents of the migration when I tried to change its contents without changing the filename.



来源:https://stackoverflow.com/questions/12968315/rake-dbdrop-not-clearing-out-my-old-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!