canvas-lms/db/migrate/20111122162607_submission_p...

24 lines
986 B
Ruby

class SubmissionPointsPossibleFixData < ActiveRecord::Migration
def self.up
case adapter_name
when 'MySQL'
execute <<-SQL
UPDATE quiz_submissions, quizzes
SET quiz_points_possible = points_possible
WHERE quiz_id = quizzes.id AND quiz_points_possible <> points_possible AND (points_possible < 2147483647 AND quiz_points_possible = CAST(points_possible AS SIGNED) OR points_possible >= 2147483647 AND quiz_points_possible = 2147483647)
SQL
when 'PostgreSQL'
execute <<-SQL
UPDATE quiz_submissions
SET quiz_points_possible = points_possible
FROM quizzes
WHERE quiz_id = quizzes.id AND quiz_points_possible <> points_possible AND (points_possible < 2147483647 AND quiz_points_possible = CAST(points_possible AS INTEGER) OR points_possible >= 2147483647 AND quiz_points_possible = 2147483647)
SQL
# no fix needed for sqlite
end
end
def self.down
end
end