Skip to content

Commit

Permalink
Feat/notifications table (#3184)
Browse files Browse the repository at this point in the history
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Creates the `notifications` table and a `user_notifications` join table 

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #
[1-720](https://linear.app/unleash/issue/1-720/db-table-for-notifications-and-real-store-with-link-to-event-store-to)

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
  • Loading branch information
andreas-unleash committed Feb 23, 2023
1 parent 8b95eab commit 194c07e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/migrations/20230222154915-create-notiications-table.js
@@ -0,0 +1,32 @@
'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,
);
};

0 comments on commit 194c07e

Please sign in to comment.