Created
October 9, 2014 17:29
-
-
Save jayfredlund/35039750afeb3fa9ac5a to your computer and use it in GitHub Desktop.
From Rails: start a table sequence ID at a different value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def alter_sequence_id(table_name, start_value) | |
ActiveRecord::Base.connection.execute("ALTER SEQUENCE #{table_name}_id_seq RESTART WITH #{start_value};") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment