mirror of https://github.com/docusealco/docuseal
				
				
				
			
			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.
		
		
		
		
		
			
		
			
				
					
					
						
							27 lines
						
					
					
						
							722 B
						
					
					
				
			
		
		
	
	
							27 lines
						
					
					
						
							722 B
						
					
					
				| # 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
 |