1

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.

Min Ming Lo
  • 2,398
  • 2
  • 18
  • 25
  • 1
    See this - http://stackoverflow.com/questions/5440401/change-autoincrement-values-in-migration-postgresql-and-sqlite3 – Anand Jan 12 '12 at 12:45

1 Answers1

1

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 
eldewall
  • 4,816
  • 1
  • 16
  • 9