Rails:更改数据库
我使用一个错误命名的数据库创建了一个应用程序,对数据库中重要数据的所有更改都已在固定装置中完成,以便我可以删除数据库,重新创建它,然后 rake 迁移数据库表并用来自的初始数据填充它们固定装置。
我现在想更改数据库的名称,因此我更新了database.yml 文件以反映另一个数据库名称。我在 mysql 中创建了数据库,然后尝试运行迁移和固定装置。
使用跟踪运行迁移显示它正在运行命令来创建表等。但是,一旦完成,我的应用程序中就会出现错误,表明新数据库中不存在这些表。
我进入mysql并检查数据库,它完全是空的。我尝试擦除所有内容并运行迁移几次,但没有任何变化。我有什么遗漏的吗?
I have created an app using a badly named database, all alterations to important data in the database have been done in fixtures so that I can just drop the database, recreate it and then rake migrate the database tables and fill them with the initial data from the fixtures.
I would like to change the name of my database now, so I updated the database.yml file to reflect another database name. I created the database in mysql and then tried to run the migration and fixtures.
Running the migration with trace shows that it is running commands to create tables etc. However once I am finished I get errors in my application saying that the tables don't exist in the new database.
I go into mysql and check the database and it is completely empty. I have tried wiping everything and running the migrations a few times but nothing changes. Is there something I am missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道您使用什么命令进行迁移,但是要迁移生产数据库(我从标签“生产环境”推断出),您必须执行以下操作:
如果这不是答案,那么请提供您用于执行迁移的命令、您预计受影响的数据库以及
database.yml
的相关位。I don't know what commands you used to do the migration, but to migrate a production database (which I infer from the tag, "production-environment"), you have to do:
If that's not the answer, then please provide the command you used to perform the migration, which database you expected to be affected, and the relevant bits of
database.yml
.