Skip to content
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 .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, [exit_status: 2]},
{Credo.Check.Design.TagTODO, false},
{Credo.Check.Design.TagFIXME, []},

#
Expand Down
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE IS AUTOGENERATED USING `mix ash.formatter`
# DONT MODIFY IT BY HAND
locals_without_parens = [repo: 1, table: 1]
locals_without_parens = [migrate?: 1, repo: 1, table: 1]

[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
ash_postgres-*.tar

test_migration_path
test_snapshots_path

2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if Mix.env() == :test do

config :ash_postgres, AshPostgres.TestRepo,
username: "postgres",
database: "postgres",
database: "ash_postgres_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox

Expand Down
5 changes: 5 additions & 0 deletions lib/ash_postgres.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ defmodule AshPostgres do
def table(resource) do
Extension.get_opt(resource, [:postgres], :table, nil, true)
end

@doc "Whether or not the resource should be included when generating migrations"
def migrate?(resource) do
Extension.get_opt(resource, [:postgres], :migrate?, nil, true)
end
end
11 changes: 7 additions & 4 deletions lib/data_layer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ defmodule AshPostgres.DataLayer do
doc:
"The repo that will be used to fetch your data. See the `AshPostgres.Repo` documentation for more"
],
migrate?: [
type: :boolean,
default: true,
doc:
"Whether or not to include this resource in the generated migrations with `mix ash.generate_migrations`"
],
table: [
type: :string,
required: true,
Expand All @@ -44,7 +50,6 @@ defmodule AshPostgres.DataLayer do
]
}

alias Ash.DataLayer.Delegate
alias Ash.Filter
alias Ash.Filter.{Expression, Not, Predicate}
alias Ash.Filter.Predicate.{Eq, GreaterThan, In, IsNil, LessThan}
Expand Down Expand Up @@ -91,14 +96,12 @@ defmodule AshPostgres.DataLayer do
def can?(_, :upsert), do: true

def can?(resource, {:join, other_resource}) do
other_resource = Delegate.get_delegated(other_resource)
data_layer = Ash.Resource.data_layer(resource)
other_data_layer = Ash.Resource.data_layer(other_resource)
data_layer == other_data_layer and repo(data_layer) == repo(other_data_layer)
end

def can?(resource, {:lateral_join, other_resource}) do
other_resource = Delegate.get_delegated(other_resource)
data_layer = Ash.Resource.data_layer(resource)
other_data_layer = Ash.Resource.data_layer(other_resource)
data_layer == other_data_layer and repo(data_layer) == repo(other_data_layer)
Expand Down Expand Up @@ -1121,6 +1124,6 @@ defmodule AshPostgres.DataLayer do
end

defp maybe_get_resource_query(resource) do
{table(Delegate.get_delegated(resource)), resource}
{table(resource), resource}
end
end
Loading