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.
28 lines
890 B
28 lines
890 B
# frozen_string_literal: true
|
|
|
|
class BackfillTeams < ActiveRecord::Migration[8.0]
|
|
def up
|
|
Account.find_each do |account|
|
|
ActiveRecord::Base.transaction do
|
|
team = Team.create!(
|
|
name: 'Default',
|
|
account: account,
|
|
uuid: SecureRandom.uuid
|
|
)
|
|
|
|
User.where(account_id: account.id, team_id: nil).update_all(team_id: team.id)
|
|
Template.where(account_id: account.id, team_id: nil).update_all(team_id: team.id)
|
|
Submission.where(account_id: account.id, team_id: nil).update_all(team_id: team.id)
|
|
Submitter.where(account_id: account.id, team_id: nil).update_all(team_id: team.id)
|
|
TemplateFolder.where(account_id: account.id, team_id: nil).update_all(team_id: team.id)
|
|
end
|
|
end
|
|
|
|
change_column_null :users, :team_id, false
|
|
end
|
|
|
|
def down
|
|
change_column_null :users, :team_id, true
|
|
end
|
|
end
|