~cytrogen/masto-fe

ref: 31d5bc89d12cd2c5c9b148e4abaa37b2f553a8d5 masto-fe/db/migrate/20190715164535_add_instance_actor.rb -rw-r--r-- 664 bytes
31d5bc89 — Matt Jankowski Speed improvement for `AccountsStatusesCleanupScheduler` spec (#25406) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class AddInstanceActor < ActiveRecord::Migration[5.2]
  class Account < ApplicationRecord
    # Dummy class, to make migration possible across version changes
    validates :username, uniqueness: { scope: :domain, case_sensitive: false }

    before_create :generate_keys

    def generate_keys
      keypair = OpenSSL::PKey::RSA.new(2048)
      self.private_key = keypair.to_pem
      self.public_key  = keypair.public_key.to_pem
    end
  end

  def up
    Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
  end

  def down
    Account.find_by(id: -99, actor_type: 'Application').destroy!
  end
end