Skip to content

Commit 1098385

Browse files
committed
chore: update tests/migrations
1 parent 64740ba commit 1098385

File tree

8 files changed

+289
-2
lines changed

8 files changed

+289
-2
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"attributes": [
3+
{
4+
"allow_nil?": false,
5+
"default": "fragment(\"uuid_generate_v7()\")",
6+
"generated?": false,
7+
"primary_key?": true,
8+
"references": null,
9+
"size": null,
10+
"source": "id",
11+
"type": "uuid"
12+
},
13+
{
14+
"allow_nil?": true,
15+
"default": "nil",
16+
"generated?": false,
17+
"primary_key?": false,
18+
"references": null,
19+
"size": null,
20+
"source": "key",
21+
"type": "text"
22+
},
23+
{
24+
"allow_nil?": false,
25+
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
26+
"generated?": false,
27+
"primary_key?": false,
28+
"references": null,
29+
"size": null,
30+
"source": "inserted_at",
31+
"type": "utc_datetime_usec"
32+
},
33+
{
34+
"allow_nil?": false,
35+
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
36+
"generated?": false,
37+
"primary_key?": false,
38+
"references": null,
39+
"size": null,
40+
"source": "updated_at",
41+
"type": "utc_datetime_usec"
42+
}
43+
],
44+
"base_filter": null,
45+
"check_constraints": [],
46+
"custom_indexes": [],
47+
"custom_statements": [],
48+
"has_create_action": true,
49+
"hash": "571E95D3DAC0A3C7446601D96857C70384A20159928EE335D3A421FA61555158",
50+
"identities": [],
51+
"multitenancy": {
52+
"attribute": null,
53+
"global": null,
54+
"strategy": null
55+
},
56+
"repo": "Elixir.AshPostgres.TestRepo",
57+
"schema": null,
58+
"table": "items"
59+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"attributes": [
3+
{
4+
"allow_nil?": false,
5+
"default": "fragment(\"uuid_generate_v7()\")",
6+
"generated?": false,
7+
"primary_key?": true,
8+
"references": null,
9+
"size": null,
10+
"source": "id",
11+
"type": "uuid"
12+
},
13+
{
14+
"allow_nil?": false,
15+
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
16+
"generated?": false,
17+
"primary_key?": false,
18+
"references": null,
19+
"size": null,
20+
"source": "inserted_at",
21+
"type": "utc_datetime_usec"
22+
},
23+
{
24+
"allow_nil?": false,
25+
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
26+
"generated?": false,
27+
"primary_key?": false,
28+
"references": null,
29+
"size": null,
30+
"source": "updated_at",
31+
"type": "utc_datetime_usec"
32+
},
33+
{
34+
"allow_nil?": false,
35+
"default": "nil",
36+
"generated?": false,
37+
"primary_key?": false,
38+
"references": {
39+
"deferrable": false,
40+
"destination_attribute": "id",
41+
"destination_attribute_default": null,
42+
"destination_attribute_generated": null,
43+
"index?": true,
44+
"match_type": null,
45+
"match_with": null,
46+
"multitenancy": {
47+
"attribute": null,
48+
"global": null,
49+
"strategy": null
50+
},
51+
"name": "other_items_item_id_fkey",
52+
"on_delete": "delete",
53+
"on_update": null,
54+
"primary_key?": true,
55+
"schema": "public",
56+
"table": "items"
57+
},
58+
"size": null,
59+
"source": "item_id",
60+
"type": "uuid"
61+
}
62+
],
63+
"base_filter": null,
64+
"check_constraints": [],
65+
"custom_indexes": [],
66+
"custom_statements": [],
67+
"has_create_action": true,
68+
"hash": "43CBB861ACD2A789B2871FAF147C4480E7854D422D70213A4DB321CECC68A203",
69+
"identities": [
70+
{
71+
"all_tenants?": false,
72+
"base_filter": null,
73+
"index_name": "other_items_unique_parent_index",
74+
"keys": [
75+
{
76+
"type": "atom",
77+
"value": "item_id"
78+
}
79+
],
80+
"name": "unique_parent",
81+
"nils_distinct?": true,
82+
"where": null
83+
}
84+
],
85+
"multitenancy": {
86+
"attribute": null,
87+
"global": null,
88+
"strategy": null
89+
},
90+
"repo": "Elixir.AshPostgres.TestRepo",
91+
"schema": null,
92+
"table": "other_items"
93+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"attributes": [
3+
{
4+
"allow_nil?": false,
5+
"default": "fragment(\"uuid_generate_v7()\")",
6+
"generated?": false,
7+
"primary_key?": true,
8+
"references": null,
9+
"size": null,
10+
"source": "id",
11+
"type": "uuid"
12+
},
13+
{
14+
"allow_nil?": false,
15+
"default": "nil",
16+
"generated?": false,
17+
"primary_key?": false,
18+
"references": null,
19+
"size": null,
20+
"source": "key",
21+
"type": "text"
22+
},
23+
{
24+
"allow_nil?": false,
25+
"default": "nil",
26+
"generated?": false,
27+
"primary_key?": false,
28+
"references": null,
29+
"size": null,
30+
"source": "value",
31+
"type": "bigint"
32+
},
33+
{
34+
"allow_nil?": false,
35+
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
36+
"generated?": false,
37+
"primary_key?": false,
38+
"references": null,
39+
"size": null,
40+
"source": "inserted_at",
41+
"type": "utc_datetime_usec"
42+
},
43+
{
44+
"allow_nil?": false,
45+
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
46+
"generated?": false,
47+
"primary_key?": false,
48+
"references": null,
49+
"size": null,
50+
"source": "updated_at",
51+
"type": "utc_datetime_usec"
52+
}
53+
],
54+
"base_filter": null,
55+
"check_constraints": [],
56+
"custom_indexes": [],
57+
"custom_statements": [],
58+
"has_create_action": true,
59+
"hash": "FC7547C74057DE3A87306D14A0AD1621D9BE7812D8BF94D68D8B319C5AA84C55",
60+
"identities": [],
61+
"multitenancy": {
62+
"attribute": null,
63+
"global": null,
64+
"strategy": null
65+
},
66+
"repo": "Elixir.AshPostgres.TestRepo",
67+
"schema": null,
68+
"table": "relationship_items"
69+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
defmodule AshPostgres.TestRepo.Migrations.MigrateResources36 do
2+
@moduledoc """
3+
Updates resources based on their most recent snapshots.
4+
5+
This file was autogenerated with `mix ash_postgres.generate_migrations`
6+
"""
7+
8+
use Ecto.Migration
9+
10+
def up do
11+
create(unique_index(:other_items, [:item_id], name: "other_items_unique_parent_index"))
12+
end
13+
14+
def down do
15+
drop_if_exists(
16+
unique_index(:other_items, [:item_id], name: "other_items_unique_parent_index")
17+
)
18+
end
19+
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
defmodule AshPostgres.TestRepo.Migrations.MigrateResources37 do
2+
@moduledoc """
3+
Updates resources based on their most recent snapshots.
4+
5+
This file was autogenerated with `mix ash_postgres.generate_migrations`
6+
"""
7+
8+
use Ecto.Migration
9+
10+
def up do
11+
create table(:relationship_items, primary_key: false) do
12+
add(:id, :uuid, null: false, default: fragment("uuid_generate_v7()"), primary_key: true)
13+
add(:key, :text, null: false)
14+
add(:value, :bigint, null: false)
15+
16+
add(:inserted_at, :utc_datetime_usec,
17+
null: false,
18+
default: fragment("(now() AT TIME ZONE 'utc')")
19+
)
20+
21+
add(:updated_at, :utc_datetime_usec,
22+
null: false,
23+
default: fragment("(now() AT TIME ZONE 'utc')")
24+
)
25+
end
26+
27+
alter table(:items) do
28+
remove(:value)
29+
end
30+
end
31+
32+
def down do
33+
alter table(:items) do
34+
add(:value, :bigint)
35+
end
36+
37+
drop(table(:relationship_items))
38+
end
39+
end

