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.
docuseal/db/migrate/20230726062428_add_template...

36 lines
976 B

# frozen_string_literal: true
class AddTemplateFieldsToSubmission < ActiveRecord::Migration[7.0]
class MigrationTemplate < ApplicationRecord
self.table_name = 'templates'
end
class MigrationSubmission < ApplicationRecord
self.table_name = 'submissions'
end
def up
change_table :submissions, bulk: true do |t|
t.text :template_fields
t.text :template_schema
t.text :template_submitters
end
MigrationTemplate.all.each do |template|
MigrationSubmission.where(template_id: template.id).each do |submission|
submission.update_columns(template_fields: template.fields,
template_schema: template.schema,
template_submitters: template.submitters)
end
end
end
def down
change_table :submissions, bulk: true do |t|
t.remove :template_fields
t.remove :template_schema
t.remove :template_submitters
end
end
end