Skip to content

Commit

Permalink
add a rake task to reset postgres sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
oscgonfer committed Feb 23, 2024
1 parent d8d51c2 commit afdce95
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/tasks/pgsequences.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace :pgsequences do
desc "Reset all Postgres sequences"
task :reset => :environment do
ActiveRecord::Base.connection.tables.each do |t|
ActiveRecord::Base.connection.reset_pk_sequence!(t)
puts "Reset pk sequence on table: #{t}"
end
end
end

0 comments on commit afdce95

Please sign in to comment.