轨道迁移。修改auto_increment的起点

发布于 2024-08-30 23:01:09 字数 466 浏览 2 评论 0原文

我已经创建了一个表。我正在寻找 Rails 迁移,可以在其中修改表的 id 列的 auto_increment 数字的起点。假设我希望它从 1000 开始。

我用谷歌搜索了一下,发现这个

它说:

:options "string" 将原始选项传递给 你的底层数据库,例如 auto_increment = 10000。请注意 传递选项会让你失败 默认 ENGINE=InnoDB 语句

可以用于我想要的东西吗?由于我正在更改列而不是创建新列,迁移会是什么样子......

I have a table already created. I am looking for a rails migration where I can modify the starting point of the auto_increment number for id column of my table. Let's say I want it to start from 1000.

I googled a bit and came across this:

it says:

:options "string" pass raw options to
your underlying database, e.g.
auto_increment = 10000. Note that
passing options will cause you to lose
the default ENGINE=InnoDB statement

Can this be used for something I want? and how will the migration look since i am changing the column and not creating new one...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

方觉久 2024-09-06 23:01:09

您可以使用原始 execute 方法

execute ("ALTER TABLE your_table_name AUTO_INCREMENT = 10000")

You can use raw execute method

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