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

Improve ash setup #650

Merged
merged 8 commits into from
Nov 6, 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 demo/.formatter.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
line_length: 120,
import_deps: [:ecto, :phoenix, :backpex, :ash, :ash_postgres],
plugins: [TailwindFormatter, Phoenix.LiveView.HTMLFormatter],
plugins: [Spark.Formatter, TailwindFormatter, Phoenix.LiveView.HTMLFormatter],
inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
subdirectories: ["priv/*/migrations"]
]
29 changes: 27 additions & 2 deletions demo/config/config.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
import Config

config :spark,
formatter: [
remove_parens?: true,
"Ash.Resource": [
section_order: [
:postgres,
:resource,
:code_interface,
:actions,
:policies,
:pub_sub,
:preparations,
:changes,
:validations,
:multitenancy,
:attributes,
:relationships,
:calculations,
:aggregates,
:identities
]
],
"Ash.Domain": [section_order: [:resources, :policies, :authorization, :domain, :execution]]
]

config :demo,
namespace: Demo,
ecto_repos: [Demo.Repo, Demo.RepoAsh],
ecto_repos: [Demo.Repo],
ash_domains: [Demo.Helpdesk],
generators: [binary_id: true]

Expand Down Expand Up @@ -49,7 +74,7 @@ config :phoenix, :json_library, Jason

config :demo, DemoWeb.Gettext, default_locale: "en"

config :ash, include_embedded_source_by_default?: false
config :ash, include_embedded_source_by_default?: false, default_page_type: :keyset

config :ash, :policies, no_filter_static_forbidden_reads?: false

Expand Down
8 changes: 0 additions & 8 deletions demo/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ config :demo, Demo.Repo,
port: get_env("DB_PORT", "5432") |> to_integer(),
pool_size: get_env("DB_POOL_SIZE", "5") |> to_integer()

config :demo, Demo.RepoAsh,
hostname: get_env("DB_HOSTNAME", "postgres"),
username: get_env("DB_USERNAME", "postgres"),
password: get_env("DB_PASSWORD", "postgres"),
database: get_env("DB_DATABASE", "postgres"),
port: get_env("DB_PORT", "5432") |> to_integer(),
pool_size: get_env("DB_POOL_SIZE", "5") |> to_integer()

config :demo, DemoWeb.Endpoint,
http: [
port: get_env("PORT", "4000") |> to_integer()
Expand Down
1 change: 0 additions & 1 deletion demo/lib/demo/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ defmodule Demo.Application do
{Cluster.Supervisor, [topologies, [name: Sourceboat.ClusterSupervisor]]},
{Phoenix.PubSub, name: Demo.PubSub},
Demo.Repo,
Demo.RepoAsh,
DemoWeb.Telemetry,
{DemoWeb.MetricsStorage, DemoWeb.Telemetry.metrics()},
DemoWeb.Endpoint
Expand Down
2 changes: 1 addition & 1 deletion demo/lib/demo/helpdesk/ticket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Demo.Helpdesk.Ticket do
data_layer: AshPostgres.DataLayer

postgres do
repo Demo.RepoAsh
repo Demo.Repo
table "tickets"
end

Expand Down
9 changes: 2 additions & 7 deletions demo/lib/demo/repo.ex
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
defmodule Demo.Repo do
use Ecto.Repo,
otp_app: :demo,
adapter: Ecto.Adapters.Postgres
end

defmodule Demo.RepoAsh do
use AshPostgres.Repo, otp_app: :demo
use AshPostgres.Repo,
otp_app: :demo

def installed_extensions do
["ash-functions"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Demo.RepoAsh.Migrations.InstallAshFunctionsExtension320241022065648 do
defmodule Demo.Repo.Migrations.InstallAshFunctionsExtension320241022065648 do
@moduledoc """
Installs any extensions that are mentioned in the repo's `installed_extensions/0` callback

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Demo.RepoAsh.Migrations.CreateTicket do
defmodule Demo.Repo.Migrations.CreateTicket do
@moduledoc """
Updates resources based on their most recent snapshots.

Expand Down
5 changes: 0 additions & 5 deletions demo/priv/repo_ash/migrations/.formatter.exs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
}
],
"table": "tickets",
"hash": "E3E87D7112A09D07945C96CD8FD2DAFD892CB07B82C9A14F42CE4D29C6DF1894",
"repo": "Elixir.Demo.RepoAsh",
"hash": "9B5D9315CFB3750457FCF436EF56A515A5539855FE2669BA3DD7AD7A3CC29DC7",
"repo": "Elixir.Demo.Repo",
"identities": [],
"schema": null,
"multitenancy": {
"global": null,
"strategy": null,
"attribute": null
"attribute": null,
"strategy": null
},
"base_filter": null,
"check_constraints": [],
Expand Down
Loading