Skip to content

Commit

Permalink
add reset database sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazingRockStorm committed Oct 16, 2023
1 parent 028e826 commit d242136
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/jobs/reset_database_sequence_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

class ResetDatabaseSequenceJob < ApplicationJob
queue_as :low

def perform(*_args)
# Do something later
# sau import, chạy rails c và reset seq:

%w[users songs artists artists_songs genres albums].each do |tablename|
ActiveRecord::Base.connection.reset_pk_sequence!(tablename)
end
end
end
7 changes: 7 additions & 0 deletions spec/jobs/reset_database_sequence_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ResetDatabaseSequenceJob do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit d242136

Please sign in to comment.