Rake db:drop not clearing out my old tables

2019-09-16 02:02发布

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条回答
Anthone
2楼-- · 2019-09-16 02:59

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.

查看更多
登录 后发表回答