mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-30 23:49:04 +01:00
33cd80d69c
* Add migration test about instance actor key * Fix old migration * Work around incorrect database state
22 lines
664 B
Ruby
22 lines
664 B
Ruby
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
|