Ruby on Rails的迁移,更改表的MyISAM [英] Ruby on Rails migration, change table to MyISAM

查看:131
本文介绍了Ruby on Rails的迁移,更改表的MyISAM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎样才能正确地创建一个Rails的迁移,这样的表被改成的MyISAM在MySQL的?现在的时间是InnoDB的。运行原始的执行语句会更改表,但它不会更新DB / schema.rb,所以当表被重新创建一个测试环境,它可以追溯到InnoDB和我的全文搜索失败。

How does one create a Rails migration properly so that a table gets changed to MyISAM in MySQL? It is currently InnoDB. Running a raw execute statement will change the table, but it won't update db/schema.rb, so when the table is recreated in a testing environment, it goes back to InnoDB and my fulltext searches fail.

我如何去改变/添加一个迁移,以使现有的表被修改,以MyISAM和schema.rb得到更新,我的数据库和相应的测试数据库得到相应更新?

How do I go about changing/adding a migration so that the existing table gets modified to MyISAM and schema.rb gets updated so my db and respective test db get updated accordingly?

推荐答案

我没有找到一个伟大的方式来做到这一点。你可以改变你schema.rb像有人建议,然后运行:耙分贝:模式:负载,但是,这将覆盖你的数据。

I didn't find a great way to do this. You could change your schema.rb like someone suggested and then run: rake db:schema:load, however, this will overwrite your data.

我做它(假设你正试图转换表叫做书)方式:

The way I did it was (assuming you are trying to convert a table called books):

  1. 从保存CLI中现有的数据: CREATE TABLE TMP SELECT * FROM图书;

在新的迁移文件,删除图书表和创建它:选项=> 发动机= MyISAM数据像是有人在评论说:

In your new migration file, drop the books table and recreate it with :options => "ENGINE=MyISAM" like someone said in the comment

中的内容复制回: INSERT INTO书SELECT * FROM TMP

这篇关于Ruby on Rails的迁移,更改表的MyISAM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