Make some notifications be scoped to certain orgs to prevent redirect

issues.
This commit is contained in:
x032205
2025-09-05 22:39:47 -04:00
parent ad42fb4721
commit 67b02612ed
9 changed files with 54 additions and 13 deletions
@@ -9,6 +9,7 @@ export async function up(knex: Knex): Promise<void> {
.createTable(TableName.UserNotifications, (t) => {
t.uuid("id").defaultTo(knex.fn.uuid());
t.uuid("userId").notNullable();
t.uuid("orgId").nullable();
t.string("type").notNullable();
t.string("title").notNullable(); // Markdown
@@ -32,10 +33,11 @@ export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable(TableName.UserNotifications, (t) => {
t.foreign("userId").references("id").inTable(TableName.Users).onDelete("CASCADE");
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
t.index("type");
t.index(["userId", "isRead"]);
t.index(["userId", "createdAt"]);
t.index(["userId", "createdAt", "orgId"]);
});
await createOnUpdateTrigger(knex, TableName.UserNotifications);