Skip to content

Commit

Permalink
fix: unique constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Apr 30, 2024
1 parent f7e5e80 commit d4d7cce
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions schema/agents.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ table "agents" {
index "agents_name_key" {
unique = true
columns = [column.name]
where = "deleted_at IS NULL"
}

foreign_key "agents_created_by_fkey" {
Expand Down
1 change: 1 addition & 0 deletions schema/checks.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ table "canaries" {
index "canaries_name_namespace_source_key" {
unique = true
columns = [column.agent_id, column.name, column.namespace, column.source]
where = "deleted_at IS NULL OR agent_id != 00000000-0000-0000-0000-000000000000"
}
index "canaries_is_pushed_idx" {
columns = [column.is_pushed]
Expand Down
1 change: 1 addition & 0 deletions schema/components.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ table "topologies" {
index "topologies_name_namespace_key" {
unique = true
columns = [column.agent_id, column.name, column.namespace]
where = "deleted_at IS NULL OR agent_id != 00000000-0000-0000-0000-000000000000"
}
index "topologies_is_pushed_idx" {
columns = [column.is_pushed]
Expand Down
1 change: 1 addition & 0 deletions schema/connections.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ table "connections" {
index "connections_name_namespace_key" {
unique = true
columns = [column.name, column.namespace]
where = "deleted_at IS NULL"
}
foreign_key "connections_created_by_fkey" {
columns = [column.created_by]
Expand Down
13 changes: 7 additions & 6 deletions schema/playbooks.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ table "playbooks" {
index "playbook_name_key" {
unique = true
columns = [column.name]
where = "deleted_at IS NULL OR agent_id != 00000000-0000-0000-0000-000000000000"
}
foreign_key "playbook_created_by_fkey" {
columns = [column.created_by]
Expand Down Expand Up @@ -169,9 +170,9 @@ table "playbook_runs" {
type = jsonb
}
column "agent_id" {
null = true
null = true
default = var.uuid_nil
type = uuid
type = uuid
}
column "error" {
null = true
Expand Down Expand Up @@ -227,13 +228,13 @@ table "playbook_action_agent_data" {
}
column "playbook_id" {
comment = "saves the linked upstream playbook id"
null = false
type = uuid
null = false
type = uuid
}
column "run_id" {
comment = "saves the linked upstream playbook run id"
null = false
type = uuid
null = false
type = uuid
}
column "spec" {
comment = "Action spec provided by upstream"
Expand Down
1 change: 1 addition & 0 deletions schema/teams.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ table "people" {
index "people_email_unique_idx" {
unique = true
columns = [column.email]
where = "deleted_at IS NULL"
}
index "people_external_id_idx" {
columns = [column.external_id]
Expand Down

0 comments on commit d4d7cce

Please sign in to comment.