Files
mkd/backend/migrations/create_pr_attraction_actions.sql
2026-02-04 00:17:04 +05:00

20 lines
1.3 KiB
SQL
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- PR Привлечение: действия, которыми привлекали людей (рассылка, мероприятие, пост и т.д.)
CREATE TABLE IF NOT EXISTS pr_attraction_actions (
id BIGSERIAL PRIMARY KEY,
title TEXT NOT NULL,
description TEXT,
channel_id BIGINT REFERENCES pr_smm_channels(id) ON DELETE SET NULL,
action_type VARCHAR(20) NOT NULL CHECK (action_type IN ('mailing', 'event', 'post', 'other')),
action_date DATE NOT NULL DEFAULT CURRENT_DATE,
new_subscribers_attributed INT,
event_id BIGINT REFERENCES pr_events(id) ON DELETE SET NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_by TEXT
);
CREATE INDEX IF NOT EXISTS idx_pr_attraction_actions_channel ON pr_attraction_actions(channel_id);
CREATE INDEX IF NOT EXISTS idx_pr_attraction_actions_type ON pr_attraction_actions(action_type);
CREATE INDEX IF NOT EXISTS idx_pr_attraction_actions_date ON pr_attraction_actions(action_date DESC);
COMMENT ON TABLE pr_attraction_actions IS 'Действия привлечения: рассылка, мероприятие, пост и т.д., с приростом подписчиков';