summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20250820175727_create_nutrients.rb10
-rw-r--r--db/migrate/20250820175742_create_nutrient_measurements.rb27
-rw-r--r--db/migrate/20250823140019_create_crops.rb26
-rw-r--r--db/migrate/20250823142743_create_beds.rb11
-rw-r--r--db/migrate/20250823142858_create_rafts.rb13
-rw-r--r--db/migrate/20250824121914_create_fertilizer_components.rb26
-rw-r--r--db/migrate/20250824163242_create_fertilizer_products.rb11
-rw-r--r--db/migrate/20250824163257_create_fertilizer_compositions.rb11
8 files changed, 135 insertions, 0 deletions
diff --git a/db/migrate/20250820175727_create_nutrients.rb b/db/migrate/20250820175727_create_nutrients.rb
new file mode 100644
index 0000000..d054375
--- /dev/null
+++ b/db/migrate/20250820175727_create_nutrients.rb
@@ -0,0 +1,10 @@
+class CreateNutrients < ActiveRecord::Migration[8.0]
+ def change
+ create_table :nutrients do |t|
+ t.string :formula
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20250820175742_create_nutrient_measurements.rb b/db/migrate/20250820175742_create_nutrient_measurements.rb
new file mode 100644
index 0000000..b4bae51
--- /dev/null
+++ b/db/migrate/20250820175742_create_nutrient_measurements.rb
@@ -0,0 +1,27 @@
+class CreateNutrientMeasurements < ActiveRecord::Migration[8.0]
+ def change
+ create_table :nutrient_measurements do |t|
+ t.date :measured_on
+ t.float :nno3
+ t.float :p
+ t.float :k
+ t.float :ca
+ t.float :mg
+ t.float :s
+ t.float :na
+ t.float :cl
+ t.float :si
+ t.float :fe
+ t.float :zn
+ t.float :b
+ t.float :mn
+ t.float :cu
+ t.float :mo
+ t.float :nnh4
+
+ t.timestamps
+ end
+
+ add_index :nutrient_measurements, :measured_on, unique: true
+ end
+end
diff --git a/db/migrate/20250823140019_create_crops.rb b/db/migrate/20250823140019_create_crops.rb
new file mode 100644
index 0000000..e88abd3
--- /dev/null
+++ b/db/migrate/20250823140019_create_crops.rb
@@ -0,0 +1,26 @@
+class CreateCrops < ActiveRecord::Migration[8.0]
+ def change
+ create_table :crops do |t|
+ t.string :name
+ t.integer :crop_type, null: false, default: 1
+ t.float :nno3
+ t.float :p
+ t.float :k
+ t.float :ca
+ t.float :mg
+ t.float :s
+ t.float :na
+ t.float :cl
+ t.float :si
+ t.float :fe
+ t.float :zn
+ t.float :b
+ t.float :mn
+ t.float :cu
+ t.float :mo
+ t.float :nnh4
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20250823142743_create_beds.rb b/db/migrate/20250823142743_create_beds.rb
new file mode 100644
index 0000000..3c23ad7
--- /dev/null
+++ b/db/migrate/20250823142743_create_beds.rb
@@ -0,0 +1,11 @@
+class CreateBeds < ActiveRecord::Migration[8.0]
+ def change
+ create_table :beds do |t|
+ t.integer :location, null: false
+
+ t.timestamps
+ end
+
+ add_index :beds, :location, unique: true
+ end
+end
diff --git a/db/migrate/20250823142858_create_rafts.rb b/db/migrate/20250823142858_create_rafts.rb
new file mode 100644
index 0000000..6b7f006
--- /dev/null
+++ b/db/migrate/20250823142858_create_rafts.rb
@@ -0,0 +1,13 @@
+class CreateRafts < ActiveRecord::Migration[8.0]
+ def change
+ create_table :rafts do |t|
+ t.references :bed, null: false, foreign_key: true
+ t.integer :location, null: false
+ t.references :crop, null: true, foreign_key: true
+
+ t.timestamps
+ end
+
+ add_index :rafts, [ :bed_id, :location ], unique: true
+ end
+end
diff --git a/db/migrate/20250824121914_create_fertilizer_components.rb b/db/migrate/20250824121914_create_fertilizer_components.rb
new file mode 100644
index 0000000..2e08fff
--- /dev/null
+++ b/db/migrate/20250824121914_create_fertilizer_components.rb
@@ -0,0 +1,26 @@
+class CreateFertilizerComponents < ActiveRecord::Migration[8.0]
+ def change
+ create_table :fertilizer_components do |t|
+ t.string :name
+ t.string :formula
+ t.float :nno3
+ t.float :nnh4
+ t.float :p
+ t.float :k
+ t.float :ca
+ t.float :mg
+ t.float :s
+ t.float :na
+ t.float :cl
+ t.float :si
+ t.float :fe
+ t.float :zn
+ t.float :b
+ t.float :mn
+ t.float :cu
+ t.float :mo
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20250824163242_create_fertilizer_products.rb b/db/migrate/20250824163242_create_fertilizer_products.rb
new file mode 100644
index 0000000..024f82c
--- /dev/null
+++ b/db/migrate/20250824163242_create_fertilizer_products.rb
@@ -0,0 +1,11 @@
+class CreateFertilizerProducts < ActiveRecord::Migration[8.0]
+ def change
+ create_table :fertilizer_products do |t|
+ t.string :name, null: false
+ t.decimal :purity, precision: 5, scale: 2, null: false, default: 100.00
+
+ t.timestamps
+ end
+ add_index :fertilizer_products, :name, unique: true
+ end
+end
diff --git a/db/migrate/20250824163257_create_fertilizer_compositions.rb b/db/migrate/20250824163257_create_fertilizer_compositions.rb
new file mode 100644
index 0000000..b48954a
--- /dev/null
+++ b/db/migrate/20250824163257_create_fertilizer_compositions.rb
@@ -0,0 +1,11 @@
+class CreateFertilizerCompositions < ActiveRecord::Migration[8.0]
+ def change
+ create_table :fertilizer_compositions do |t|
+ t.references :fertilizer_product, null: false, foreign_key: true
+ t.references :fertilizer_component, null: false, foreign_key: true
+ t.decimal :percent_w, precision: 6, scale: 3, null: false # e.g. 13.500 (% w/w)
+
+ t.timestamps
+ end
+ end
+end
Copyright 2019--2025 Marius PETER