diff --git a/migrate.py b/migrate.py new file mode 100644 index 0000000..aae69a8 --- /dev/null +++ b/migrate.py @@ -0,0 +1,23 @@ +import sqlite3 + +DB_FILE = 'db/pos_database.db' + +def upgrade_db(): + try: + with sqlite3.connect(DB_FILE) as conn: + # Add stock column + conn.execute("ALTER TABLE products ADD COLUMN stock REAL DEFAULT 0") + print("Successfully added 'stock' column.") + + # App.py also expects unit_type, adding it to prevent future headaches + conn.execute("ALTER TABLE products ADD COLUMN unit_type TEXT DEFAULT 'unit'") + print("Successfully added 'unit_type' column.") + + conn.commit() + print("Migration complete. Your data is intact.") + + except sqlite3.OperationalError as e: + print(f"Skipped: {e}. (This usually means the columns already exist, so you're fine).") + +if __name__ == '__main__': + upgrade_db() \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 5c710cf..f430318 100644 --- a/templates/index.html +++ b/templates/index.html @@ -445,7 +445,13 @@ onclick="updateBulkBar()">