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/20260508100002_backfill_tea...

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