From 9de6c35f387d770db8705dee7a390d65b9cf2331 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:14:47 +0100 Subject: [PATCH] add trackable module to devise --- app/models/user.rb | 2 +- ...231101100015_add_devise_trackable_columns_to_users.rb | 9 +++++++++ db/schema.rb | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20231101100015_add_devise_trackable_columns_to_users.rb diff --git a/app/models/user.rb b/app/models/user.rb index d90b05bb8..479346276 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ class User < ApplicationRecord include ApplicationHelper # use devise for authentification, include the following modules - devise :database_authenticatable, :registerable, + devise :database_authenticatable, :registerable, :trackable, :recoverable, :rememberable, :validatable, :confirmable, :lockable # a user has many subscribed lectures diff --git a/db/migrate/20231101100015_add_devise_trackable_columns_to_users.rb b/db/migrate/20231101100015_add_devise_trackable_columns_to_users.rb new file mode 100644 index 000000000..94a9eeaf2 --- /dev/null +++ b/db/migrate/20231101100015_add_devise_trackable_columns_to_users.rb @@ -0,0 +1,9 @@ +class AddDeviseTrackableColumnsToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :sign_in_count, :integer, default: 0, null: false + add_column :users, :current_sign_in_at, :datetime + add_column :users, :last_sign_in_at, :datetime + add_column :users, :current_sign_in_ip, :string + add_column :users, :last_sign_in_ip, :string + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index d9abf5def..923aed6fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_04_27_124337) do +ActiveRecord::Schema[7.0].define(version: 2023_11_01_100015) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -848,6 +848,11 @@ t.datetime "locked_at", precision: nil t.text "image_data" t.string "ghost_hash" + t.integer "sign_in_count", default: 0, null: false + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true