Fixed seed created_at column

This commit is contained in:
2024-10-03 16:18:52 +02:00
parent a2269cb6b9
commit 6ce1b80360

View File

@@ -75,7 +75,7 @@ end
updated_at = created_at + rand(4..44).minutes
status_changed_at = updated_at
end
job = Job.new(status:, privacy_policy: true, created_at: created_at)
job = Job.new(status:, privacy_policy: true)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
student = students[rand(0..9)]
job.customer = student
@@ -84,6 +84,7 @@ end
job.operator = operator if status != :open
job.cashier = operator if status == :paid
job.save!
job.update_column :created_at, created_at # write with update_column to avoid before_save action
job.update_column :printed_at, printed_at # write with update_column to avoid before_save action
job.update_column :status_changed_at, status_changed_at # write with update_column to avoid before_save action
job.update_column :paid_at, paid_at if status == :paid # write with update_column to avoid before_save action
@@ -109,7 +110,7 @@ end
updated_at = created_at + rand(4..44).minutes
status_changed_at = updated_at
end
job = Job.new(status:, privacy_policy: true, created_at: created_at)
job = Job.new(status:, privacy_policy: true)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
student = students[rand(0...9)]
job.customer = student
@@ -118,6 +119,7 @@ end
job.operator = operator if status == :paid
job.cashier = operator if status == :paid
job.save!
job.update_column :created_at, created_at # write with update_column to avoid before_save action
job.update_column :printed_at, printed_at # write with update_column to avoid before_save action
job.update_column :status_changed_at, status_changed_at # write with update_column to avoid before_save action
job.update_column :paid_at, paid_at if status == :paid # write with update_column to avoid before_save action