aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/client.rb1
-rw-r--r--app/models/visit.rb3
-rw-r--r--db/migrate/20251029130829_create_visits.rb9
-rw-r--r--db/schema.rb10
4 files changed, 22 insertions, 1 deletions
diff --git a/app/models/client.rb b/app/models/client.rb
index 45b2363..4bbe757 100644
--- a/app/models/client.rb
+++ b/app/models/client.rb
@@ -1,2 +1,3 @@
class Client < ApplicationRecord
+ has_many :visits
end
diff --git a/app/models/visit.rb b/app/models/visit.rb
new file mode 100644
index 0000000..9b8b4d0
--- /dev/null
+++ b/app/models/visit.rb
@@ -0,0 +1,3 @@
+class Visit < ApplicationRecord
+ belongs_to :client
+end
diff --git a/db/migrate/20251029130829_create_visits.rb b/db/migrate/20251029130829_create_visits.rb
new file mode 100644
index 0000000..a6301e3
--- /dev/null
+++ b/db/migrate/20251029130829_create_visits.rb
@@ -0,0 +1,9 @@
+class CreateVisits < ActiveRecord::Migration[8.1]
+ def change
+ create_table :visits do |t|
+ t.references :client, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fe7b52f..52a6a4c 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_010650) do
+ActiveRecord::Schema[8.1].define(version: 2025_10_29_130829) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
@@ -39,5 +39,13 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_29_010650) do
t.index ["email_address"], name: "index_users_on_email_address", unique: true
end
+ create_table "visits", force: :cascade do |t|
+ t.bigint "client_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["client_id"], name: "index_visits_on_client_id"
+ end
+
add_foreign_key "sessions", "users"
+ add_foreign_key "visits", "clients"
end