mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-14 00:19:16 +01:00
33 lines
961 B
JavaScript
33 lines
961 B
JavaScript
|
'use strict';
|
||
|
|
||
|
exports.up = function (db, cb) {
|
||
|
db.runSql(
|
||
|
`
|
||
|
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),
|
||
|
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),
|
||
|
read_at TIMESTAMP WITH TIME ZONE,
|
||
|
PRIMARY KEY (notification_id, user_id)
|
||
|
);
|
||
|
`,
|
||
|
cb,
|
||
|
);
|
||
|
};
|
||
|
|
||
|
exports.down = function (db, cb) {
|
||
|
db.runSql(
|
||
|
`
|
||
|
DROP TABLE IF EXISTS notifications;
|
||
|
DROP TABLE IF EXISTS user_notifications;`,
|
||
|
cb,
|
||
|
);
|
||
|
};
|