chore: build
Backend - Build & Lint / build (push) Successful in 31m25s
Frontend Admin - EAS Build / build (push) Successful in 1h24m40s

This commit is contained in:
Xor290
2026-11-15 22:05:14 +01:00
parent 3ce40dd2be
commit beb78bf062
14 changed files with 1204 additions and 35 deletions
+18 -1
View File
@@ -105,6 +105,23 @@ func InitDB() *Database {
log.Fatalf("❌ Erreur migration unit products: %v", err)
}
// Migration: products.stock 2 → 3 décimales, même précision que les quantités commandées (0,001 g)
if _, err = database.Exec(`
DO $$
BEGIN
IF EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'products' AND column_name = 'stock'
AND numeric_scale IS DISTINCT FROM 3
) THEN
ALTER TABLE products ALTER COLUMN stock TYPE NUMERIC(10,3);
END IF;
END
$$;
`); err != nil {
log.Fatalf("❌ Erreur migration products.stock: %v", err)
}
// Migration: baskets.quantity INTEGER → NUMERIC(10,3) pour supporter les quantités fractionnaires (ex: 0.5g)
if _, err = database.Exec(`
DO $$
@@ -404,7 +421,7 @@ func (db *Database) createTables() error {
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
category VARCHAR(100) NOT NULL,
stock DECIMAL(10,2) NOT NULL DEFAULT 0,
stock NUMERIC(10,3) NOT NULL DEFAULT 0,
unit VARCHAR(10) NOT NULL DEFAULT 'u',
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,