add chip id and user to rfid_tags

This commit is contained in:
Christophe Robillard 2026-01-27 14:49:20 +01:00
parent 4567f3ef6e
commit 39f1035125
3 changed files with 14 additions and 3 deletions

View file

@ -1,2 +1,3 @@
class RfidTag < ApplicationRecord
belongs_to :user, required: false
end

View file

@ -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

10
db/schema.rb generated
View file

@ -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