Files
codeocean/db/migrate/20170830083601_add_cause_to_testruns.rb
Sebastian Serth 6c44ffbd5c Fix missing/incorrect Model specifications in migrations
We need to define the required models within the migration (not below) to work reliably.
2024-07-04 11:02:10 +02:00

28 lines
594 B
Ruby

# frozen_string_literal: true
class AddCauseToTestruns < ActiveRecord::Migration[4.2]
class Testrun < ApplicationRecord
belongs_to :submission, optional: true
end
class Submission < ApplicationRecord
end
def up
add_column :testruns, :cause, :string
Testrun.reset_column_information
Testrun.find_each do |testrun|
if testrun.submission.nil?
say_with_time "#{testrun.id} has no submission"
else
testrun.cause = testrun.submission.cause
testrun.save
end
end
end
def down
remove_column :testruns, :cause
end
end