Skip to content

Commit 3852146

Browse files
committed
docs: total docs reorg
1 parent 7d7d95d commit 3852146

23 files changed

+395
-250
lines changed
File renamed without changes.
File renamed without changes.

lib/guides/multitenancy.md renamed to documentation/topics/schema-based-multitenancy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Multitenancy
1+
# Schema Based Multitenancy
22

33
Multitenancy in AshPostgres is implemented via postgres schemas. For more information on schemas, see postgres' [schema documentation](https://www.postgresql.org/docs/current/ddl-schemas.html)
44

documentation/tutorials/get-started-with-postgres.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Take a look at the DSL documentation for more information on what you can config
331331

332332
#### See what is available in the DSL
333333

334-
{{link:ash_postgres:dsl:ash_postgres}}
334+
{{link:ash_postgres:dsl:ashpostgres:postgres}}
335335

336336
#### Learn more about the underlying tools
337337

lib/aggregate.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,15 @@ defmodule AshPostgres.Aggregate do
619619
query_tenant) do
620620
Ecto.Query.put_query_prefix(
621621
query,
622-
query_tenant || root_tenant || AshPostgres.schema(relationship.destination)
622+
query_tenant || root_tenant || AshPostgres.DataLayer.Info.schema(relationship.destination)
623623
)
624624
else
625625
%{
626626
query
627627
| prefix:
628-
AshPostgres.schema(relationship.destination) ||
629-
AshPostgres.repo(relationship.destination).config()[:default_prefix] || "public"
628+
AshPostgres.DataLayer.Info.schema(relationship.destination) ||
629+
AshPostgres.DataLayer.Info.repo(relationship.destination).config()[:default_prefix] ||
630+
"public"
630631
}
631632
end
632633
end
@@ -659,14 +660,15 @@ defmodule AshPostgres.Aggregate do
659660
query_tenant) do
660661
Ecto.Query.put_query_prefix(
661662
query,
662-
query_tenant || root_tenant || AshPostgres.schema(relationship.destination)
663+
query_tenant || root_tenant || AshPostgres.DataLayer.Info.schema(relationship.destination)
663664
)
664665
else
665666
%{
666667
query
667668
| prefix:
668-
AshPostgres.schema(relationship.destination) ||
669-
AshPostgres.repo(relationship.destination).config()[:default_prefix] || "public"
669+
AshPostgres.DataLayer.Info.schema(relationship.destination) ||
670+
AshPostgres.DataLayer.Info.repo(relationship.destination).config()[:default_prefix] ||
671+
"public"
670672
}
671673
end
672674
end

lib/ash_postgres.ex

