Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: notification name & namespace #1055

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading