From 35a92a375d4c44ab3ee98a99b1f313a7982dcab7 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 29 Jul 2026 16:54:04 +0200 Subject: [PATCH] use mode reference for rfid tags --- app/models/rfid_tag.rb | 1 + ...60729144217_update_rfid_tags_mode_from_string_to_mode.rb | 6 ++++++ db/schema.rb | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20260729144217_update_rfid_tags_mode_from_string_to_mode.rb diff --git a/app/models/rfid_tag.rb b/app/models/rfid_tag.rb index 0a8fcde..59834be 100644 --- a/app/models/rfid_tag.rb +++ b/app/models/rfid_tag.rb @@ -1,3 +1,4 @@ class RfidTag < ApplicationRecord belongs_to :user, required: false + belongs_to :mode, required: false end diff --git a/db/migrate/20260729144217_update_rfid_tags_mode_from_string_to_mode.rb b/db/migrate/20260729144217_update_rfid_tags_mode_from_string_to_mode.rb new file mode 100644 index 0000000..5c3fe8d --- /dev/null +++ b/db/migrate/20260729144217_update_rfid_tags_mode_from_string_to_mode.rb @@ -0,0 +1,6 @@ +class UpdateRfidTagsModeFromStringToMode < ActiveRecord::Migration[8.0] + def change + remove_column :rfid_tags, :mode + add_reference :rfid_tags, :mode + end +end diff --git a/db/schema.rb b/db/schema.rb index c7a6b6f..40d2cd5 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_03_19_181607) do +ActiveRecord::Schema[8.0].define(version: 2026_07_29_144217) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -70,12 +70,13 @@ ActiveRecord::Schema[8.0].define(version: 2026_03_19_181607) do create_table "rfid_tags", force: :cascade do |t| t.string "identifier" - t.string "mode" 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.integer "mode_id" t.index ["identifier"], name: "index_rfid_tags_on_identifier", unique: true + t.index ["mode_id"], name: "index_rfid_tags_on_mode_id" t.index ["user_id"], name: "index_rfid_tags_on_user_id" end