dawarich/db/data/20240525110530_bind_existing_points_to_first_user.rb
2024-05-25 14:44:32 +02:00

19 lines
387 B
Ruby

# frozen_string_literal: true
class BindExistingPointsToFirstUser < ActiveRecord::Migration[7.1]
def up
user = User.first
return if user.blank?
points = Point.where(user_id: nil)
points.update_all(user_id: user.id)
Rails.logger.info "Bound #{points.count} points to user #{user.email}"
end
def down
raise ActiveRecord::IrreversibleMigration
end
end