about summary refs log tree commit diff stats
path: root/crates/rocie-server/src/storage/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rocie-server/src/storage/migrate')
-rw-r--r--crates/rocie-server/src/storage/migrate/sql/0->1.sql12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/rocie-server/src/storage/migrate/sql/0->1.sql b/crates/rocie-server/src/storage/migrate/sql/0->1.sql
index 13bc1cb..5aa497d 100644
--- a/crates/rocie-server/src/storage/migrate/sql/0->1.sql
+++ b/crates/rocie-server/src/storage/migrate/sql/0->1.sql
@@ -37,11 +37,15 @@ CREATE TABLE barcodes (
     amount                      INTEGER        NOT NULL,
     unit                        TEXT           NOT NULL,
     FOREIGN KEY(product_id) REFERENCES products(id),
-    FOREIGN KEY(unit) REFERENCES units(name)
+    FOREIGN KEY(unit) REFERENCES units(id)
 ) STRICT;
 
 CREATE TABLE units (
-    name                        TEXT UNIQUE NOT NULL PRIMARY KEY
+    id                          TEXT UNIQUE NOT NULL PRIMARY KEY,
+    full_name_singular          TEXT UNIQUE NOT NULL,
+    full_name_plural            TEXT UNIQUE NOT NULL,
+    short_name                  TEXT UNIQUE NOT NULL,
+    description                 TEXT
 ) STRICT;
 
 -- Encodes unit conversions:
@@ -51,8 +55,8 @@ CREATE TABLE unit_conversions (
     from_unit                  TEXT NOT NULL,
     to_unit                    TEXT NOT NULL,
     factor                     REAL NOT NULL,
-    FOREIGN KEY(from_unit)     REFERENCES units(name),
-    FOREIGN KEY(to_unit)       REFERENCES units(name)
+    FOREIGN KEY(from_unit)     REFERENCES units(id),
+    FOREIGN KEY(to_unit)       REFERENCES units(id)
 ) STRICT;
 
 -- Log of all the applied operations to this db.