2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-22 01:47:48 +00:00
moebooru/db/migrate/091_migrate_users_to_contributor.rb
2024-01-08 19:39:01 +09:00

18 lines
454 B
Ruby

class MigrateUsersToContributor < ActiveRecord::Migration[5.1]
def self.up
User.find(:all, conditions: "level = 30").each do |user|
post_count = Post.count(conditions: [ "user_id = ? AND status <> 'deleted'", user.id ])
if post_count > 50
user.update_attribute(:level, 33)
end
end
User.update_all("invite_count = 0", "level < 35")
end
def self.down
User.update_all("level = 30", "level = 33")
end
end