Files
spsays-bff/migrations/0042_user_limit_overrides.up.sql
T
2026-06-23 14:21:45 +05:30

16 lines
799 B
SQL

-- Per-user save-limit overrides, set by admins from the panel. NULL means
-- "use the plan default" (free: 1 bookmark, 5 public + 5 private collections;
-- premium: 5 bookmarks, unlimited collections). A non-NULL value caps that
-- resource for this specific user, regardless of plan.
ALTER TABLE users
ADD COLUMN IF NOT EXISTS bookmark_limit INT,
ADD COLUMN IF NOT EXISTS public_collection_limit INT,
ADD COLUMN IF NOT EXISTS private_collection_limit INT;
ALTER TABLE users
ADD CONSTRAINT users_limit_overrides_nonneg CHECK (
(bookmark_limit IS NULL OR bookmark_limit >= 0) AND
(public_collection_limit IS NULL OR public_collection_limit >= 0) AND
(private_collection_limit IS NULL OR private_collection_limit >= 0)
);