Auto-count storefront page views with 6-month event retention and lifetime counters, track product visit/cart/sale stats, persist SSL cert expiry with daily probes, and support owner titles plus annual contract renewal. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.0 KiB
SQL
33 lines
1.0 KiB
SQL
-- Business annual renewal date + user honorific titles.
|
|
|
|
CREATE TABLE IF NOT EXISTS user_titles (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
slug VARCHAR(32) NOT NULL,
|
|
name_en VARCHAR(64) NOT NULL,
|
|
name_fa VARCHAR(64) NOT NULL,
|
|
sort_order INT NOT NULL DEFAULT 0,
|
|
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
CONSTRAINT user_titles_slug_unique UNIQUE (slug)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_titles_sort
|
|
ON user_titles (sort_order, id);
|
|
|
|
INSERT INTO user_titles (slug, name_en, name_fa, sort_order)
|
|
VALUES
|
|
('mr', 'Mr', 'آقای', 10),
|
|
('mrs', 'Mrs', 'خانم', 20),
|
|
('ms', 'Ms', 'خانم', 30),
|
|
('dr', 'Dr', 'دکتر', 40),
|
|
('eng', 'Eng.', 'مهندس', 50)
|
|
ON CONFLICT (slug) DO NOTHING;
|
|
|
|
ALTER TABLE users
|
|
ADD COLUMN IF NOT EXISTS title_id BIGINT REFERENCES user_titles (id) ON DELETE SET NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_users_title_id ON users (title_id);
|
|
|
|
ALTER TABLE businesses
|
|
ADD COLUMN IF NOT EXISTS annual_renewal_at TIMESTAMPTZ;
|