test/multi_domain_calculations_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ defmodule AshPostgres.Test.MultiDomainCalculationsTest do
3232
|> Ash.Changeset.for_create(:create, %{key: "key"})
3333
|> Ash.create!()
3434

35+
Ash.read!(AshPostgres.Test.MultiDomainCalculations.DomainOne.Item,
36+
load: [:total_amount_relationship]
37+
)
38+
3539
_relationship_item =
3640
AshPostgres.Test.MultiDomainCalculations.DomainThree.RelationshipItem
3741
|> Ash.Changeset.for_create(:create, %{key: "key", value: 1})
@@ -48,7 +52,7 @@ defmodule AshPostgres.Test.MultiDomainCalculationsTest do
4852
|> Ash.create!()
4953
end
5054

51-
assert [%{total_amount: 3}] =
55+
assert [%{total_amount_relationship: 3}] =
5256
Ash.read!(AshPostgres.Test.MultiDomainCalculations.DomainOne.Item,
5357
load: [:total_amount_relationship]
5458
)

test/support/multi_domain_calculations/domain_three/relationship_item.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule AshPostgres.Test.MultiDomainCalculations.DomainThree.RelationshipItem
2525
end
2626

2727
postgres do
28-
table "items"
28+
table "relationship_items"
2929
repo(AshPostgres.TestRepo)
3030
end
3131
end

test/support/multi_domain_calculations/domain_two/other_item.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ defmodule AshPostgres.Test.MultiDomainCalculations.DomainTwo.OtherItem do
1515
update_timestamp(:updated_at)
1616
end
1717

18+
identities do
19+
identity :unique_parent, [:item_id]
20+
end
21+
1822
relationships do
1923
belongs_to(:item, Item, allow_nil?: false)
2024
has_many(:sub_items, SubItem)

0 commit comments

Comments
 (0)