mirror of
https://github.com/docusealco/docuseal
synced 2026-11-07 23:32:33 -05:00
add account_id to submissions
This commit is contained in:
1 parent
ddcb5c5d40
commit
8630c68631
9 files changed
+41
-6
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user