feat(api_token): add allowed_procedure_ids to api tokens

This commit is contained in:
Paul Chavard 2023-02-13 14:22:21 +01:00
parent 17361b8644
commit 64f79bb6d8
3 changed files with 18 additions and 8 deletions

View file

@ -2,13 +2,15 @@
#
# Table name: api_tokens
#
# id :uuid not null, primary key
# encrypted_token :string not null
# name :string not null
# version :integer default(3), not null
# created_at :datetime not null
# updated_at :datetime not null
# administrateur_id :bigint not null
# id :uuid not null, primary key
# allowed_procedure_ids :bigint is an Array
# encrypted_token :string not null
# name :string not null
# write_access :boolean default(TRUE), not null
# version :integer default(3), not null
# created_at :datetime not null
# updated_at :datetime not null
# administrateur_id :bigint not null
#
class APIToken < ApplicationRecord
include ActiveRecord::SecureToken

View file

@ -0,0 +1,6 @@
class AddReadOnlyAndProcedureIdsToAPITokens < ActiveRecord::Migration[6.1]
def change
add_column :api_tokens, :write_access, :boolean, default: true, null: false
add_column :api_tokens, :allowed_procedure_ids, :bigint, array: true, null: true
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2023_02_17_094119) do
ActiveRecord::Schema.define(version: 2023_02_18_094119) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
@ -89,9 +89,11 @@ ActiveRecord::Schema.define(version: 2023_02_17_094119) do
create_table "api_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.bigint "administrateur_id", null: false
t.bigint "allowed_procedure_ids", array: true
t.datetime "created_at", precision: 6, null: false
t.string "encrypted_token", null: false
t.string "name", null: false
t.boolean "write_access", default: true, null: false
t.datetime "updated_at", precision: 6, null: false
t.integer "version", default: 3, null: false
t.index ["administrateur_id"], name: "index_api_tokens_on_administrateur_id"