How to restart id counting on a table in PostgreSQL after deleting some previous data?
If you truncate the table you can use the RESTART IDENTITY clause on the end.
Example:
TRUNCATE TABLE foo RESTART IDENTITY;
TRUNCATE DOCUMENTATION
You could do it in the following way:
ActiveRecord::Base.connection.execute("TRUNCATE TABLE your_table_name RESTART IDENTITY")
You can do it directly in PostgreSQL using "alter sequence": http://www.postgresql.org/docs/current/static/sql-altersequence.html
Particularly "restart with"
I don't know how you would do it via the rails abstraction.