feat: подписка на уведомление о поступлении товара

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 13:38:03 +03:00
parent 561fbd22e0
commit e2a7c79245
11 changed files with 313 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
-- Подписка «сообщить о поступлении»
CREATE TABLE IF NOT EXISTS product_stock_alerts (
id SERIAL PRIMARY KEY,
product_id INTEGER NOT NULL REFERENCES products(id) ON DELETE CASCADE,
email TEXT NOT NULL,
user_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
notified_at TIMESTAMPTZ,
UNIQUE (product_id, email)
);
CREATE INDEX IF NOT EXISTS idx_stock_alerts_product_pending
ON product_stock_alerts (product_id)
WHERE notified_at IS NULL;