Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24b743d

Browse files
authored
feat: snapshot-based migration generator
1 parent60c18dd commit24b743d

25 files changed

+1765
-93
lines changed

‎.credo.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
# If you don't want TODO comments to cause `mix credo` to fail, just
8888
# set this value to 0 (zero).
8989
#
90-
{Credo.Check.Design.TagTODO,[exit_status:2]},
90+
{Credo.Check.Design.TagTODO,false},
9191
{Credo.Check.Design.TagFIXME,[]},
9292

9393
#

‎.formatter.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE IS AUTOGENERATED USING `mix ash.formatter`
22
# DONT MODIFY IT BY HAND
3-
locals_without_parens=[repo:1,table:1]
3+
locals_without_parens=[migrate?:1,repo:1,table:1]
44

55
[
66
inputs:["{mix,.formatter}.exs","{config,lib,test}/**/*.{ex,exs}"],

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ erl_crash.dump
2222
# Ignore package tarball (built via "mix hex.build").
2323
ash_postgres-*.tar
2424

25+
test_migration_path
26+
test_snapshots_path
27+

‎config/config.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if Mix.env() == :test do
2020

2121
config:ash_postgres,AshPostgres.TestRepo,
2222
username:"postgres",
23-
database:"postgres",
23+
database:"ash_postgres_test",
2424
hostname:"localhost",
2525
pool:Ecto.Adapters.SQL.Sandbox
2626

‎lib/ash_postgres.ex‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ defmodule AshPostgres do
1818
deftable(resource)do
1919
Extension.get_opt(resource,[:postgres],:table,nil,true)
2020
end
21+
22+
@doc"Whether or not the resource should be included when generating migrations"
23+
defmigrate?(resource)do
24+
Extension.get_opt(resource,[:postgres],:migrate?,nil,true)
25+
end
2126
end

‎lib/data_layer.ex‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ defmodule AshPostgres.DataLayer do
3636
doc:
3737
"The repo that will be used to fetch your data. See the `AshPostgres.Repo` documentation for more"
3838
],
39+
migrate?:[
40+
type::boolean,
41+
default:true,
42+
doc:
43+
"Whether or not to include this resource in the generated migrations with `mix ash.generate_migrations`"
44+
],
3945
table:[
4046
type::string,
4147
required:true,
@@ -44,7 +50,6 @@ defmodule AshPostgres.DataLayer do
4450
]
4551
}
4652

47-
aliasAsh.DataLayer.Delegate
4853
aliasAsh.Filter
4954
aliasAsh.Filter.{Expression,Not,Predicate}
5055
aliasAsh.Filter.Predicate.{Eq,GreaterThan,In,IsNil,LessThan}
@@ -91,14 +96,12 @@ defmodule AshPostgres.DataLayer do
9196
defcan?(_,:upsert),do:true
9297

9398
defcan?(resource,{:join,other_resource})do
94-
other_resource=Delegate.get_delegated(other_resource)
9599
data_layer=Ash.Resource.data_layer(resource)
96100
other_data_layer=Ash.Resource.data_layer(other_resource)
97101
data_layer==other_data_layerandrepo(data_layer)==repo(other_data_layer)
98102
end
99103

100104
defcan?(resource,{:lateral_join,other_resource})do
101-
other_resource=Delegate.get_delegated(other_resource)
102105
data_layer=Ash.Resource.data_layer(resource)
103106
other_data_layer=Ash.Resource.data_layer(other_resource)
104107
data_layer==other_data_layerandrepo(data_layer)==repo(other_data_layer)
@@ -1121,6 +1124,6 @@ defmodule AshPostgres.DataLayer do
11211124
end
11221125

11231126
defpmaybe_get_resource_query(resource)do
1124-
{table(Delegate.get_delegated(resource)),resource}
1127+
{table(resource),resource}
11251128
end
11261129
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp