diff --git a/app/models/rfid_tag.rb b/app/models/rfid_tag.rb index 88efdc8..0a8fcde 100644 --- a/app/models/rfid_tag.rb +++ b/app/models/rfid_tag.rb @@ -1,2 +1,3 @@ class RfidTag < ApplicationRecord + belongs_to :user, required: false end diff --git a/db/migrate/20260127134053_add_chip_id_and_users_to_rfid_tags.rb b/db/migrate/20260127134053_add_chip_id_and_users_to_rfid_tags.rb new file mode 100644 index 0000000..a30bc13 --- /dev/null +++ b/db/migrate/20260127134053_add_chip_id_and_users_to_rfid_tags.rb @@ -0,0 +1,6 @@ +class AddChipIdAndUsersToRfidTags < ActiveRecord::Migration[8.0] + def change + add_column :rfid_tags, :chip_id, :string + add_reference :rfid_tags, :user, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f33dca..8e352f9 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.0].define(version: 2026_01_12_150457) do +ActiveRecord::Schema[8.0].define(version: 2026_01_27_134053) do create_table "moods", force: :cascade do |t| t.string "mode" t.datetime "recorded_at" @@ -21,9 +21,12 @@ ActiveRecord::Schema[8.0].define(version: 2026_01_12_150457) do create_table "rfid_tags", force: :cascade do |t| t.string "identifier" t.string "mode" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", default: -> { "CURRENT_DATE" }, null: false + t.datetime "updated_at", default: -> { "CURRENT_DATE" }, null: false + t.string "chip_id" + t.integer "user_id" t.index ["identifier"], name: "index_rfid_tags_on_identifier", unique: true + t.index ["user_id"], name: "index_rfid_tags_on_user_id" end create_table "sessions", force: :cascade do |t| @@ -44,5 +47,6 @@ ActiveRecord::Schema[8.0].define(version: 2026_01_12_150457) do t.index ["email_address"], name: "index_users_on_email_address", unique: true end + add_foreign_key "rfid_tags", "users" add_foreign_key "sessions", "users" end