added AuthenticationToken model, updated some restrictions for the authentication token table, added dependent destroy to the user model for authentication tokens
This commit is contained in:

committed by
Sebastian Serth

parent
fe410a5306
commit
d64daadd21
12
db/migrate/20220721131946_create_authentication_tokens.rb
Normal file
12
db/migrate/20220721131946_create_authentication_tokens.rb
Normal file
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateAuthenticationTokens < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :authentication_tokens, id: :uuid do |t|
|
||||
t.string :shared_secret, null: false, index: {unique: true}
|
||||
t.references :user, polymorphic: true, null: false
|
||||
t.date :expire_at, null: false
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_04_15_215112) do
|
||||
ActiveRecord::Schema.define(version: 2022_07_21_131946) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_trgm"
|
||||
@ -30,6 +30,17 @@ ActiveRecord::Schema.define(version: 2022_04_15_215112) do
|
||||
t.index ["user_type", "user_id"], name: "index_anomaly_notifications_on_user"
|
||||
end
|
||||
|
||||
create_table "authentication_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "shared_secret", null: false
|
||||
t.string "user_type", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.date "expire_at", null: false
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["shared_secret"], name: "index_authentication_tokens_on_shared_secret", unique: true
|
||||
t.index ["user_type", "user_id"], name: "index_authentication_tokens_on_user"
|
||||
end
|
||||
|
||||
create_table "codeharbor_links", id: :serial, force: :cascade do |t|
|
||||
t.string "api_key"
|
||||
t.datetime "created_at"
|
||||
|
Reference in New Issue
Block a user