0

I’m trying to add a string column to a SQLite 3 database in rails. Use the normal syntax "rails generate migration AddAuthorColumnToPublications author:string". I run the migration, it works without errors.

I change the attributes accessor in the Publications model to include the Author column. I check in the schema, the new column has been included in the schema.

I go to my database and the new column does not appear in the index of the Publications table. I’ve tried including it specifically in the index, but to no avail.

The only thing I can think of here is that because I am using Ubuntu, the syntax may be slightly different (as it has been for certain things).

I have looked in books and on the internet, and the syntax seems correct (can also use underscores as well as camel casing to name the migration), but I can’t find anything specific to Ubuntu on this particular issue. I would appreciate any and all help on this matter.

4

1 回答 1

2

运行此命令:

rake db:migrate

迁移不会自动运行。您需要运行rake db:migrate才能运行所有迁移并更新数据库。

此外,查看您的 database.yml 文件并确保您使用的是您正在打开的 sqlite 数据库。命令的语法没有什么不同。

于 2012-07-13T19:29:19.133 回答