All checks were successful
Deploy / changes (push) Successful in 5s
Deploy Trade-In / changes (push) Successful in 7s
Deploy / build-backend (push) Successful in 29s
Deploy / build-frontend (push) Successful in 28s
Deploy / build-worker (push) Successful in 29s
Deploy Trade-In / build-backend (push) Successful in 46s
Deploy / deploy (push) Successful in 58s
Deploy Trade-In / build-frontend (push) Successful in 1m40s
Deploy Trade-In / deploy (push) Successful in 39s
36 lines
1.7 KiB
PL/PgSQL
36 lines
1.7 KiB
PL/PgSQL
-- Migration 076: account_estimate_usage — квота оценок на аккаунт (#quota)
|
|
--
|
|
-- Хранит счётчик успешных оценок per (username, period_month).
|
|
-- period_month — строка 'YYYY-MM' (UTC). Лимит проверяется/инкрементится
|
|
-- в app.services.account_quota.
|
|
--
|
|
-- Idempotent: CREATE TABLE IF NOT EXISTS + существующие COMMENT переписываются
|
|
-- безопасно (COMMENT ON TABLE/COLUMN — DML, не DDL, не падает при повторе).
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS account_estimate_usage (
|
|
username text NOT NULL,
|
|
period_month text NOT NULL, -- 'YYYY-MM' (UTC)
|
|
used integer NOT NULL DEFAULT 0,
|
|
updated_at timestamptz NOT NULL DEFAULT NOW(),
|
|
PRIMARY KEY (username, period_month)
|
|
);
|
|
|
|
COMMENT ON TABLE account_estimate_usage IS
|
|
'Счётчик успешных оценок trade-in per (username, calendar month UTC). '
|
|
'Используется для применения лимита 15 оценок/месяц на pilot-аккаунтах.';
|
|
|
|
COMMENT ON COLUMN account_estimate_usage.username IS
|
|
'Имя пользователя из заголовка X-Authenticated-User (Caddy basic_auth).';
|
|
|
|
COMMENT ON COLUMN account_estimate_usage.period_month IS
|
|
'Календарный месяц UTC в формате YYYY-MM, напр. ''2026-05''.';
|
|
|
|
COMMENT ON COLUMN account_estimate_usage.used IS
|
|
'Количество успешных оценок в данном месяце.';
|
|
|
|
COMMENT ON COLUMN account_estimate_usage.updated_at IS
|
|
'Время последнего инкремента (UTC).';
|
|
|
|
COMMIT;
|