Rake db:drop无法清除旧表 [英] Rake db:drop not clearing out my old tables
本文介绍了Rake db:drop无法清除旧表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的用户迁移过去通常是这样的:
My User migration used to look like this:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :login
etc
现在看起来像这样:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username
etc
为什么,我看到了吗
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
中的1行
我正在使用PostgreSQL。
I am using PostgreSQL.
推荐答案
增加用户迁移的文件名即可解决此问题。我假定Rails在尝试在不更改文件名的情况下更改其内容时就缓存了迁移的内容。
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.
这篇关于Rake db:drop无法清除旧表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文