Allow arbitrary text in shopping list

This commit is contained in:
Bernd Bestel
2018-01-04 12:51:36 +01:00
parent 2ddbc2656b
commit e40979a874
3 changed files with 40 additions and 5 deletions

View File

@@ -160,6 +160,32 @@ class GrocyDbMigrator
GROUP BY battery_id
ORDER BY MAX(tracked_time) DESC;"
);
self::ExecuteMigrationWhenNeeded($pdo, 16, "
ALTER TABLE shopping_list RENAME TO shopping_list_old;"
);
self::ExecuteMigrationWhenNeeded($pdo, 17, "
CREATE TABLE shopping_list (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
product_id INTEGER,
note TEXT,
amount INTEGER NOT NULL DEFAULT 0,
amount_autoadded INTEGER NOT NULL DEFAULT 0,
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime'))
)"
);
self::ExecuteMigrationWhenNeeded($pdo, 18, "
INSERT INTO shopping_list
(product_id, amount, amount_autoadded, row_created_timestamp)
SELECT product_id, amount, amount_autoadded, row_created_timestamp
FROM shopping_list_old"
);
self::ExecuteMigrationWhenNeeded($pdo, 19, "
DROP TABLE shopping_list_old;"
);
}
private static function ExecuteMigrationWhenNeeded(PDO $pdo, int $migrationId, string $sql)