scinote-web/db/migrate/20200826143431_migrate_task_status.rb

21 lines
672 B
Ruby
Raw Normal View History

2020-08-27 17:30:55 +08:00
# frozen_string_literal: true
class MigrateTaskStatus < ActiveRecord::Migration[6.0]
def up
2020-08-27 18:13:13 +08:00
MyModuleStatusFlow.ensure_default
2020-08-27 17:30:55 +08:00
2020-08-27 18:13:13 +08:00
in_progress_status = execute("SELECT id FROM my_module_statuses WHERE name = 'In progress' LIMIT 1").to_a[0]
completed_status = execute("SELECT id FROM my_module_statuses WHERE name = 'Completed' LIMIT 1").to_a[0]
if in_progress_status
execute("UPDATE my_modules
SET my_module_status_id = #{in_progress_status['id']} WHERE state = 0")
end
if completed_status
execute("UPDATE my_modules
SET my_module_status_id = #{completed_status['id']} WHERE state = 1")
end
2020-08-27 17:30:55 +08:00
end
end