Lines changed: 67 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,69 @@
11
defmodule AshPostgres do
2-
@moduledoc """
3-
A postgres extension library for `Ash`.
4-
5-
`AshPostgres.DataLayer` provides a DataLayer, and a DSL extension to configure that data layer.
6-
7-
The dsl extension exposes the `postgres` section. See: `AshPostgres.DataLayer` for more.
8-
"""
9-
10-
alias Spark.Dsl.Extension
11-
12-
@doc "The configured repo for a resource"
13-
def repo(resource) do
14-
Extension.get_opt(resource, [:postgres], :repo, nil, true)
15-
end
16-
17-
@doc "The configured table for a resource"
18-
def table(resource) do
19-
Extension.get_opt(resource, [:postgres], :table, nil, true)
20-
end
21-
22-
@doc "The configured schema for a resource"
23-
def schema(resource) do
24-
Extension.get_opt(resource, [:postgres], :schema, nil, true)
25-
end
26-
27-
@doc "The configured references for a resource"
28-
def references(resource) do
29-
Extension.get_entities(resource, [:postgres, :references])
30-
end
31-
32-
@doc "A keyword list of customized migration types"
33-
def migration_types(resource) do
34-
Extension.get_opt(resource, [:postgres], :migration_types, nil, true)
35-
end
36-
37-
@doc "The configured check_constraints for a resource"
38-
def check_constraints(resource) do
39-
Extension.get_entities(resource, [:postgres, :check_constraints])
40-
end
41-
42-
@doc "The configured custom_indexes for a resource"
43-
def custom_indexes(resource) do
44-
Extension.get_entities(resource, [:postgres, :custom_indexes])
45-
end
46-
47-
@doc "The configured custom_statements for a resource"
48-
def custom_statements(resource) do
49-
Extension.get_entities(resource, [:postgres, :custom_statements])
50-
end
51-
52-
@doc "The configured polymorphic_reference_on_delete for a resource"
53-
def polymorphic_on_delete(resource) do
54-
Extension.get_opt(resource, [:postgres, :references], :polymorphic_on_delete, nil, true)
55-
end
56-
57-
@doc "The configured polymorphic_reference_on_update for a resource"
58-
def polymorphic_on_update(resource) do
59-
Extension.get_opt(resource, [:postgres, :references], :polymorphic_on_update, nil, true)
60-
end
61-
62-
@doc "The configured polymorphic_reference_name for a resource"
63-
def polymorphic_name(resource) do
64-
Extension.get_opt(resource, [:postgres, :references], :polymorphic_on_delete, nil, true)
65-
end
66-
67-
@doc "The configured polymorphic? for a resource"
68-
def polymorphic?(resource) do
69-
Extension.get_opt(resource, [:postgres], :polymorphic?, nil, true)
70-
end
71-
72-
@doc "The configured unique_index_names"
73-
def unique_index_names(resource) do
74-
Extension.get_opt(resource, [:postgres], :unique_index_names, [], true)
75-
end
76-
77-
@doc "The configured exclusion_constraint_names"
78-
def exclusion_constraint_names(resource) do
79-
Extension.get_opt(resource, [:postgres], :exclusion_constraint_names, [], true)
80-
end
81-
82-
@doc "The configured identity_index_names"
83-
def identity_index_names(resource) do
84-
Extension.get_opt(resource, [:postgres], :identity_index_names, [], true)
85-
end
86-
87-
@doc "The configured foreign_key_names"
88-
def foreign_key_names(resource) do
89-
Extension.get_opt(resource, [:postgres], :foreign_key_names, [], true)
90-
end
91-
92-
@doc "Whether or not the resource should be included when generating migrations"
93-
def migrate?(resource) do
94-
Extension.get_opt(resource, [:postgres], :migrate?, nil, true)
95-
end
96-
97-
@doc "A stringified version of the base_filter, to be used in a where clause when generating unique indexes"
98-
def base_filter_sql(resource) do
99-
Extension.get_opt(resource, [:postgres], :base_filter_sql, nil)
100-
end
101-
102-
@doc "Skip generating unique indexes when generating migrations"
103-
def skip_unique_indexes?(resource) do
104-
Extension.get_opt(resource, [:postgres], :skip_unique_indexes?, [])
105-
end
106-
107-
@doc "The template for a managed tenant"
108-
def manage_tenant_template(resource) do
109-
Extension.get_opt(resource, [:postgres, :manage_tenant], :template, nil)
110-
end
111-
112-
@doc "Whether or not to create a tenant for a given resource"
113-
def manage_tenant_create?(resource) do
114-
Extension.get_opt(resource, [:postgres, :manage_tenant], :create?, false)
115-
end
116-
117-
@doc "Whether or not to update a tenant for a given resource"
118-
def manage_tenant_update?(resource) do
119-
Extension.get_opt(resource, [:postgres, :manage_tenant], :update?, false)
120-
end
2+
@moduledoc false
3+
4+
@deprecated "use AshPostgres.DataLayer.Info.repo/1"
5+
defdelegate repo(resource), to: AshPostgres.DataLayer.Info
6+
7+
@deprecated "use AshPostgres.DataLayer.Info.table/1"
8+
defdelegate table(resource), to: AshPostgres.DataLayer.Info
9+
10+
@deprecated "use AshPostgres.DataLayer.Info.schema/1"
11+
defdelegate schema(resource), to: AshPostgres.DataLayer.Info
12+
13+
@deprecated "use AshPostgres.DataLayer.Info.references/1"
14+
defdelegate references(resource), to: AshPostgres.DataLayer.Info
15+
16+
@deprecated "use AshPostgres.DataLayer.Info.migration_types/1"
17+
defdelegate migration_types(resource), to: AshPostgres.DataLayer.Info
18+
19+
@deprecated "use AshPostgres.DataLayer.Info.check_constraints/1"
20+
defdelegate check_constraints(resource), to: AshPostgres.DataLayer.Info
21+
22+
@deprecated "use AshPostgres.DataLayer.Info.custom_indexes/1"
23+
defdelegate custom_indexes(resource), to: AshPostgres.DataLayer.Info
24+
25+
@deprecated "use AshPostgres.DataLayer.Info.custom_statements/1"
26+
defdelegate custom_statements(resource), to: AshPostgres.DataLayer.Info
27+
28+
@deprecated "use AshPostgres.DataLayer.Info.polymorphic_on_delete/1"
29+
defdelegate polymorphic_on_delete(resource), to: AshPostgres.DataLayer.Info
30+
31+
@deprecated "use AshPostgres.DataLayer.Info.polymorphic_on_update/1"
32+
defdelegate polymorphic_on_update(resource), to: AshPostgres.DataLayer.Info
33+
34+
@deprecated "use AshPostgres.DataLayer.Info.polymorphic_name/1"
35+
defdelegate polymorphic_name(resource), to: AshPostgres.DataLayer.Info
36+
37+
@deprecated "use AshPostgres.DataLayer.Info.polymorphic?/1"
38+
defdelegate polymorphic?(resource), to: AshPostgres.DataLayer.Info
39+
40+
@deprecated "use AshPostgres.DataLayer.Info.unique_index_names/1"
41+
defdelegate unique_index_names(resource), to: AshPostgres.DataLayer.Info
42+
43+
@deprecated "use AshPostgres.DataLayer.Info.exclusion_constraint_names/1"
44+
defdelegate exclusion_constraint_names(resource), to: AshPostgres.DataLayer.Info
45+
46+
@deprecated "use AshPostgres.DataLayer.Info.identity_index_names/1"
47+
defdelegate identity_index_names(resource), to: AshPostgres.DataLayer.Info
48+
49+
@deprecated "use AshPostgres.DataLayer.Info.foreign_key_names/1"
50+
defdelegate foreign_key_names(resource), to: AshPostgres.DataLayer.Info
51+
52+
@deprecated "use AshPostgres.DataLayer.Info.migrate?/1"
53+
defdelegate migrate?(resource), to: AshPostgres.DataLayer.Info
54+
55+
@deprecated "use AshPostgres.DataLayer.Info.base_filter_sql/1"
56+
defdelegate base_filter_sql(resource), to: AshPostgres.DataLayer.Info
57+
58+
@deprecated "use AshPostgres.DataLayer.Info.skip_unique_indexes?/1"
59+
defdelegate skip_unique_indexes?(resource), to: AshPostgres.DataLayer.Info
60+
61+
@deprecated "use AshPostgres.DataLayer.Info.manage_tenant_template/1"
62+
defdelegate manage_tenant_template(resource), to: AshPostgres.DataLayer.Info
63+
64+
@deprecated "use AshPostgres.DataLayer.Info.manage_tenant_create?/1"
65+
defdelegate manage_tenant_create?(resource), to: AshPostgres.DataLayer.Info
66+
67+
@deprecated "use AshPostgres.DataLayer.Info.manage_tenant_update?/1"
68+
defdelegate manage_tenant_update?(resource), to: AshPostgres.DataLayer.Info
12169
end

lib/check_constraint.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
defmodule AshPostgres.CheckConstraint do
2-
@moduledoc """
3-
Contains configuration for database check constraints
4-
"""
2+
@moduledoc false
3+
54
defstruct [:attribute, :name, :message, :check]
65

76
def schema do

0 commit comments

Comments
 (0)