Min Ming Lo
Min Ming Lo

Reputation: 2508

Set/Change Rails id auto increment value

Is there a way for me to set the increment value of id in Rails? Instead of +1, to be +10 (or some other function I specify).

In MySQL there is an option @@auto_increment_increment. Is there a way to set in Rails through ActiveRecord? I am working with both Postgres.

Upvotes: 1

Views: 1356

Answers (1)

eldewall
eldewall

Reputation: 4856

Check the Rails 3.x guide on migrations: http://guides.rubyonrails.org/migrations.html

There is a example where they hardcode some sql

class SomeMigration < ActiveRecord::Migration

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

end 

Upvotes: 1

Related Questions