Rails:更改数据库

发布于 2024-10-07 16:24:11 字数 323 浏览 0 评论 0原文

我使用一个错误命名的数据库创建了一个应用程序,对数据库中重要数据的所有更改都已在固定装置中完成,以便我可以删除数据库,重新创建它,然后 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2024-10-14 16:24:11

我不知道您使用什么命令进行迁移,但是要迁移生产数据库(我从标签“生产环境”推断出),您必须执行以下操作:

RAILS_ENV=production rake db:migrate

如果这不是答案,那么请提供您用于执行迁移的命令、您预计受影响的数据库以及 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:

RAILS_ENV=production rake db:migrate

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文