Skip to content

Instantly share code, notes, and snippets.

@jayfredlund
Created October 9, 2014 17:29
Show Gist options
  • Save jayfredlund/35039750afeb3fa9ac5a to your computer and use it in GitHub Desktop.
Save jayfredlund/35039750afeb3fa9ac5a to your computer and use it in GitHub Desktop.
From Rails: start a table sequence ID at a different value
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