OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/modules/job_status/db/migrate/20200610124259_extend_job_s...

35 lines
991 B

class ExtendJobStatus < ActiveRecord::Migration[6.0]
# ALTER TYPE has to run outside transaction
disable_ddl_transaction!
def change
reversible do |dir|
dir.up do
execute <<-SQL
ALTER TYPE delayed_job_status ADD VALUE IF NOT EXISTS 'cancelled';
SQL
end
end
ActiveRecord::Base.transaction do
remove_reference :delayed_job_statuses, :job
change_table :delayed_job_statuses do |t|
t.references :user, index: true
t.string :job_id, index: { unique: true }
t.jsonb :payload
end
reversible do |dir|
dir.up do
change_column_default :delayed_job_statuses, :created_at, -> { 'CURRENT_TIMESTAMP' }
change_column_default :delayed_job_statuses, :updated_at, -> { 'CURRENT_TIMESTAMP' }
end
end
# Now that we have user reference on job status
# we don't need it on export
remove_reference :work_package_exports, :user
end
end
end