@pgpm/metaschema-modules 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/Makefile +6 -0
- package/README.md +240 -0
- package/deploy/schemas/metaschema_modules_public/schema.sql +16 -0
- package/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +34 -0
- package/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +35 -0
- package/deploy/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql +41 -0
- package/deploy/schemas/metaschema_modules_public/tables/default_ids_module/table.sql +19 -0
- package/deploy/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql +41 -0
- package/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql +34 -0
- package/deploy/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +29 -0
- package/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql +37 -0
- package/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +79 -0
- package/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +51 -0
- package/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql +71 -0
- package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +63 -0
- package/deploy/schemas/metaschema_modules_public/tables/membership_types_module/table.sql +30 -0
- package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +120 -0
- package/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +65 -0
- package/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +34 -0
- package/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +89 -0
- package/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql +46 -0
- package/deploy/schemas/metaschema_modules_public/tables/secrets_module/table.sql +28 -0
- package/deploy/schemas/metaschema_modules_public/tables/tokens_module/table.sql +35 -0
- package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +68 -0
- package/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql +38 -0
- package/deploy/schemas/metaschema_modules_public/tables/uuid_module/table.sql +23 -0
- package/deploy/schemas/services_private/schema.sql +2 -0
- package/deploy/schemas/services_public/schema.sql +2 -0
- package/deploy/schemas/services_public/tables/apis/table.sql +3 -0
- package/deploy/schemas/services_public/tables/sites/table.sql +3 -0
- package/metaschema-modules.control +7 -0
- package/package.json +40 -0
- package/pgpm.plan +32 -0
- package/revert/schemas/metaschema_modules_public/schema.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/default_ids_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/emails_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/field_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/invites_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/levels_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/limits_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/membership_types_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/memberships_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/permissions_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/profiles_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/rls_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/secrets_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/tokens_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/users_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/uuid_module/table.sql +7 -0
- package/revert/schemas/services_private/schema.sql +1 -0
- package/revert/schemas/services_public/schema.sql +1 -0
- package/revert/schemas/services_public/tables/apis/table.sql +1 -0
- package/revert/schemas/services_public/tables/sites/table.sql +1 -0
- package/sql/metaschema-modules--0.15.5.sql +1206 -0
- package/verify/schemas/metaschema_modules_public/schema.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/default_ids_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/emails_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/field_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +29 -0
- package/verify/schemas/metaschema_modules_public/tables/invites_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/levels_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/limits_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/membership_types_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/memberships_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/permissions_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/profiles_module/table.sql +14 -0
- package/verify/schemas/metaschema_modules_public/tables/rls_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/secrets_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/tokens_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/users_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/uuid_module/table.sql +7 -0
- package/verify/schemas/services_private/schema.sql +1 -0
- package/verify/schemas/services_public/schema.sql +1 -0
- package/verify/schemas/services_public/tables/apis/table.sql +1 -0
- package/verify/schemas/services_public/tables/sites/table.sql +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
|
|
4
|
+
Copyright (c) 2025 Constructive
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/Makefile
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# @pgpm/metaschema-modules
|
|
2
|
+
|
|
3
|
+
<p align="center" width="100%">
|
|
4
|
+
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center" width="100%">
|
|
8
|
+
<a href="https://github.com/constructive-io/pgpm-modules/actions/workflows/ci.yml">
|
|
9
|
+
<img height="20" src="https://github.com/constructive-io/pgpm-modules/actions/workflows/ci.yml/badge.svg" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://github.com/constructive-io/pgpm-modules/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@pgpm/metaschema-modules"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/pgpm-modules?filename=packages%2Fmetaschema-modules%2Fpackage.json"/></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
Module metadata handling and dependency tracking.
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
`@pgpm/metaschema-modules` extends the `@pgpm/metaschema-schema` package with module-specific metadata tables. This package provides tables for tracking various pgpm modules including authentication, permissions, memberships, encrypted secrets, and more. It enables configuration and metadata storage for modular application features.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Module Metadata Tables**: Store configuration for various application modules
|
|
24
|
+
- **Authentication Modules**: Track user authentication, connected accounts, and crypto auth
|
|
25
|
+
- **Permission System**: Store permissions and membership configurations
|
|
26
|
+
- **Security Modules**: Track encrypted secrets and tokens
|
|
27
|
+
- **User Management**: Store user and membership module configurations
|
|
28
|
+
- **Field Modules**: Track custom field configurations
|
|
29
|
+
- **API Configuration**: Store API and RLS module settings
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
If you have `pgpm` installed:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pgpm install @pgpm/metaschema-modules
|
|
37
|
+
pgpm deploy
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This is a quick way to get started. The sections below provide more detailed installation options.
|
|
41
|
+
|
|
42
|
+
### Prerequisites
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Install pgpm CLI
|
|
46
|
+
npm install -g pgpm
|
|
47
|
+
|
|
48
|
+
# Start local Postgres (via Docker) and export env vars
|
|
49
|
+
pgpm docker start
|
|
50
|
+
eval "$(pgpm env)"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> **Tip:** Already running Postgres? Skip the Docker step and just export your `PG*` environment variables.
|
|
54
|
+
|
|
55
|
+
### **Add to an Existing Package**
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 1. Install the package
|
|
59
|
+
pgpm install @pgpm/metaschema-modules
|
|
60
|
+
|
|
61
|
+
# 2. Deploy locally
|
|
62
|
+
pgpm deploy
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### **Add to a New Project**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# 1. Create a workspace
|
|
69
|
+
pgpm init workspace
|
|
70
|
+
|
|
71
|
+
# 2. Create your first module
|
|
72
|
+
cd my-workspace
|
|
73
|
+
pgpm init
|
|
74
|
+
|
|
75
|
+
# 3. Install a package
|
|
76
|
+
cd packages/my-module
|
|
77
|
+
pgpm install @pgpm/metaschema-modules
|
|
78
|
+
|
|
79
|
+
# 4. Deploy everything
|
|
80
|
+
pgpm deploy --createdb --database mydb1
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Module Tables
|
|
84
|
+
|
|
85
|
+
The package provides metadata tables for the following modules:
|
|
86
|
+
|
|
87
|
+
### Authentication & Users
|
|
88
|
+
- **users_module**: User management configuration
|
|
89
|
+
- **user_auth_module**: User authentication settings
|
|
90
|
+
- **connected_accounts_module**: Connected account configurations
|
|
91
|
+
- **crypto_auth_module**: Cryptocurrency authentication settings
|
|
92
|
+
- **crypto_addresses_module**: Crypto address management
|
|
93
|
+
|
|
94
|
+
### Permissions & Memberships
|
|
95
|
+
- **permissions_module**: Permission system configuration
|
|
96
|
+
- **memberships_module**: Membership management settings
|
|
97
|
+
- **membership_types_module**: Membership type definitions
|
|
98
|
+
- **levels_module**: User level configurations
|
|
99
|
+
|
|
100
|
+
### Security
|
|
101
|
+
- **encrypted_secrets_module**: Encrypted secrets configuration
|
|
102
|
+
- **secrets_module**: Secret management settings
|
|
103
|
+
- **tokens_module**: Token management configuration
|
|
104
|
+
|
|
105
|
+
### Communication
|
|
106
|
+
- **emails_module**: Email module configuration
|
|
107
|
+
- **phone_numbers_module**: Phone number management settings
|
|
108
|
+
- **invites_module**: Invitation system configuration
|
|
109
|
+
|
|
110
|
+
### Other Modules
|
|
111
|
+
- **field_module**: Custom field configurations
|
|
112
|
+
- **default_ids_module**: Default ID generation settings
|
|
113
|
+
- **limits_module**: Rate limiting and quota configurations
|
|
114
|
+
- **rls_module**: Row-level security configurations
|
|
115
|
+
- **denormalized_table_field**: Denormalized field tracking
|
|
116
|
+
|
|
117
|
+
### Application Structure
|
|
118
|
+
- **apis**: API configurations
|
|
119
|
+
- **sites**: Site definitions
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
### Storing Module Configuration
|
|
124
|
+
|
|
125
|
+
```sql
|
|
126
|
+
-- Configure users module
|
|
127
|
+
INSERT INTO metaschema_modules_public.users_module (
|
|
128
|
+
database_id,
|
|
129
|
+
api_id,
|
|
130
|
+
enabled,
|
|
131
|
+
settings
|
|
132
|
+
) VALUES (
|
|
133
|
+
'database-uuid',
|
|
134
|
+
'api-uuid',
|
|
135
|
+
true,
|
|
136
|
+
'{"require_email_verification": true}'::jsonb
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
-- Configure permissions module
|
|
140
|
+
INSERT INTO metaschema_modules_public.permissions_module (
|
|
141
|
+
database_id,
|
|
142
|
+
api_id,
|
|
143
|
+
enabled,
|
|
144
|
+
settings
|
|
145
|
+
) VALUES (
|
|
146
|
+
'database-uuid',
|
|
147
|
+
'api-uuid',
|
|
148
|
+
true,
|
|
149
|
+
'{"default_role": "user"}'::jsonb
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
-- Configure encrypted secrets module
|
|
153
|
+
INSERT INTO metaschema_modules_public.encrypted_secrets_module (
|
|
154
|
+
database_id,
|
|
155
|
+
api_id,
|
|
156
|
+
enabled,
|
|
157
|
+
encryption_key_id
|
|
158
|
+
) VALUES (
|
|
159
|
+
'database-uuid',
|
|
160
|
+
'api-uuid',
|
|
161
|
+
true,
|
|
162
|
+
'key-uuid'
|
|
163
|
+
);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Querying Module Configuration
|
|
167
|
+
|
|
168
|
+
```sql
|
|
169
|
+
-- Get all enabled modules for a database
|
|
170
|
+
SELECT
|
|
171
|
+
'users' as module_name, enabled
|
|
172
|
+
FROM metaschema_modules_public.users_module
|
|
173
|
+
WHERE database_id = 'database-uuid'
|
|
174
|
+
UNION ALL
|
|
175
|
+
SELECT
|
|
176
|
+
'permissions' as module_name, enabled
|
|
177
|
+
FROM metaschema_modules_public.permissions_module
|
|
178
|
+
WHERE database_id = 'database-uuid'
|
|
179
|
+
UNION ALL
|
|
180
|
+
SELECT
|
|
181
|
+
'encrypted_secrets' as module_name, enabled
|
|
182
|
+
FROM metaschema_modules_public.encrypted_secrets_module
|
|
183
|
+
WHERE database_id = 'database-uuid';
|
|
184
|
+
|
|
185
|
+
-- Get RLS module configuration
|
|
186
|
+
SELECT * FROM metaschema_modules_public.rls_module
|
|
187
|
+
WHERE api_id = 'api-uuid';
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Use Cases
|
|
191
|
+
|
|
192
|
+
### Modular Application Configuration
|
|
193
|
+
|
|
194
|
+
Store and manage configuration for optional application features:
|
|
195
|
+
- Enable/disable modules per database or API
|
|
196
|
+
- Store module-specific settings
|
|
197
|
+
- Track module dependencies
|
|
198
|
+
- Configure module behavior
|
|
199
|
+
|
|
200
|
+
### Multi-Tenant Applications
|
|
201
|
+
|
|
202
|
+
Manage module configurations per tenant:
|
|
203
|
+
- Different modules enabled per tenant
|
|
204
|
+
- Tenant-specific module settings
|
|
205
|
+
- Isolated module configurations
|
|
206
|
+
|
|
207
|
+
### Dynamic Feature Flags
|
|
208
|
+
|
|
209
|
+
Use module tables as feature flags:
|
|
210
|
+
- Enable/disable features at runtime
|
|
211
|
+
- A/B testing configurations
|
|
212
|
+
- Gradual feature rollouts
|
|
213
|
+
|
|
214
|
+
## Dependencies
|
|
215
|
+
|
|
216
|
+
- `@pgpm/metaschema-schema`: Core metadata management
|
|
217
|
+
- `@pgpm/services`: Services schemas for APIs, sites, and domains
|
|
218
|
+
- `@pgpm/verify`: Verification utilities
|
|
219
|
+
|
|
220
|
+
## Testing
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
pnpm test
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Related Tooling
|
|
227
|
+
|
|
228
|
+
* [pgpm](https://github.com/constructive-io/constructive/tree/main/packages/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
229
|
+
* [pgsql-test](https://github.com/constructive-io/constructive/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
230
|
+
* [supabase-test](https://github.com/constructive-io/constructive/tree/main/packages/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
|
|
231
|
+
* [graphile-test](https://github.com/constructive-io/constructive/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
|
|
232
|
+
* [pgsql-parser](https://github.com/constructive-io/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
|
|
233
|
+
* [libpg-query-node](https://github.com/constructive-io/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
|
|
234
|
+
* [pg-proto-parser](https://github.com/constructive-io/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
|
|
235
|
+
|
|
236
|
+
## Disclaimer
|
|
237
|
+
|
|
238
|
+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
239
|
+
|
|
240
|
+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/schema to pg
|
|
2
|
+
|
|
3
|
+
BEGIN;
|
|
4
|
+
|
|
5
|
+
CREATE SCHEMA metaschema_modules_public;
|
|
6
|
+
|
|
7
|
+
GRANT USAGE ON SCHEMA metaschema_modules_public TO authenticated;
|
|
8
|
+
GRANT USAGE ON SCHEMA metaschema_modules_public TO administrator;
|
|
9
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_modules_public GRANT ALL ON TABLES TO authenticated;
|
|
10
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_modules_public GRANT ALL ON SEQUENCES TO authenticated;
|
|
11
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_modules_public GRANT ALL ON FUNCTIONS TO authenticated;
|
|
12
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_modules_public GRANT ALL ON TABLES TO administrator;
|
|
13
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_modules_public GRANT ALL ON SEQUENCES TO administrator;
|
|
14
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_modules_public GRANT ALL ON FUNCTIONS TO administrator;
|
|
15
|
+
|
|
16
|
+
COMMIT;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/connected_accounts_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.connected_accounts_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
|
|
17
|
+
table_name text NOT NULL,
|
|
18
|
+
|
|
19
|
+
--
|
|
20
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
21
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
22
|
+
CONSTRAINT owner_table_fkey FOREIGN KEY (owner_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
23
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
24
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany';
|
|
28
|
+
COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany';
|
|
29
|
+
COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany';
|
|
30
|
+
COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany';
|
|
31
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany';
|
|
32
|
+
CREATE INDEX connected_accounts_module_database_id_idx ON metaschema_modules_public.connected_accounts_module ( database_id );
|
|
33
|
+
|
|
34
|
+
COMMIT;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/crypto_addresses_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.crypto_addresses_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
|
|
17
|
+
table_name text NOT NULL,
|
|
18
|
+
crypto_network text NOT NULL DEFAULT 'BTC',
|
|
19
|
+
|
|
20
|
+
--
|
|
21
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
22
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
23
|
+
CONSTRAINT owner_table_fkey FOREIGN KEY (owner_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
24
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
25
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany';
|
|
29
|
+
COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany';
|
|
30
|
+
COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany';
|
|
31
|
+
COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany';
|
|
32
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany';
|
|
33
|
+
CREATE INDEX crypto_addresses_module_database_id_idx ON metaschema_modules_public.crypto_addresses_module ( database_id );
|
|
34
|
+
|
|
35
|
+
COMMIT;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/crypto_auth_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.crypto_auth_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
|
|
13
|
+
users_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
tokens_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
secrets_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
addresses_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
|
|
18
|
+
user_field text NOT NULL,
|
|
19
|
+
|
|
20
|
+
crypto_network text NOT NULL DEFAULT 'BTC',
|
|
21
|
+
sign_in_request_challenge text NOT NULL DEFAULT 'sign_in_request_challenge',
|
|
22
|
+
sign_in_record_failure text NOT NULL DEFAULT 'sign_in_record_failure',
|
|
23
|
+
sign_up_with_key text NOT NULL DEFAULT 'sign_up_with_key',
|
|
24
|
+
sign_in_with_challenge text NOT NULL DEFAULT 'sign_in_with_challenge',
|
|
25
|
+
|
|
26
|
+
--
|
|
27
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
28
|
+
CONSTRAINT secrets_table_fkey FOREIGN KEY (secrets_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
29
|
+
CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
30
|
+
CONSTRAINT tokens_table_fkey FOREIGN KEY (tokens_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
31
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany';
|
|
35
|
+
COMMENT ON CONSTRAINT secrets_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany';
|
|
36
|
+
COMMENT ON CONSTRAINT users_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany';
|
|
37
|
+
COMMENT ON CONSTRAINT tokens_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany';
|
|
38
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany';
|
|
39
|
+
CREATE INDEX crypto_auth_module_database_id_idx ON metaschema_modules_public.crypto_auth_module ( database_id );
|
|
40
|
+
|
|
41
|
+
COMMIT;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/default_ids_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.default_ids_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
--
|
|
12
|
+
|
|
13
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.default_ids_module IS E'@omit manyToMany';
|
|
17
|
+
CREATE INDEX default_ids_module_database_id_idx ON metaschema_modules_public.default_ids_module ( database_id );
|
|
18
|
+
|
|
19
|
+
COMMIT;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/denormalized_table_field/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.denormalized_table_field (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
table_id uuid NOT NULL,
|
|
12
|
+
field_id uuid NOT NULL,
|
|
13
|
+
|
|
14
|
+
set_ids uuid[],
|
|
15
|
+
|
|
16
|
+
ref_table_id uuid NOT NULL,
|
|
17
|
+
ref_field_id uuid NOT NULL,
|
|
18
|
+
ref_ids uuid[],
|
|
19
|
+
|
|
20
|
+
use_updates bool NOT NULL DEFAULT TRUE,
|
|
21
|
+
update_defaults bool NOT NULL DEFAULT TRUE,
|
|
22
|
+
|
|
23
|
+
func_name text NULL,
|
|
24
|
+
func_order int NOT NULL DEFAULT 0,
|
|
25
|
+
|
|
26
|
+
--
|
|
27
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
28
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
29
|
+
CONSTRAINT ref_table_fkey FOREIGN KEY (ref_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
30
|
+
CONSTRAINT field_fkey FOREIGN KEY (field_id) REFERENCES metaschema_public.field (id) ON DELETE CASCADE,
|
|
31
|
+
CONSTRAINT ref_field_fkey FOREIGN KEY (ref_field_id) REFERENCES metaschema_public.field (id) ON DELETE CASCADE
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany';
|
|
35
|
+
COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany';
|
|
36
|
+
COMMENT ON CONSTRAINT ref_table_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany';
|
|
37
|
+
COMMENT ON CONSTRAINT field_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany';
|
|
38
|
+
COMMENT ON CONSTRAINT ref_field_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany';
|
|
39
|
+
CREATE INDEX denormalized_table_field_database_id_idx ON metaschema_modules_public.denormalized_table_field ( database_id );
|
|
40
|
+
|
|
41
|
+
COMMIT;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/emails_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.emails_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
|
|
17
|
+
table_name text NOT NULL,
|
|
18
|
+
|
|
19
|
+
--
|
|
20
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
21
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
22
|
+
CONSTRAINT owner_table_fkey FOREIGN KEY (owner_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
23
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
24
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany';
|
|
28
|
+
COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany';
|
|
29
|
+
COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany';
|
|
30
|
+
COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany';
|
|
31
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany';
|
|
32
|
+
CREATE INDEX emails_module_database_id_idx ON metaschema_modules_public.emails_module ( database_id );
|
|
33
|
+
|
|
34
|
+
COMMIT;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/encrypted_secrets_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.encrypted_secrets_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
--
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
table_name text NOT NULL DEFAULT 'encrypted_secrets',
|
|
15
|
+
--
|
|
16
|
+
|
|
17
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
18
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
19
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.encrypted_secrets_module IS E'@omit manyToMany';
|
|
23
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.encrypted_secrets_module IS E'@omit manyToMany';
|
|
24
|
+
CREATE INDEX encrypted_secrets_module_database_id_idx ON metaschema_modules_public.encrypted_secrets_module ( database_id );
|
|
25
|
+
|
|
26
|
+
COMMENT ON CONSTRAINT table_fkey
|
|
27
|
+
ON metaschema_modules_public.encrypted_secrets_module IS E'@omit manyToMany';
|
|
28
|
+
|
|
29
|
+
COMMIT;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/field_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.field_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
|
|
13
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
field_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
|
|
16
|
+
-- data = '{"regexp":"^kjhsdkjhsd$"}'
|
|
17
|
+
-- data = '{"min":10, "max": 20}'
|
|
18
|
+
data jsonb NOT NULL DEFAULT '{}',
|
|
19
|
+
|
|
20
|
+
triggers text[],
|
|
21
|
+
functions text[],
|
|
22
|
+
|
|
23
|
+
--
|
|
24
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
25
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
26
|
+
CONSTRAINT field_fkey FOREIGN KEY (field_id) REFERENCES metaschema_public.field (id) ON DELETE CASCADE,
|
|
27
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany';
|
|
31
|
+
COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany';
|
|
32
|
+
COMMENT ON CONSTRAINT field_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany';
|
|
33
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany';
|
|
34
|
+
CREATE INDEX field_module_database_id_idx ON metaschema_modules_public.field_module ( database_id );
|
|
35
|
+
|
|
36
|
+
COMMIT;
|
|
37
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/hierarchy_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.hierarchy_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
-- Schema references
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
|
|
15
|
+
-- Table references for created tables
|
|
16
|
+
chart_edges_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
chart_edges_table_name text NOT NULL DEFAULT '',
|
|
18
|
+
|
|
19
|
+
hierarchy_sprt_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
hierarchy_sprt_table_name text NOT NULL DEFAULT '',
|
|
21
|
+
|
|
22
|
+
chart_edge_grants_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
23
|
+
chart_edge_grants_table_name text NOT NULL DEFAULT '',
|
|
24
|
+
|
|
25
|
+
-- Required external table references
|
|
26
|
+
entity_table_id uuid NOT NULL, -- Organizations table (membership_type=2 entity)
|
|
27
|
+
users_table_id uuid NOT NULL, -- Users table
|
|
28
|
+
|
|
29
|
+
-- Prefix for naming (e.g., 'org' -> 'org_chart_edges')
|
|
30
|
+
prefix text NOT NULL DEFAULT 'org',
|
|
31
|
+
|
|
32
|
+
-- Resolved names for RLS parser lookups
|
|
33
|
+
private_schema_name text NOT NULL DEFAULT '',
|
|
34
|
+
sprt_table_name text NOT NULL DEFAULT '',
|
|
35
|
+
|
|
36
|
+
-- Function names for helper functions
|
|
37
|
+
rebuild_hierarchy_function text NOT NULL DEFAULT '',
|
|
38
|
+
get_subordinates_function text NOT NULL DEFAULT '',
|
|
39
|
+
get_managers_function text NOT NULL DEFAULT '',
|
|
40
|
+
is_manager_of_function text NOT NULL DEFAULT '',
|
|
41
|
+
|
|
42
|
+
-- Timestamps
|
|
43
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
44
|
+
|
|
45
|
+
-- Constraints
|
|
46
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
47
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
48
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
49
|
+
CONSTRAINT chart_edges_table_fkey FOREIGN KEY (chart_edges_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
50
|
+
CONSTRAINT hierarchy_sprt_table_fkey FOREIGN KEY (hierarchy_sprt_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
51
|
+
CONSTRAINT chart_edge_grants_table_fkey FOREIGN KEY (chart_edge_grants_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
52
|
+
CONSTRAINT entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
53
|
+
CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
54
|
+
|
|
55
|
+
-- Only one hierarchy module per database
|
|
56
|
+
CONSTRAINT hierarchy_module_database_unique UNIQUE (database_id)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
60
|
+
COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
61
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
62
|
+
CREATE INDEX hierarchy_module_database_id_idx ON metaschema_modules_public.hierarchy_module ( database_id );
|
|
63
|
+
|
|
64
|
+
COMMENT ON CONSTRAINT chart_edges_table_fkey
|
|
65
|
+
ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
66
|
+
|
|
67
|
+
COMMENT ON CONSTRAINT hierarchy_sprt_table_fkey
|
|
68
|
+
ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
69
|
+
|
|
70
|
+
COMMENT ON CONSTRAINT chart_edge_grants_table_fkey
|
|
71
|
+
ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
72
|
+
|
|
73
|
+
COMMENT ON CONSTRAINT entity_table_fkey
|
|
74
|
+
ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
75
|
+
|
|
76
|
+
COMMENT ON CONSTRAINT users_table_fkey
|
|
77
|
+
ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany';
|
|
78
|
+
|
|
79
|
+
COMMIT;
|