CREATE TABLE notifications ( id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, user_id uuid NOT NULL, affected_module text, subject text NOT NULL, description text, metadata jsonb, created_at timestamptz NOT NULL DEFAULT now(), viewed_at timestamptz NULL, CONSTRAINT notifications_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE );