mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Ready for release 1.1.4
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
ALTER TABLE "notification_log" DROP CONSTRAINT "notification_log_channel_id_notification_channel_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "notification_log" DROP CONSTRAINT "notification_log_policy_id_alert_policy_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "notification_log" DROP CONSTRAINT "notification_log_organization_id_organization_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "notification_log" ADD COLUMN "event" text;--> statement-breakpoint
|
||||
ALTER TABLE "notification_log" ADD COLUMN "provider" text NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "notification_log" ADD COLUMN "provider_name" text NOT NULL;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,13 @@
|
||||
"when": 1764497732581,
|
||||
"tag": "0010_past_trauma",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 11,
|
||||
"version": "7",
|
||||
"when": 1765097874110,
|
||||
"tag": "0011_outgoing_blob",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import {boolean, pgEnum, pgTable, uuid} from "drizzle-orm/pg-core";
|
||||
import {notificationChannel} from "@/db/schema/09_notification-channel";
|
||||
import {timestamps} from "@/db/schema/00_common";
|
||||
import {relations} from "drizzle-orm";
|
||||
import {database, retentionPolicy} from "@/db/schema/07_database";
|
||||
import {database} from "@/db/schema/07_database";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
|
||||
@@ -32,9 +32,7 @@ export const alertPolicyRelations = relations(alertPolicy, ({one}) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const notificationChannelsToAlertPoliciesRelations = relations(notificationChannel, ({many}) => ({
|
||||
alertPolicies: many(alertPolicy),
|
||||
}));
|
||||
|
||||
|
||||
|
||||
export const alertPolicySchema = createSelectSchema(alertPolicy);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {pgTable, uuid, timestamp, jsonb, varchar, boolean, text, pgEnum} from 'drizzle-orm/pg-core';
|
||||
import {notificationChannel} from "@/db/schema/09_notification-channel";
|
||||
import {alertPolicy} from "@/db/schema/10_alert-policy";
|
||||
import {organization} from "@/db/schema/03_organization";
|
||||
import {timestamps} from "@/db/schema/00_common";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {relations} from "drizzle-orm";
|
||||
|
||||
|
||||
export const levelEnum = pgEnum('level', ['critical', 'warning', 'info']);
|
||||
@@ -13,13 +13,13 @@ export const levelEnum = pgEnum('level', ['critical', 'warning', 'info']);
|
||||
export const notificationLog = pgTable('notification_log', {
|
||||
id: uuid('id').defaultRandom().primaryKey(),
|
||||
|
||||
channelId: uuid('channel_id')
|
||||
.notNull()
|
||||
.references(() => notificationChannel.id, {onDelete: 'restrict'}),
|
||||
policyId: uuid('policy_id')
|
||||
.references(() => alertPolicy.id, {onDelete: 'restrict'}),
|
||||
organizationId: uuid('organization_id')
|
||||
.references(() => organization.id, {onDelete: 'set null'}),
|
||||
channelId: uuid('channel_id').notNull(),
|
||||
policyId: uuid('policy_id'),
|
||||
organizationId: uuid('organization_id'),
|
||||
|
||||
event: text("event"),
|
||||
provider: text("provider").notNull(),
|
||||
providerName: text("provider_name").notNull(),
|
||||
|
||||
title: varchar('title', {length: 255}).notNull(),
|
||||
message: text('message').notNull(),
|
||||
@@ -35,6 +35,11 @@ export const notificationLog = pgTable('notification_log', {
|
||||
...timestamps
|
||||
});
|
||||
|
||||
|
||||
export const notificationChannelsToAlertPoliciesRelations = relations(notificationChannel, ({many}) => ({
|
||||
alertPolicies: many(alertPolicy),
|
||||
}));
|
||||
|
||||
export const notificationLogSchema = createSelectSchema(notificationLog);
|
||||
export type NotificationLog = z.infer<typeof notificationLogSchema>;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import {and, desc, eq, gte, lte} from 'drizzle-orm';
|
||||
import {NotificationLevel, notificationLog} from "@/db/schema/11_notification-log";
|
||||
import {notificationChannel} from "@/db/schema/09_notification-channel";
|
||||
import {db} from "@/db";
|
||||
import {alertPolicy} from "@/db/schema/10_alert-policy";
|
||||
import {Json} from "drizzle-zod";
|
||||
|
||||
export type NotificationLogWithRelations = {
|
||||
@@ -18,13 +17,11 @@ export type NotificationLogWithRelations = {
|
||||
message: string;
|
||||
},
|
||||
channel: {
|
||||
id: string;
|
||||
name: string;
|
||||
provider: string;
|
||||
} | null;
|
||||
policy: {
|
||||
id: string;
|
||||
eventKinds: string[];
|
||||
event: string | null;
|
||||
} | null;
|
||||
};
|
||||
|
||||
@@ -63,18 +60,16 @@ export async function getNotificationHistory(
|
||||
message: notificationLog.message,
|
||||
},
|
||||
channel: {
|
||||
id: notificationChannel.id,
|
||||
name: notificationChannel.name,
|
||||
provider: notificationChannel.provider,
|
||||
name: notificationLog.providerName,
|
||||
provider: notificationLog.provider,
|
||||
},
|
||||
policy: {
|
||||
id: alertPolicy.id,
|
||||
eventKinds: alertPolicy.eventKinds,
|
||||
event: notificationLog.event,
|
||||
},
|
||||
})
|
||||
.from(notificationLog)
|
||||
.leftJoin(notificationChannel, eq(notificationLog.channelId, notificationChannel.id))
|
||||
.leftJoin(alertPolicy, eq(notificationLog.policyId, alertPolicy.id))
|
||||
// .leftJoin(alertPolicy, eq(notificationLog.policyId, alertPolicy.id))
|
||||
.where(and(...where))
|
||||
.orderBy(desc(notificationLog.sentAt))
|
||||
.limit(filters?.limit || 100);
|
||||
|
||||
Reference in New Issue
Block a user