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 #142

Closed
wants to merge 3 commits into from
Closed
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
32 changes: 32 additions & 0 deletions .github/workflows/preview_core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://github.com/neondatabase/preview-branches-with-fly
on: [pull_request]
env:
NEON_PROJECT_ID: ${{ vars.NEON_PROJECT_ID }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
preview:
runs-on: ubuntu-latest
concurrency:
group: pr-${{ github.event.number }}
steps:
- uses: actions/checkout@v4
- id: branch-name
uses: tj-actions/branch-names@v8
- id: create-branch
uses: neondatabase/create-branch-action@v5
with:
project_id: ${{ env.NEON_PROJECT_ID }}
username: "canary_prod_owner"
branch_name: preview/${{ steps.branch-name.outputs.current_branch }}
api_key: ${{ secrets.NEON_API_KEY }}
- run: |
echo "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}" >> "$GITHUB_ENV"
- id: deploy
uses: superfly/fly-pr-review-apps@1.2.1
with:
secrets: DATABASE_URL=$DATABASE_URL
- uses: thollander/actions-comment-pull-request@v2
with:
message: |-
Fly Preview URL :balloon: : ${{ steps.deploy.outputs.url }}
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ env.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }}
16 changes: 16 additions & 0 deletions .github/workflows/preview_core_cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://github.com/neondatabase/preview-branches-with-fly
on:
pull_request:
types: [closed]
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: superfly/fly-pr-review-apps@1.2.0
- uses: neondatabase/delete-branch-action@v3.1.3
with:
project_id: ${{ var.NEON_PROJECT_ID }}
branch: preview/${{ github.event.pull_request.head.ref }}
api_key: ${{ secrets.NEON_API_KEY }}
3 changes: 1 addition & 2 deletions core/.formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
:ash,
:ash_phoenix,
:ash_postgres,
:ash_authentication,
:ash_archival
:ash_authentication
],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter],
Expand Down
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
12 changes: 1 addition & 11 deletions core/lib/canary/accounts/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule Canary.Accounts.Project do
use Ash.Resource,
domain: Canary.Accounts,
data_layer: AshPostgres.DataLayer,
extensions: [AshArchival.Resource],
authorizers: [Ash.Policy.Authorizer],
simple_notifiers: [Canary.Notifiers.Discord]

Expand All @@ -20,11 +19,6 @@ defmodule Canary.Accounts.Project do
identity :unique_public_key, [:public_key]
end

archive do
attribute :archived_at
exclude_read_actions [:read_all]
end

relationships do
belongs_to :account, Canary.Accounts.Account, allow_nil?: false
has_many :sources, Canary.Sources.Source
Expand All @@ -34,16 +28,12 @@ defmodule Canary.Accounts.Project do
actions do
defaults [:read]

read :read_all do
primary? false
end

create :create do
primary? true
accept [:account_id, :name]

change fn changeset, _ ->
key = "cp" <> String.slice(Ash.UUID.generate(), 0..7)
key = "cp_" <> String.slice(Ash.UUID.generate(), 0..7)

changeset
|> Ash.Changeset.force_change_attribute(:public_key, key)
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
3 changes: 1 addition & 2 deletions core/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ defmodule Canary.MixProject do
{:ex2ms, "~> 1.7"},
{:recon, "~> 2.5", override: true},
{:recon_ex,
github: "tatsuya6502/recon_ex", ref: "0ce4c5da777937a5bb57d3e68b9afcb9877c1c3b"},
{:ash_archival, "~> 1.0.4"}
github: "tatsuya6502/recon_ex", ref: "0ce4c5da777937a5bb57d3e68b9afcb9877c1c3b"}
] ++ deps_eval()
end

Expand Down
Loading
Loading