gohorsejobs/backend/migrations/016_create_notifications_table.sql
Tiago Yamamoto 568b4ebb88 refactor: clean up legacy UUID v4, use UUID v7 everywhere
Migrations:
- 016, 017, 019: Replace gen_random_uuid() with uuid_generate_v7()
- All UUID tables now use custom uuid_generate_v7() function

Backend:
- Create internal/utils/uuid/uuid.go with V7() function (RFC 9562)
- Update storage_handler.go to use internal uuid.V7()
- Remove dependency on google/uuid for file naming

All new UUIDs in the system are now UUID v7 (time-ordered)
2025-12-24 11:29:55 -03:00

14 lines
571 B
SQL

CREATE TABLE IF NOT EXISTS notifications (
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
type VARCHAR(50) NOT NULL, -- info, success, warning, error
title VARCHAR(255) NOT NULL,
message TEXT NOT NULL,
link TEXT,
read_at TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_notifications_user_id ON notifications(user_id);
CREATE INDEX idx_notifications_created_at ON notifications(created_at);