|
1 | 1 | 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 |
121 | 69 | end |
0 commit comments