1

有没有办法让我在 Rails 中设置 id 的增量值?而不是 +1,而是 +10(或我指定的其他函数)。

在 MySQL 中有一个选项@@auto_increment_increment。有没有办法通过 ActiveRecord 在 Rails 中设置?我正在使用两个 Postgres。

4

1 回答 1

1

查看 Rails 3.x 迁移指南:http: //guides.rubyonrails.org/migrations.html

有一个例子,他们对一些 sql 进行硬编码

class SomeMigration < ActiveRecord::Migration

    def up
      execute <<-SQL
            ALTER TABLE xxx
      SQL
    end

end 
于 2012-01-12T10:37:12.193 回答