diff --git a/src/migrations/20230222154915-create-notiications-table.js b/src/migrations/20230222154915-create-notiications-table.js index c7a7130b7b..6207f47254 100644 --- a/src/migrations/20230222154915-create-notiications-table.js +++ b/src/migrations/20230222154915-create-notiications-table.js @@ -5,15 +5,15 @@ exports.up = function (db, cb) { ` CREATE TABLE IF NOT EXISTS notifications ( id SERIAL PRIMARY KEY, - event_id INTEGER NOT NULL REFERENCES events (id), - created_by INTEGER NOT NULL REFERENCES users (id), + event_id INTEGER NOT NULL REFERENCES events (id) ON DELETE CASCADE, + created_by INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now() ); CREATE TABLE if not exists user_notifications ( - notification_id INTEGER NOT NULL REFERENCES notifications (id), - user_id INTEGER NOT NULL REFERENCES users (id), + notification_id INTEGER NOT NULL REFERENCES notifications (id) ON DELETE CASCADE, + user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, read_at TIMESTAMP WITH TIME ZONE, PRIMARY KEY (notification_id, user_id) );