Skip to content

Commit

Permalink
feat: notification name & namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Sep 13, 2024
1 parent 7cd0b00 commit 0465074
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion models/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
// Notification represents the notifications table
type Notification struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Events pq.StringArray `json:"events" gorm:"type:[]text"`
Title string `json:"title,omitempty"`
Template string `json:"template,omitempty"`
Expand All @@ -20,7 +22,7 @@ type Notification struct {
TeamID *uuid.UUID `json:"team_id,omitempty"`
Properties types.JSONStringMap `json:"properties,omitempty"`
Source string `json:"source"`
RepeatInterval string `json:"repeat_interval"`
RepeatInterval string `json:"repeat_interval,omitempty"`
GroupBy pq.StringArray `json:"group_by" gorm:"type:[]text"`
CustomServices types.JSON `json:"custom_services,omitempty" gorm:"column:custom_services"`
CreatedBy *uuid.UUID `json:"created_by,omitempty"`
Expand Down
14 changes: 14 additions & 0 deletions schema/notifications.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ table "notifications" {
type = uuid
default = sql("generate_ulid()")
}
column "name" {
null = false
type = text
default = sql("generate_ulid()") # temporary default value to make the migration possible. we can remove this later.
}
column "namespace" {
null = true
type = text
}
column "events" {
null = false
type = sql("text[]")
Expand Down Expand Up @@ -99,6 +108,11 @@ table "notifications" {
on_update = NO_ACTION
on_delete = CASCADE
}
index "notifications_name_namespace_key" {
unique = true
columns = [column.name, column.namespace]
where = "deleted_at IS NULL"
}
}

table "notification_send_history" {
Expand Down
2 changes: 2 additions & 0 deletions views/015_job_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ WITH notification_send_summary AS (
)
SELECT
notifications.id,
notifications.name,
notifications.namespace,
notifications.title,
notifications.events,
notifications.filter,
Expand Down

0 comments on commit 0465074

Please sign in to comment.