mirror of https://github.com/docusealco/docuseal
parent
ddcb5c5d40
commit
8630c68631
@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddAccountIdToSubmissions < ActiveRecord::Migration[7.1]
|
||||
class MigrationSubmission < ApplicationRecord
|
||||
self.table_name = 'submissions'
|
||||
end
|
||||
|
||||
class MigrationTemplate < ApplicationRecord
|
||||
self.table_name = 'templates'
|
||||
end
|
||||
|
||||
class MigrationAccount < ApplicationRecord
|
||||
self.table_name = 'accounts'
|
||||
end
|
||||
|
||||
def change
|
||||
add_reference :submissions, :account, index: true, null: true
|
||||
|
||||
MigrationAccount.all.each do |account|
|
||||
MigrationSubmission.where(template_id: MigrationTemplate.where(account_id: account.id).select(:id))
|
||||
.update_all(account_id: account.id)
|
||||
end
|
||||
|
||||
change_column_null :submissions, :account_id, false
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue