我有办法在Rails中设置id的增量值吗?而不是+1,是+10(或我指定的其他一些功能)。
在MySQL中有一个选项@@ auto_increment_increment。有没有办法通过ActiveRecord设置Rails?我正在与Postgres合作。
答案 0 :(得分: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