feat: add expiry_date, notes, and generic_name columns to medications table with corresponding migrations

This commit is contained in:
Daniel Volz
2025-12-20 22:06:44 +01:00
parent b96c8db3de
commit 8a03bf3f86
9 changed files with 286 additions and 19 deletions
+3
View File
@@ -13,6 +13,9 @@ export const db = drizzle(client);
async function runMigrations() {
const migrations = [
{ name: "image_url", sql: "ALTER TABLE medications ADD COLUMN image_url TEXT" },
{ name: "expiry_date", sql: "ALTER TABLE medications ADD COLUMN expiry_date TEXT" },
{ name: "notes", sql: "ALTER TABLE medications ADD COLUMN notes TEXT" },
{ name: "generic_name", sql: "ALTER TABLE medications ADD COLUMN generic_name TEXT" },
];
for (const migration of migrations) {
@@ -0,0 +1,2 @@
-- Migration 0004: Add expiry_date column for medication expiration tracking
ALTER TABLE medications ADD COLUMN expiry_date TEXT;
@@ -0,0 +1,2 @@
-- Add notes column for medication instructions
ALTER TABLE medications ADD COLUMN notes TEXT;
@@ -0,0 +1,2 @@
-- Add generic_name column for medication active ingredient
ALTER TABLE medications ADD COLUMN generic_name TEXT;
+4 -1
View File
@@ -3,6 +3,9 @@
{ "idx": 0, "version": 1, "when": 1734633120, "tag": "0000_init", "breakpoint": false },
{ "idx": 1, "version": 1, "when": 1734700000, "tag": "0001_add_strips", "breakpoint": false },
{ "idx": 2, "version": 1, "when": 1734800000, "tag": "0002_pack_inventory", "breakpoint": false },
{ "idx": 3, "version": 1, "when": 1734900000, "tag": "0003_add_image_url", "breakpoint": false }
{ "idx": 3, "version": 1, "when": 1734900000, "tag": "0003_add_image_url", "breakpoint": false },
{ "idx": 4, "version": 1, "when": 1735000000, "tag": "0004_add_expiry_date", "breakpoint": false },
{ "idx": 5, "version": 1, "when": 1735100000, "tag": "0005_add_notes", "breakpoint": false },
{ "idx": 6, "version": 1, "when": 1735200000, "tag": "0006_add_generic_name", "breakpoint": false }
]
}
+3
View File
@@ -13,6 +13,7 @@ export const users = sqliteTable("users", {
export const medications = sqliteTable("medications", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name", { length: 100 }).notNull().unique(),
genericName: text("generic_name", { length: 100 }),
count: integer("count").notNull().default(0),
strips: integer("strips").notNull().default(0),
packCount: integer("pack_count").notNull().default(1),
@@ -24,6 +25,8 @@ export const medications = sqliteTable("medications", {
startJson: text("start_json").notNull().default("[]"),
stripSize: integer("strip_size").notNull().default(1),
imageUrl: text("image_url"),
expiryDate: text("expiry_date"),
notes: text("notes"),
updatedAt: integer("updated_at", { mode: "timestamp" }).notNull().default(sql`CURRENT_TIMESTAMP`),
});