Skip to content

Instantly share code, notes, and snippets.

@m2web
Created January 24, 2013 09:52
Show Gist options
  • Save m2web/4619356 to your computer and use it in GitHub Desktop.
Save m2web/4619356 to your computer and use it in GitHub Desktop.
class AddSequenceToTableName < ActiveRecord::Migration
def up
#add sequence to
execute <<-SQL
ALTER TABLE table_name ALTER COLUMN id SET DEFAULT nextval('table_name_id_seq'::regclass);
SQL
end
def down
execute <<-SQL
ALTER TABLE table_name ALTER COLUMN id SET NOT NULL;
SQL
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment