summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorMarius Peter <dev@marius-peter.com>2025-09-08 21:21:56 +0200
committerMarius Peter <dev@marius-peter.com>2025-09-08 21:21:56 +0200
commit7116826b854188604e21e2a613ac6672b6fd81f3 (patch)
tree33150bf2e04e69b8e1fa7d37901d2643b1955534 /db
parent8ba568ae0ebe715b5da453681eb141886f1977a8 (diff)
Create Target and nutrient target table on dashboard.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20250908181137_create_targets.rb9
-rw-r--r--db/migrate/20250908181147_create_target_allocations.rb11
-rw-r--r--db/schema.rb20
-rw-r--r--db/seeds/NutrientProfile.rb2
4 files changed, 40 insertions, 2 deletions
diff --git a/db/migrate/20250908181137_create_targets.rb b/db/migrate/20250908181137_create_targets.rb
new file mode 100644
index 0000000..9144e50
--- /dev/null
+++ b/db/migrate/20250908181137_create_targets.rb
@@ -0,0 +1,9 @@
+class CreateTargets < ActiveRecord::Migration[8.0]
+ def change
+ create_table :targets do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20250908181147_create_target_allocations.rb b/db/migrate/20250908181147_create_target_allocations.rb
new file mode 100644
index 0000000..9141bd3
--- /dev/null
+++ b/db/migrate/20250908181147_create_target_allocations.rb
@@ -0,0 +1,11 @@
+class CreateTargetAllocations < ActiveRecord::Migration[8.0]
+ def change
+ create_table :target_allocations do |t|
+ t.references :target, null: false, foreign_key: true
+ t.references :nutrient_profile, null: false, foreign_key: true
+ t.decimal :percentage
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index feb2fd0..d201f5a 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: 2025_09_01_112954) do
+ActiveRecord::Schema[8.0].define(version: 2025_09_08_181147) do
create_table "beds", force: :cascade do |t|
t.integer "location", null: false
t.datetime "created_at", null: false
@@ -122,8 +122,26 @@ ActiveRecord::Schema[8.0].define(version: 2025_09_01_112954) do
t.index ["crop_nutrient_need_id"], name: "index_rafts_on_crop_nutrient_need_id"
end
+ create_table "target_allocations", force: :cascade do |t|
+ t.integer "target_id", null: false
+ t.integer "nutrient_profile_id", null: false
+ t.decimal "percentage"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["nutrient_profile_id"], name: "index_target_allocations_on_nutrient_profile_id"
+ t.index ["target_id"], name: "index_target_allocations_on_target_id"
+ end
+
+ create_table "targets", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
add_foreign_key "fertilizer_compositions", "fertilizer_components"
add_foreign_key "fertilizer_compositions", "fertilizer_products"
add_foreign_key "rafts", "beds"
add_foreign_key "rafts", "nutrient_profiles", column: "crop_nutrient_need_id"
+ add_foreign_key "target_allocations", "nutrient_profiles"
+ add_foreign_key "target_allocations", "targets"
end
diff --git a/db/seeds/NutrientProfile.rb b/db/seeds/NutrientProfile.rb
index 04e16cc..0c3c152 100644
--- a/db/seeds/NutrientProfile.rb
+++ b/db/seeds/NutrientProfile.rb
@@ -101,7 +101,7 @@
b: 0.11,
mn: 0.11,
cu: 0.03,
- mo: 0.01 },
+ mo: 0.01 }
].each do |profile|
NutrientProfile.find_or_create_by!(name: profile[:name]) do |p|
p.attributes = profile
Copyright 2019--2025 Marius PETER