20 lines
646 B
SQL
20 lines
646 B
SQL
-- +goose Up
|
|
-- +goose StatementBegin
|
|
CREATE TABLE notifications (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
title TEXT NOT NULL,
|
|
body TEXT,
|
|
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_notifications_user_id ON notifications(user_id);
|
|
CREATE INDEX idx_notifications_user_unread ON notifications(user_id) WHERE is_read = FALSE;
|
|
-- +goose StatementEnd
|
|
|
|
-- +goose Down
|
|
-- +goose StatementBegin
|
|
DROP TABLE IF EXISTS notifications;
|
|
-- +goose StatementEnd
|