🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Fixing database
sassanixc07d2079a223
diff --git a/Dockerfile b/Dockerfileindex 49c1745..780b6a8 100644--- a/Dockerfile+++ b/Dockerfile@@ -53,7 +53,7 @@ RUN echo 'server {\n\\n\# Proxy API requests to backend\n\location /api/ {\n\- proxy_pass http://localhost:5000;\n\+ proxy_pass http://127.0.0.1:5000;\n\proxy_set_header Host $host;\n\proxy_set_header X-Real-IP $remote_addr;\n\}\n\diff --git a/backend/app.py b/backend/app.pyindex 426d02c..ebd65cf 100644--- a/backend/app.py+++ b/backend/app.py@@ -2,7 +2,7 @@ from flask import Flask, request, jsonify, send_from_directoryimport psycopg2from psycopg2 import poolimport os-from datetime import datetime, timedelta+from datetime import datetime, timedelta, datefrom werkzeug.utils import secure_filenamefrom flask_cors import CORSimport logging@@ -98,7 +98,7 @@ def get_warranties():warranty_dict = dict(zip(columns, row))# Convert date objects to ISO format strings for JSON serializationfor key, value in warranty_dict.items():- if isinstance(value, datetime.date):+ if isinstance(value, (datetime, date)):warranty_dict[key] = value.isoformat()warranties_list.append(warranty_dict)diff --git a/backend/init.sql b/backend/init.sqlindex 0ddd2f4..1a7997a 100644--- a/backend/init.sql+++ b/backend/init.sql@@ -2,17 +2,13 @@CREATE TABLE warranties (id SERIAL PRIMARY KEY,- item_name VARCHAR(255) NOT NULL,- serial_number VARCHAR(255),- purchase_date DATE,- expiration_date DATE NOT NULL,- warranty_provider VARCHAR(255),- invoice_image VARCHAR(255), -- Filename or path to the uploaded invoice image- notes TEXT, -- Any additional notes about the warranty- created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,- updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP+ product_name VARCHAR(255) NOT NULL,+ purchase_date DATE NOT NULL,+ warranty_years INTEGER NOT NULL,+ expiration_date DATE,+ invoice_path TEXT,+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);--- Optionally add indexes for faster querying (if needed)--- CREATE INDEX idx_expiration_date ON warranties (expiration_date);--- CREATE INDEX idx_item_name ON warranties (item_name);\ No newline at end of file+CREATE INDEX idx_expiration_date ON warranties(expiration_date);+CREATE INDEX idx_product_name ON warranties(product_name);\ No newline at end of file