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

Set missing non-null constraints #146

Merged
merged 1 commit into from
Oct 20, 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
2 changes: 1 addition & 1 deletion core/lib/canary/accounts/billing.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Canary.Accounts.Billing do
end

relationships do
belongs_to :account, Canary.Accounts.Account
belongs_to :account, Canary.Accounts.Account, allow_nil?: false
end

calculations do
Expand Down
2 changes: 1 addition & 1 deletion core/lib/canary/accounts/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Canary.Accounts.User do
end

relationships do
belongs_to :account, Canary.Accounts.Account
belongs_to :account, Canary.Accounts.Account, allow_nil?: false

many_to_many :accounts, Canary.Accounts.Account do
through Canary.Accounts.AccountUser
Expand Down
2 changes: 1 addition & 1 deletion core/lib/canary/github/app.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Canary.Github.App do
end

relationships do
belongs_to :account, Canary.Accounts.Account
belongs_to :account, Canary.Accounts.Account, allow_nil?: false
has_many :repos, Canary.Github.Repo
end

Expand Down
4 changes: 2 additions & 2 deletions core/lib/canary/sources/document.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ defmodule Canary.Sources.Document do
uuid_primary_key :id
create_timestamp :created_at

attribute :index_id, :uuid, allow_nil?: true
attribute :index_id, :uuid, allow_nil?: false
attribute :meta, Canary.Type.DocumentMeta, allow_nil?: false
attribute :chunks, {:array, Canary.Sources.Chunk}, allow_nil?: false
end

relationships do
belongs_to :source, Canary.Sources.Source
belongs_to :source, Canary.Sources.Source, allow_nil?: false
end

actions do
Expand Down
47 changes: 47 additions & 0 deletions core/priv/repo/migrations/20241020110009_add_missing_non_null.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
defmodule Canary.Repo.Migrations.AddMissingNonNull do
@moduledoc """
Updates resources based on their most recent snapshots.

This file was autogenerated with `mix ash_postgres.generate_migrations`
"""

use Ecto.Migration

def up do
alter table(:users) do
modify :account_id, :uuid, null: false
end

alter table(:github_apps) do
modify :account_id, :uuid, null: false
end

alter table(:documents) do
modify :source_id, :uuid, null: false
modify :index_id, :uuid, null: false
end

alter table(:billings) do
modify :account_id, :uuid, null: false
end
end

def down do
alter table(:billings) do
modify :account_id, :uuid, null: true
end

alter table(:documents) do
modify :index_id, :uuid, null: true
modify :source_id, :uuid, null: true
end

alter table(:github_apps) do
modify :account_id, :uuid, null: true
end

alter table(:users) do
modify :account_id, :uuid, null: true
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"type": "bigint"
},
{
"allow_nil?": true,
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
Expand Down Expand Up @@ -85,7 +85,7 @@
"custom_indexes": [],
"custom_statements": [],
"has_create_action": true,
"hash": "FD28B0654BC49759BC9B939BDBD09B20A742FF144F4149BCC2AF78A4FE72FC3F",
"hash": "57ED3678A5CE98C319BE007B14A8A4633C6CC4A82B2685FA469F0E9902761284",
"identities": [],
"multitenancy": {
"attribute": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"type": "utc_datetime_usec"
},
{
"allow_nil?": true,
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
Expand Down Expand Up @@ -51,7 +51,7 @@
"type": ["array", "map"]
},
{
"allow_nil?": true,
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
Expand Down Expand Up @@ -85,7 +85,7 @@
"custom_indexes": [],
"custom_statements": [],
"has_create_action": true,
"hash": "574A39D3BDF92D9BCCDD3B528C78D15B1ACDC50645B19F6E619EAF95D7BCA1B0",
"hash": "BEF0A88021C81171A3E31B7CD8D5DE915085599E67B8246F7266D9AB5D009403",
"identities": [],
"multitenancy": {
"attribute": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"type": "bigint"
},
{
"allow_nil?": true,
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
Expand Down Expand Up @@ -55,7 +55,7 @@
"custom_indexes": [],
"custom_statements": [],
"has_create_action": true,
"hash": "F46116CD6F8A3AE84C1D92026D9A0657FC8EC83004C746B2C704FAF583FF9A9D",
"hash": "F0E9089AFBBB44AD28CBC3BDEC1B43D751DD42CD59F58586C76CC597E16B705A",
"identities": [],
"multitenancy": {
"attribute": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"type": "text"
},
{
"allow_nil?": true,
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
Expand Down Expand Up @@ -75,7 +75,7 @@
"custom_indexes": [],
"custom_statements": [],
"has_create_action": true,
"hash": "B07490F52CE7402A65E3F275FEAF5F4AA48543E4AC1E9B3FE6BB4E8C737044AE",
"hash": "3F15DD19F575C2BBAECACD7481BD178DA5C70D115647742DAB1DBFAE5AB2002B",
"identities": [
{
"all_tenants?": false,
Expand Down
Loading