Add product price history model and database schema: Implement associations for ProductPriceHistory with ProductType and RegionData. Update FalukantService to utilize active character for user-related operations. Ensure product price history table exists in the database with appropriate structure and indexing.

This commit is contained in:
Torsten Schulz (local)
2026-02-04 09:02:51 +01:00
parent ce34bae16a
commit 14775eb556
5 changed files with 80 additions and 8 deletions

View File

@@ -539,6 +539,27 @@ const syncDatabase = async () => {
console.warn('⚠️ relationship_change_log/Trigger konnten nicht sichergestellt werden:', e?.message || e);
}
// Preishistorie für Produkte (Zeitreihe) nur Schema/Struktur, noch ohne Logik
console.log("Ensuring falukant_log.product_price_history exists...");
try {
await sequelize.query(`
CREATE TABLE IF NOT EXISTS falukant_log.product_price_history (
id serial PRIMARY KEY,
product_id integer NOT NULL,
region_id integer NOT NULL,
price numeric(12,2) NOT NULL,
recorded_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
);
`);
await sequelize.query(`
CREATE INDEX IF NOT EXISTS product_price_history_product_region_recorded_idx
ON falukant_log.product_price_history (product_id, region_id, recorded_at);
`);
console.log("✅ product_price_history ist vorhanden.");
} catch (e) {
console.warn('⚠️ product_price_history konnte nicht sichergestellt werden:', e?.message || e);
}
// Vorab: Stelle kritische Spalten sicher, damit Index-Erstellung nicht fehlschlägt
console.log("Pre-ensure Taxi columns (traffic_light) ...");
try {