diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2025-10-28 21:08:40 -0400 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-10-28 21:08:40 -0400 |
| commit | dff8b357b7031d572099eab3e05e333b79f21f22 (patch) | |
| tree | 3793d49716d5668d8dda653549f9976be5564d98 | |
| parent | e54cd377470bf5cbaac7029e2885c147b81907cb (diff) | |
model: user: add role enum
| -rw-r--r-- | app/models/user.rb | 2 | ||||
| -rw-r--r-- | db/migrate/20251029010650_add_role_to_users.rb | 5 | ||||
| -rw-r--r-- | db/schema.rb | 3 |
3 files changed, 9 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index c88d5b0..2386d7e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,6 @@ class User < ApplicationRecord has_many :sessions, dependent: :destroy normalizes :email_address, with: ->(e) { e.strip.downcase } + + enum :role, %i[ normie admin ] end diff --git a/db/migrate/20251029010650_add_role_to_users.rb b/db/migrate/20251029010650_add_role_to_users.rb new file mode 100644 index 0000000..4aa1d12 --- /dev/null +++ b/db/migrate/20251029010650_add_role_to_users.rb @@ -0,0 +1,5 @@ +class AddRoleToUsers < ActiveRecord::Migration[8.1] + def change + add_column :users, :role, :integer, null: false, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index fc12b56..fe7b52f 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[8.1].define(version: 2025_10_29_005839) do +ActiveRecord::Schema[8.1].define(version: 2025_10_29_010650) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -34,6 +34,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_29_005839) do t.datetime "created_at", null: false t.string "email_address", null: false t.string "password_digest", null: false + t.integer "role", default: 0, null: false t.datetime "updated_at", null: false t.index ["email_address"], name: "index_users_on_email_address", unique: true end |
