25 lines
908 B
Ruby
25 lines
908 B
Ruby
class CreateClients < ActiveRecord::Migration[6.1]
|
|
def change
|
|
create_table :clients do |t|
|
|
# TODO: check performance of indexing name/name_id
|
|
# prefix: char(8) + name_id sha1(name + SecureRandom.base64(8))[0, 8] + api_key: SecureRandom.hex(32)
|
|
# -> 8 + 8 + 64 = client_api_key(80+2) (delimited with '.'):
|
|
# <prefix>.<name_id>.<api_key>
|
|
t.string :name, limit: 20, null: false, unique: true
|
|
t.string :name_id, limit: 8, null: false, unique: true
|
|
t.string :api_key_hash, null: false, limit: 60
|
|
t.string :description, limit: 200, default: ''
|
|
t.boolean :perm_r, default: false
|
|
t.boolean :perm_w, default: false
|
|
t.boolean :perm_x, default: false
|
|
t.boolean :public_ip, default: false
|
|
t.string :ipv4, limit: 15, default: ''
|
|
|
|
t.timestamps
|
|
end
|
|
end
|
|
end
|
|
|
|
# reset with all migrations with
|
|
# rake db:drop db:create db:migrate
|