Files
yourpart3/backend/migrations/20260716010000-create-push-notifications.sql
Torsten Schulz (local) 1ab9407e79
All checks were successful
Deploy to production / deploy (push) Successful in 2m56s
Refactor code structure for improved readability and maintainability; optimize performance across multiple modules.
2026-07-21 09:08:15 +02:00

25 lines
1.1 KiB
SQL

CREATE TABLE IF NOT EXISTS community.push_notification_device (
id BIGSERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES community."user"(id) ON DELETE CASCADE,
token TEXT NOT NULL UNIQUE,
platform VARCHAR(20) NOT NULL DEFAULT 'android',
enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT push_notification_device_platform_check CHECK (platform IN ('android'))
);
CREATE INDEX IF NOT EXISTS push_notification_device_user_enabled_idx
ON community.push_notification_device (user_id, enabled);
CREATE TABLE IF NOT EXISTS community.push_notification_setting (
user_id INTEGER PRIMARY KEY REFERENCES community."user"(id) ON DELETE CASCADE,
enabled BOOLEAN NOT NULL DEFAULT FALSE,
chat_enabled BOOLEAN NOT NULL DEFAULT TRUE,
friend_login_enabled BOOLEAN NOT NULL DEFAULT TRUE,
falukant_enabled BOOLEAN NOT NULL DEFAULT TRUE,
vocab_reminder_enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);