29 lines
651 B
Ruby
29 lines
651 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Una Raspberry puede tener muchas llaves públicas
|
|
class CreatePublicKeys < ActiveRecord::Migration[6.1]
|
|
def up
|
|
create_table :public_keys, id: :uuid do |t|
|
|
t.timestamps
|
|
t.uuid :raspberry_id, index: true
|
|
t.string :content, null: false, unique: true
|
|
end
|
|
|
|
Raspberry.find_each do |r|
|
|
r.public_keys.create content: r.public_key
|
|
end
|
|
|
|
remove_column :raspberries, :public_key
|
|
end
|
|
|
|
def down
|
|
add_column :raspberries, :public_key, :string
|
|
|
|
Raspberry.find_each do |r|
|
|
r.update public_key: r.public_keys.first.public_key
|
|
end
|
|
|
|
drop_table :public_keys
|
|
end
|
|
end
|