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

Commite2eb2d4

Browse files
committed
improvement: only count resources w/ create action for nullability
1 parentdc628c3 commite2eb2d4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

‎lib/migration_generator/migration_generator.ex‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ defmodule AshPostgres.MigrationGenerator do
199199
{primary_key,identities}=merge_primary_keys(existing_snapshot,snapshots)
200200

201201
attributes=Enum.flat_map(snapshots,&&1.attributes)
202-
count=Enum.count(snapshots)
202+
203+
count_with_create=
204+
snapshots
205+
|>Enum.filter(&&1.has_create_action)
206+
|>Enum.count()
203207

204208
snapshot_identities=
205209
snapshots
@@ -208,7 +212,7 @@ defmodule AshPostgres.MigrationGenerator do
208212

209213
new_snapshot=%{
210214
snapshot
211-
|attributes:merge_attributes(attributes,snapshot.table,count),
215+
|attributes:merge_attributes(attributes,snapshot.table,count_with_create),
212216
identities:snapshot_identities
213217
}
214218

@@ -1228,7 +1232,8 @@ defmodule AshPostgres.MigrationGenerator do
12281232
table:table||AshPostgres.table(resource),
12291233
repo:AshPostgres.repo(resource),
12301234
multitenancy:multitenancy(resource),
1231-
base_filter:AshPostgres.base_filter_sql(resource)
1235+
base_filter:AshPostgres.base_filter_sql(resource),
1236+
has_create_action:has_create_action?(resource)
12321237
}
12331238

12341239
hash=
@@ -1239,6 +1244,12 @@ defmodule AshPostgres.MigrationGenerator do
12391244
Map.put(snapshot,:hash,hash)
12401245
end
12411246

1247+
defphas_create_action?(resource)do
1248+
resource
1249+
|>Ash.Resource.Info.actions()
1250+
|>Enum.any?(&(&1.type==:create))
1251+
end
1252+
12421253
defpmultitenancy(resource)do
12431254
strategy=Ash.Resource.Info.multitenancy_strategy(resource)
12441255
attribute=Ash.Resource.Info.multitenancy_attribute(resource)
@@ -1382,6 +1393,7 @@ defmodule AshPostgres.MigrationGenerator do
13821393
defpload_snapshot(json)do
13831394
json
13841395
|>Jason.decode!(keys::atoms!)
1396+
|>Map.put_new(:has_create_action,true)
13851397
|>Map.update!(:identities,fnidentities->
13861398
Enum.map(identities,&load_identity/1)
13871399
end)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp