@pgpm/metaschema-schema 0.17.0 → 0.18.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/README.md +10 -6
- package/deploy/schemas/metaschema_public/tables/database/table.sql +1 -7
- package/deploy/schemas/metaschema_public/tables/default_privilege/table.sql +39 -0
- package/deploy/schemas/metaschema_public/tables/field/table.sql +20 -2
- package/deploy/schemas/metaschema_public/tables/foreign_key_constraint/table.sql +1 -1
- package/deploy/schemas/metaschema_public/tables/index/table.sql +1 -0
- package/deploy/schemas/metaschema_public/tables/policy/table.sql +5 -1
- package/deploy/schemas/metaschema_public/tables/schema/table.sql +3 -0
- package/deploy/schemas/metaschema_public/tables/table/indexes/databases_table_unique_name_idx.sql +1 -1
- package/deploy/schemas/metaschema_public/tables/table/table.sql +1 -3
- package/deploy/schemas/metaschema_public/tables/table_grant/table.sql +5 -1
- package/deploy/schemas/metaschema_public/tables/trigger/table.sql +3 -1
- package/deploy/schemas/metaschema_public/tables/unique_constraint/table.sql +3 -0
- package/deploy/schemas/metaschema_public/tables/view_grant/table.sql +5 -2
- package/deploy/schemas/metaschema_public/types/object_category.sql +4 -0
- package/package.json +7 -7
- package/pgpm.plan +10 -12
- package/revert/schemas/metaschema_public/tables/default_privilege/table.sql +7 -0
- package/revert/schemas/metaschema_public/types/object_category.sql +1 -1
- package/sql/metaschema-schema--0.15.5.sql +54 -94
- package/verify/schemas/metaschema_public/tables/default_privilege/table.sql +9 -0
- package/verify/schemas/metaschema_public/tables/view_grant/table.sql +1 -1
- package/verify/schemas/metaschema_public/types/object_category.sql +2 -0
- package/deploy/schemas/metaschema_public/tables/limit_function/table.sql +0 -34
- package/deploy/schemas/metaschema_public/tables/procedure/table.sql +0 -38
- package/deploy/schemas/metaschema_public/tables/rls_function/table.sql +0 -36
- package/revert/schemas/metaschema_public/tables/limit_function/table.sql +0 -7
- package/revert/schemas/metaschema_public/tables/procedure/table.sql +0 -7
- package/revert/schemas/metaschema_public/tables/rls_function/table.sql +0 -7
- package/verify/schemas/metaschema_public/tables/limit_function/table.sql +0 -7
- package/verify/schemas/metaschema_public/tables/procedure/table.sql +0 -7
- package/verify/schemas/metaschema_public/tables/rls_function/table.sql +0 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @pgpm/
|
|
1
|
+
# @pgpm/db-meta-schema
|
|
2
2
|
|
|
3
3
|
<p align="center" width="100%">
|
|
4
4
|
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
<img height="20" src="https://github.com/constructive-io/pgpm-modules/actions/workflows/ci.yml/badge.svg" />
|
|
10
10
|
</a>
|
|
11
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/
|
|
12
|
+
<a href="https://www.npmjs.com/package/@pgpm/db-meta-schema"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/pgpm-modules?filename=packages%2Fdb-meta-schema%2Fpackage.json"/></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
Database metadata utilities and introspection functions.
|
|
16
16
|
|
|
17
17
|
## Overview
|
|
18
18
|
|
|
19
|
-
`@pgpm/
|
|
19
|
+
`@pgpm/db-meta-schema` provides a comprehensive metadata management system for PostgreSQL databases. This package creates tables and schemas for storing and querying database structure information including databases, schemas, tables, fields, constraints, indexes, and more. It enables runtime schema introspection, metadata-driven code generation, and database structure management.
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
@@ -25,6 +25,7 @@ Database metadata utilities and introspection functions.
|
|
|
25
25
|
- **Index Management**: Store and query index definitions
|
|
26
26
|
- **Trigger and Procedure Metadata**: Track database functions and triggers
|
|
27
27
|
- **RLS and Policy Information**: Store row-level security policies
|
|
28
|
+
- **Extension Tracking**: Manage database extensions and their relationships
|
|
28
29
|
- **API and Site Metadata**: Store API configurations and site information
|
|
29
30
|
- **GraphQL Integration**: Smart tags and annotations for GraphQL schema generation
|
|
30
31
|
|
|
@@ -33,7 +34,7 @@ Database metadata utilities and introspection functions.
|
|
|
33
34
|
If you have `pgpm` installed:
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
|
-
pgpm install @pgpm/
|
|
37
|
+
pgpm install @pgpm/db-meta-schema
|
|
37
38
|
pgpm deploy
|
|
38
39
|
```
|
|
39
40
|
|
|
@@ -56,7 +57,7 @@ eval "$(pgpm env)"
|
|
|
56
57
|
|
|
57
58
|
```bash
|
|
58
59
|
# 1. Install the package
|
|
59
|
-
pgpm install @pgpm/
|
|
60
|
+
pgpm install @pgpm/db-meta-schema
|
|
60
61
|
|
|
61
62
|
# 2. Deploy locally
|
|
62
63
|
pgpm deploy
|
|
@@ -74,7 +75,7 @@ pgpm init
|
|
|
74
75
|
|
|
75
76
|
# 3. Install a package
|
|
76
77
|
cd packages/my-module
|
|
77
|
-
pgpm install @pgpm/
|
|
78
|
+
pgpm install @pgpm/db-meta-schema
|
|
78
79
|
|
|
79
80
|
# 4. Deploy everything
|
|
80
81
|
pgpm deploy --createdb --database mydb1
|
|
@@ -98,6 +99,8 @@ Stores database structure metadata:
|
|
|
98
99
|
- **trigger**: Trigger definitions
|
|
99
100
|
- **procedure**: Stored procedure definitions
|
|
100
101
|
- **policy**: Row-level security policies
|
|
102
|
+
- **extension**: PostgreSQL extensions
|
|
103
|
+
- **database_extension**: Extension installations per database
|
|
101
104
|
|
|
102
105
|
### metaschema_private Schema
|
|
103
106
|
|
|
@@ -108,6 +111,7 @@ Private schema for internal metadata operations.
|
|
|
108
111
|
Application-level metadata:
|
|
109
112
|
|
|
110
113
|
- **apis**: API configurations
|
|
114
|
+
- **api_extensions**: API extension relationships
|
|
111
115
|
- **api_modules**: API module definitions
|
|
112
116
|
- **api_schemas**: API schema configurations
|
|
113
117
|
- **sites**: Site definitions
|
|
@@ -8,23 +8,17 @@ CREATE TABLE metaschema_public.database (
|
|
|
8
8
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
9
|
owner_id uuid,
|
|
10
10
|
schema_hash text,
|
|
11
|
-
schema_name text,
|
|
12
|
-
private_schema_name text,
|
|
13
11
|
|
|
14
12
|
name text,
|
|
15
13
|
label text,
|
|
16
14
|
|
|
17
15
|
hash uuid,
|
|
18
|
-
unique(schema_hash)
|
|
19
|
-
unique(schema_name),
|
|
20
|
-
unique(private_schema_name)
|
|
16
|
+
unique(schema_hash)
|
|
21
17
|
);
|
|
22
18
|
|
|
23
19
|
ALTER TABLE metaschema_public.database
|
|
24
20
|
ADD CONSTRAINT db_namechk CHECK (char_length(name) > 2);
|
|
25
21
|
|
|
26
22
|
COMMENT ON COLUMN metaschema_public.database.schema_hash IS '@omit';
|
|
27
|
-
-- COMMENT ON COLUMN metaschema_public.database.schema_name IS '@omit';
|
|
28
|
-
-- COMMENT ON COLUMN metaschema_public.database.private_schema_name IS '@omit';
|
|
29
23
|
|
|
30
24
|
COMMIT;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_public/tables/default_privilege/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_public/schema
|
|
4
|
+
-- requires: schemas/metaschema_public/tables/schema/table
|
|
5
|
+
-- requires: schemas/metaschema_public/tables/database/table
|
|
6
|
+
|
|
7
|
+
BEGIN;
|
|
8
|
+
|
|
9
|
+
CREATE TABLE metaschema_public.default_privilege (
|
|
10
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
11
|
+
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
|
|
13
|
+
schema_id uuid NOT NULL,
|
|
14
|
+
|
|
15
|
+
-- 'tables', 'functions', 'sequences'
|
|
16
|
+
object_type text NOT NULL,
|
|
17
|
+
|
|
18
|
+
-- 'ALL', 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'USAGE', 'EXECUTE', etc.
|
|
19
|
+
privilege text NOT NULL,
|
|
20
|
+
|
|
21
|
+
-- role receiving the privilege (e.g. 'authenticated', 'administrator', 'anonymous')
|
|
22
|
+
grantee_name text NOT NULL,
|
|
23
|
+
|
|
24
|
+
-- true = GRANT, false = REVOKE
|
|
25
|
+
is_grant boolean NOT NULL DEFAULT true,
|
|
26
|
+
|
|
27
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
28
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
29
|
+
|
|
30
|
+
UNIQUE (schema_id, object_type, privilege, grantee_name, is_grant)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_public.default_privilege IS E'@omit manyToMany';
|
|
34
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.default_privilege IS E'@omit manyToMany';
|
|
35
|
+
|
|
36
|
+
CREATE INDEX default_privilege_schema_id_idx ON metaschema_public.default_privilege ( schema_id );
|
|
37
|
+
CREATE INDEX default_privilege_database_id_idx ON metaschema_public.default_privilege ( database_id );
|
|
38
|
+
|
|
39
|
+
COMMIT;
|
|
@@ -3,10 +3,25 @@
|
|
|
3
3
|
|
|
4
4
|
-- requires: schemas/metaschema_public/schema
|
|
5
5
|
-- requires: schemas/metaschema_public/tables/table/table
|
|
6
|
-
-- requires: schemas/metaschema_public/types/object_category
|
|
7
6
|
|
|
8
7
|
BEGIN;
|
|
9
8
|
|
|
9
|
+
-- TODO should we just query this table and make a view?
|
|
10
|
+
-- https://www.postgresql.org/docs/9.2/catalog-pg-attribute.html
|
|
11
|
+
|
|
12
|
+
-- IF YOU WANT TO REMOVE THIS TABLE, answer the qustion, how would you add RLS to this:
|
|
13
|
+
-- SELECT
|
|
14
|
+
-- attrelid::text AS tbl
|
|
15
|
+
-- , attname::text AS col
|
|
16
|
+
-- , p.attnum::int as id,
|
|
17
|
+
-- t.typname as typename
|
|
18
|
+
|
|
19
|
+
-- FROM pg_catalog.pg_attribute p
|
|
20
|
+
-- INNER JOIN pg_catalog.pg_type t ON (t.oid = p.atttypid)
|
|
21
|
+
-- WHERE attrelid = 'dude_schema.products'::regclass
|
|
22
|
+
-- AND p.attnum > 0
|
|
23
|
+
-- AND NOT attisdropped;
|
|
24
|
+
|
|
10
25
|
CREATE TABLE metaschema_public.field (
|
|
11
26
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
12
27
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
@@ -41,11 +56,14 @@ CREATE TABLE metaschema_public.field (
|
|
|
41
56
|
|
|
42
57
|
tags citext[] NOT NULL DEFAULT '{}',
|
|
43
58
|
|
|
59
|
+
-- Field categorization for system/module/app fields (mirrors table categorization)
|
|
60
|
+
-- category: 'core' for system fields (id, entity_id, actor_id), 'module' for module-generated fields, 'app' for user-defined fields
|
|
61
|
+
-- module: the module name that created this field (e.g., 'users', 'permissions', 'memberships')
|
|
62
|
+
-- scope: membership_type int (1=app, 2=org, 3=group, NULL=not scoped)
|
|
44
63
|
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
45
64
|
module text NULL,
|
|
46
65
|
scope int NULL,
|
|
47
66
|
|
|
48
|
-
--
|
|
49
67
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
50
68
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
51
69
|
|
|
@@ -19,7 +19,7 @@ CREATE TABLE metaschema_public.foreign_key_constraint (
|
|
|
19
19
|
field_ids uuid[] NOT NULL,
|
|
20
20
|
ref_table_id uuid NOT NULL REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
21
21
|
ref_field_ids uuid[] NOT NULL,
|
|
22
|
-
delete_action char(1) DEFAULT 'c',
|
|
22
|
+
delete_action char(1) DEFAULT 'c', -- postgres default is 'a'
|
|
23
23
|
update_action char(1) DEFAULT 'a',
|
|
24
24
|
|
|
25
25
|
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
@@ -33,6 +33,7 @@ CREATE TABLE metaschema_public.index (
|
|
|
33
33
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
34
34
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
35
35
|
|
|
36
|
+
-- index names are UNIQUE across schemas, so for portability we will check against database_id
|
|
36
37
|
UNIQUE (database_id, name)
|
|
37
38
|
);
|
|
38
39
|
|
|
@@ -12,9 +12,13 @@ CREATE TABLE metaschema_public.policy (
|
|
|
12
12
|
|
|
13
13
|
table_id uuid NOT NULL,
|
|
14
14
|
name text,
|
|
15
|
-
|
|
15
|
+
grantee_name text,
|
|
16
16
|
privilege text,
|
|
17
17
|
|
|
18
|
+
-- using_expression text,
|
|
19
|
+
-- check_expression text,
|
|
20
|
+
-- policy_text text,
|
|
21
|
+
|
|
18
22
|
permissive boolean default true,
|
|
19
23
|
disabled boolean default false,
|
|
20
24
|
|
|
@@ -31,6 +31,9 @@ CREATE TABLE metaschema_public.schema (
|
|
|
31
31
|
UNIQUE (schema_name)
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
+
-- TODO: build out services
|
|
35
|
+
-- COMMENT ON COLUMN metaschema_public.schema.schema_name IS '@omit';
|
|
36
|
+
|
|
34
37
|
ALTER TABLE metaschema_public.schema
|
|
35
38
|
ADD CONSTRAINT schema_namechk CHECK (char_length(name) > 2);
|
|
36
39
|
|
package/deploy/schemas/metaschema_public/tables/table/indexes/databases_table_unique_name_idx.sql
CHANGED
|
@@ -14,7 +14,7 @@ $BODY$
|
|
|
14
14
|
LANGUAGE sql
|
|
15
15
|
IMMUTABLE;
|
|
16
16
|
|
|
17
|
-
CREATE UNIQUE INDEX databases_table_unique_name_idx ON metaschema_public.table (database_id, metaschema_private.table_name_hash (name));
|
|
17
|
+
CREATE UNIQUE INDEX databases_table_unique_name_idx ON metaschema_public.table (database_id, schema_id, metaschema_private.table_name_hash (name));
|
|
18
18
|
|
|
19
19
|
COMMIT;
|
|
20
20
|
|
|
@@ -33,12 +33,10 @@ CREATE TABLE metaschema_public.table (
|
|
|
33
33
|
|
|
34
34
|
tags citext[] NOT NULL DEFAULT '{}',
|
|
35
35
|
|
|
36
|
-
--
|
|
37
|
-
|
|
38
36
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
39
37
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
40
38
|
|
|
41
|
-
UNIQUE (database_id, name)
|
|
39
|
+
UNIQUE (database_id, schema_id, name)
|
|
42
40
|
);
|
|
43
41
|
|
|
44
42
|
ALTER TABLE metaschema_public.table ADD COLUMN
|
|
@@ -11,8 +11,12 @@ CREATE TABLE metaschema_public.table_grant (
|
|
|
11
11
|
|
|
12
12
|
table_id uuid NOT NULL,
|
|
13
13
|
privilege text NOT NULL,
|
|
14
|
-
|
|
14
|
+
grantee_name text NOT NULL,
|
|
15
15
|
field_ids uuid[],
|
|
16
|
+
|
|
17
|
+
-- true = GRANT, false = REVOKE
|
|
18
|
+
is_grant boolean NOT NULL DEFAULT true,
|
|
19
|
+
|
|
16
20
|
--
|
|
17
21
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
18
22
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
BEGIN;
|
|
8
8
|
|
|
9
|
+
-- https://www.postgresql.org/docs/12/sql-createtrigger.html
|
|
10
|
+
|
|
9
11
|
CREATE TABLE metaschema_public.trigger (
|
|
10
12
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
11
13
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
14
|
|
|
13
15
|
table_id uuid NOT NULL,
|
|
14
16
|
name text NOT NULL,
|
|
15
|
-
event text,
|
|
17
|
+
event text, -- INSERT, UPDATE, DELETE, or TRUNCATE
|
|
16
18
|
function_name text,
|
|
17
19
|
|
|
18
20
|
smart_tags jsonb,
|
|
@@ -27,6 +27,9 @@ CREATE TABLE metaschema_public.unique_constraint (
|
|
|
27
27
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
28
28
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
29
29
|
|
|
30
|
+
-- TODO these are unique across schema, NOT table. We'll need to update this to have database_id
|
|
31
|
+
-- for portability
|
|
32
|
+
|
|
30
33
|
UNIQUE (table_id, name),
|
|
31
34
|
CHECK (field_ids <> '{}')
|
|
32
35
|
);
|
|
@@ -11,15 +11,18 @@ CREATE TABLE metaschema_public.view_grant (
|
|
|
11
11
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
12
|
|
|
13
13
|
view_id uuid NOT NULL,
|
|
14
|
-
|
|
14
|
+
grantee_name text NOT NULL,
|
|
15
15
|
privilege text NOT NULL,
|
|
16
16
|
|
|
17
17
|
with_grant_option boolean DEFAULT false,
|
|
18
18
|
|
|
19
|
+
-- true = GRANT, false = REVOKE
|
|
20
|
+
is_grant boolean NOT NULL DEFAULT true,
|
|
21
|
+
|
|
19
22
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
20
23
|
CONSTRAINT view_fkey FOREIGN KEY (view_id) REFERENCES metaschema_public.view (id) ON DELETE CASCADE,
|
|
21
24
|
|
|
22
|
-
UNIQUE (view_id,
|
|
25
|
+
UNIQUE (view_id, grantee_name, privilege, is_grant)
|
|
23
26
|
);
|
|
24
27
|
|
|
25
28
|
COMMENT ON CONSTRAINT view_fkey ON metaschema_public.view_grant IS E'@omit manyToMany';
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
BEGIN;
|
|
6
6
|
|
|
7
|
+
-- Unified category type for all metaschema objects (tables, fields, procedures, triggers, indexes, policies, constraints, etc.)
|
|
8
|
+
-- 'core' - system-level objects (id fields, entity_id, actor_id, etc.)
|
|
9
|
+
-- 'module' - objects created by modules (users, permissions, memberships, etc.)
|
|
10
|
+
-- 'app' - user-defined application objects
|
|
7
11
|
CREATE TYPE metaschema_public.object_category AS ENUM ('core', 'module', 'app');
|
|
8
12
|
|
|
9
13
|
COMMIT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/metaschema-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Database metadata utilities and introspection functions",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pgpm/database-jobs": "0.
|
|
25
|
-
"@pgpm/inflection": "0.
|
|
26
|
-
"@pgpm/types": "0.
|
|
27
|
-
"@pgpm/verify": "0.
|
|
24
|
+
"@pgpm/database-jobs": "0.18.0",
|
|
25
|
+
"@pgpm/inflection": "0.18.0",
|
|
26
|
+
"@pgpm/types": "0.18.0",
|
|
27
|
+
"@pgpm/verify": "0.18.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"pgpm": "^
|
|
30
|
+
"pgpm": "^4.2.3"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8144027c7fab4956bcdebd736d04c0d4f57344bc"
|
|
41
41
|
}
|
package/pgpm.plan
CHANGED
|
@@ -4,29 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
schemas/metaschema_private/schema [pgpm-inflection:schemas/inflection/tables/inflection_rules/indexes/inflection_rules_type_idx pgpm-database-jobs:schemas/app_jobs/triggers/tg_add_job_with_row pgpm-types:schemas/public/domains/url] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_private/schema
|
|
6
6
|
schemas/metaschema_public/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/schema
|
|
7
|
-
schemas/metaschema_public/types/object_category [schemas/metaschema_public/schema]
|
|
7
|
+
schemas/metaschema_public/types/object_category [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/types/object_category
|
|
8
8
|
schemas/metaschema_public/tables/database/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/database/table
|
|
9
9
|
schemas/metaschema_public/tables/schema/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/schema/table
|
|
10
10
|
schemas/metaschema_public/tables/table/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/schema/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/table/table
|
|
11
|
-
schemas/metaschema_public/tables/check_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table
|
|
11
|
+
schemas/metaschema_public/tables/check_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/check_constraint/table
|
|
12
12
|
schemas/metaschema_public/tables/database/indexes/databases_database_unique_name_idx [schemas/metaschema_private/schema schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/database/indexes/databases_database_unique_name_idx
|
|
13
|
-
schemas/metaschema_public/tables/field/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table
|
|
13
|
+
schemas/metaschema_public/tables/field/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/field/table
|
|
14
14
|
schemas/metaschema_public/tables/field/indexes/databases_field_uniq_names_idx [schemas/metaschema_public/schema schemas/metaschema_public/tables/field/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/field/indexes/databases_field_uniq_names_idx
|
|
15
|
-
schemas/metaschema_public/tables/foreign_key_constraint/table [schemas/metaschema_public/tables/field/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/schema
|
|
15
|
+
schemas/metaschema_public/tables/foreign_key_constraint/table [schemas/metaschema_public/tables/field/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/foreign_key_constraint/table
|
|
16
16
|
schemas/metaschema_public/tables/full_text_search/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/full_text_search/table
|
|
17
|
-
schemas/metaschema_public/tables/index/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/tables/database/table
|
|
18
|
-
schemas/metaschema_public/tables/
|
|
19
|
-
schemas/metaschema_public/tables/
|
|
20
|
-
schemas/metaschema_public/tables/primary_key_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/primary_key_constraint/table
|
|
21
|
-
schemas/metaschema_public/tables/procedure/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/procedure/table
|
|
22
|
-
schemas/metaschema_public/tables/rls_function/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/rls_function/table
|
|
17
|
+
schemas/metaschema_public/tables/index/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/index/table
|
|
18
|
+
schemas/metaschema_public/tables/policy/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/policy/table
|
|
19
|
+
schemas/metaschema_public/tables/primary_key_constraint/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/primary_key_constraint/table
|
|
23
20
|
schemas/metaschema_public/tables/schema_grant/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/schema/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/schema_grant/table
|
|
24
21
|
schemas/metaschema_public/tables/table_grant/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/table_grant/table
|
|
25
22
|
schemas/metaschema_public/tables/table/indexes/databases_table_unique_name_idx [schemas/metaschema_public/schema schemas/metaschema_private/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/table/indexes/databases_table_unique_name_idx
|
|
26
23
|
schemas/metaschema_public/tables/trigger_function/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/trigger_function/table
|
|
27
|
-
schemas/metaschema_public/tables/trigger/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table
|
|
28
|
-
schemas/metaschema_public/tables/unique_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table
|
|
24
|
+
schemas/metaschema_public/tables/trigger/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/trigger/table
|
|
25
|
+
schemas/metaschema_public/tables/unique_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_public/tables/unique_constraint/table
|
|
29
26
|
schemas/metaschema_public/tables/view/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/schema/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/tables/database/table schemas/metaschema_public/types/object_category] 2026-01-23T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_public/tables/view/table
|
|
30
27
|
schemas/metaschema_public/tables/view_table/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/view/table schemas/metaschema_public/tables/table/table] 2026-01-23T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_public/tables/view_table/table
|
|
31
28
|
schemas/metaschema_public/tables/view_grant/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/view/table schemas/metaschema_public/tables/database/table] 2026-01-23T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_public/tables/view_grant/table
|
|
32
29
|
schemas/metaschema_public/tables/view_rule/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/view/table schemas/metaschema_public/tables/database/table] 2026-01-23T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_public/tables/view_rule/table
|
|
30
|
+
schemas/metaschema_public/tables/default_privilege/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/schema/table schemas/metaschema_public/tables/database/table] 2026-02-27T00:00:00Z Constructive <developers@constructive.io> # add schemas/metaschema_public/tables/default_privilege/table
|
|
@@ -25,18 +25,16 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_public
|
|
|
25
25
|
ALTER DEFAULT PRIVILEGES IN SCHEMA metaschema_public
|
|
26
26
|
GRANT ALL ON FUNCTIONS TO authenticated;
|
|
27
27
|
|
|
28
|
+
CREATE TYPE metaschema_public.object_category AS ENUM ('core', 'module', 'app');
|
|
29
|
+
|
|
28
30
|
CREATE TABLE metaschema_public.database (
|
|
29
31
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
30
32
|
owner_id uuid,
|
|
31
33
|
schema_hash text,
|
|
32
|
-
schema_name text,
|
|
33
|
-
private_schema_name text,
|
|
34
34
|
name text,
|
|
35
35
|
label text,
|
|
36
36
|
hash uuid,
|
|
37
|
-
UNIQUE (schema_hash)
|
|
38
|
-
UNIQUE (schema_name),
|
|
39
|
-
UNIQUE (private_schema_name)
|
|
37
|
+
UNIQUE (schema_hash)
|
|
40
38
|
);
|
|
41
39
|
|
|
42
40
|
ALTER TABLE metaschema_public.database
|
|
@@ -52,6 +50,12 @@ CREATE TABLE metaschema_public.schema (
|
|
|
52
50
|
schema_name text NOT NULL,
|
|
53
51
|
label text,
|
|
54
52
|
description text,
|
|
53
|
+
smart_tags jsonb,
|
|
54
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
55
|
+
module text NULL,
|
|
56
|
+
scope int NULL,
|
|
57
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
58
|
+
is_public boolean NOT NULL DEFAULT true,
|
|
55
59
|
CONSTRAINT db_fkey
|
|
56
60
|
FOREIGN KEY(database_id)
|
|
57
61
|
REFERENCES metaschema_public.database (id)
|
|
@@ -68,8 +72,6 @@ COMMENT ON CONSTRAINT db_fkey ON metaschema_public.schema IS '@omit manyToMany';
|
|
|
68
72
|
|
|
69
73
|
CREATE INDEX schema_database_id_idx ON metaschema_public.schema (database_id);
|
|
70
74
|
|
|
71
|
-
CREATE TYPE metaschema_public.table_category AS ENUM ('core', 'module', 'app');
|
|
72
|
-
|
|
73
75
|
CREATE TABLE metaschema_public."table" (
|
|
74
76
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
75
77
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
@@ -78,7 +80,7 @@ CREATE TABLE metaschema_public."table" (
|
|
|
78
80
|
label text,
|
|
79
81
|
description text,
|
|
80
82
|
smart_tags jsonb,
|
|
81
|
-
category metaschema_public.
|
|
83
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
82
84
|
module text NULL,
|
|
83
85
|
scope int NULL,
|
|
84
86
|
use_rls boolean NOT NULL DEFAULT false,
|
|
@@ -95,7 +97,7 @@ CREATE TABLE metaschema_public."table" (
|
|
|
95
97
|
FOREIGN KEY(schema_id)
|
|
96
98
|
REFERENCES metaschema_public.schema (id)
|
|
97
99
|
ON DELETE CASCADE,
|
|
98
|
-
UNIQUE (database_id, name)
|
|
100
|
+
UNIQUE (database_id, schema_id, name)
|
|
99
101
|
);
|
|
100
102
|
|
|
101
103
|
ALTER TABLE metaschema_public."table"
|
|
@@ -119,6 +121,11 @@ CREATE TABLE metaschema_public.check_constraint (
|
|
|
119
121
|
type text,
|
|
120
122
|
field_ids uuid[] NOT NULL,
|
|
121
123
|
expr jsonb,
|
|
124
|
+
smart_tags jsonb,
|
|
125
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
126
|
+
module text NULL,
|
|
127
|
+
scope int NULL,
|
|
128
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
122
129
|
CONSTRAINT db_fkey
|
|
123
130
|
FOREIGN KEY(database_id)
|
|
124
131
|
REFERENCES metaschema_public.database (id)
|
|
@@ -146,8 +153,6 @@ $EOFCODE$ LANGUAGE sql IMMUTABLE;
|
|
|
146
153
|
|
|
147
154
|
CREATE UNIQUE INDEX databases_database_unique_name_idx ON metaschema_public.database (owner_id, (metaschema_private.database_name_hash(name)));
|
|
148
155
|
|
|
149
|
-
CREATE TYPE metaschema_public.field_category AS ENUM ('core', 'module', 'app');
|
|
150
|
-
|
|
151
156
|
CREATE TABLE metaschema_public.field (
|
|
152
157
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
153
158
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
@@ -168,7 +173,7 @@ CREATE TABLE metaschema_public.field (
|
|
|
168
173
|
min double precision DEFAULT NULL,
|
|
169
174
|
max double precision DEFAULT NULL,
|
|
170
175
|
tags citext[] NOT NULL DEFAULT '{}',
|
|
171
|
-
category metaschema_public.
|
|
176
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
172
177
|
module text NULL,
|
|
173
178
|
scope int NULL,
|
|
174
179
|
CONSTRAINT db_fkey
|
|
@@ -192,7 +197,10 @@ CREATE INDEX field_database_id_idx ON metaschema_public.field (database_id);
|
|
|
192
197
|
|
|
193
198
|
COMMENT ON COLUMN metaschema_public.field.default_value IS '@sqlExpression';
|
|
194
199
|
|
|
195
|
-
CREATE UNIQUE INDEX databases_field_uniq_names_idx ON metaschema_public.field (table_id, (decode(md5(lower(CASE
|
|
200
|
+
CREATE UNIQUE INDEX databases_field_uniq_names_idx ON metaschema_public.field (table_id, (decode(md5(lower(CASE
|
|
201
|
+
WHEN type = 'uuid' THEN regexp_replace(name, '^(.+?)(_row_id|_id|_uuid|_fk|_pk)$', E'\\1', 'i')
|
|
202
|
+
ELSE name
|
|
203
|
+
END)), 'hex')));
|
|
196
204
|
|
|
197
205
|
CREATE TABLE metaschema_public.foreign_key_constraint (
|
|
198
206
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
@@ -208,6 +216,10 @@ CREATE TABLE metaschema_public.foreign_key_constraint (
|
|
|
208
216
|
ref_field_ids uuid[] NOT NULL,
|
|
209
217
|
delete_action char(1) DEFAULT 'c',
|
|
210
218
|
update_action char(1) DEFAULT 'a',
|
|
219
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
220
|
+
module text NULL,
|
|
221
|
+
scope int NULL,
|
|
222
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
211
223
|
CONSTRAINT db_fkey
|
|
212
224
|
FOREIGN KEY(database_id)
|
|
213
225
|
REFERENCES metaschema_public.database (id)
|
|
@@ -270,6 +282,11 @@ CREATE TABLE metaschema_public.index (
|
|
|
270
282
|
index_params jsonb,
|
|
271
283
|
where_clause jsonb,
|
|
272
284
|
is_unique boolean NOT NULL DEFAULT false,
|
|
285
|
+
smart_tags jsonb,
|
|
286
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
287
|
+
module text NULL,
|
|
288
|
+
scope int NULL,
|
|
289
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
273
290
|
CONSTRAINT db_fkey
|
|
274
291
|
FOREIGN KEY(database_id)
|
|
275
292
|
REFERENCES metaschema_public.database (id)
|
|
@@ -289,45 +306,22 @@ CREATE INDEX index_table_id_idx ON metaschema_public.index (table_id);
|
|
|
289
306
|
|
|
290
307
|
CREATE INDEX index_database_id_idx ON metaschema_public.index (database_id);
|
|
291
308
|
|
|
292
|
-
CREATE TABLE metaschema_public.limit_function (
|
|
293
|
-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
294
|
-
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
295
|
-
table_id uuid NOT NULL,
|
|
296
|
-
name text,
|
|
297
|
-
label text,
|
|
298
|
-
description text,
|
|
299
|
-
data jsonb,
|
|
300
|
-
security int DEFAULT 0,
|
|
301
|
-
CONSTRAINT db_fkey
|
|
302
|
-
FOREIGN KEY(database_id)
|
|
303
|
-
REFERENCES metaschema_public.database (id)
|
|
304
|
-
ON DELETE CASCADE,
|
|
305
|
-
CONSTRAINT table_fkey
|
|
306
|
-
FOREIGN KEY(table_id)
|
|
307
|
-
REFERENCES metaschema_public."table" (id)
|
|
308
|
-
ON DELETE CASCADE,
|
|
309
|
-
UNIQUE (database_id, name)
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.limit_function IS '@omit manyToMany';
|
|
313
|
-
|
|
314
|
-
COMMENT ON CONSTRAINT table_fkey ON metaschema_public.limit_function IS '@omit manyToMany';
|
|
315
|
-
|
|
316
|
-
CREATE INDEX limit_function_table_id_idx ON metaschema_public.limit_function (table_id);
|
|
317
|
-
|
|
318
|
-
CREATE INDEX limit_function_database_id_idx ON metaschema_public.limit_function (database_id);
|
|
319
|
-
|
|
320
309
|
CREATE TABLE metaschema_public.policy (
|
|
321
310
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
322
311
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
323
312
|
table_id uuid NOT NULL,
|
|
324
313
|
name text,
|
|
325
|
-
|
|
314
|
+
grantee_name text,
|
|
326
315
|
privilege text,
|
|
327
316
|
permissive boolean DEFAULT true,
|
|
328
317
|
disabled boolean DEFAULT false,
|
|
329
|
-
|
|
318
|
+
policy_type text,
|
|
330
319
|
data jsonb,
|
|
320
|
+
smart_tags jsonb,
|
|
321
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
322
|
+
module text NULL,
|
|
323
|
+
scope int NULL,
|
|
324
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
331
325
|
CONSTRAINT db_fkey
|
|
332
326
|
FOREIGN KEY(database_id)
|
|
333
327
|
REFERENCES metaschema_public.database (id)
|
|
@@ -354,6 +348,11 @@ CREATE TABLE metaschema_public.primary_key_constraint (
|
|
|
354
348
|
name text,
|
|
355
349
|
type text,
|
|
356
350
|
field_ids uuid[] NOT NULL,
|
|
351
|
+
smart_tags jsonb,
|
|
352
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
353
|
+
module text NULL,
|
|
354
|
+
scope int NULL,
|
|
355
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
357
356
|
CONSTRAINT db_fkey
|
|
358
357
|
FOREIGN KEY(database_id)
|
|
359
358
|
REFERENCES metaschema_public.database (id)
|
|
@@ -374,55 +373,6 @@ CREATE INDEX primary_key_constraint_table_id_idx ON metaschema_public.primary_ke
|
|
|
374
373
|
|
|
375
374
|
CREATE INDEX primary_key_constraint_database_id_idx ON metaschema_public.primary_key_constraint (database_id);
|
|
376
375
|
|
|
377
|
-
CREATE TABLE metaschema_public.procedure (
|
|
378
|
-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
379
|
-
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
380
|
-
name text NOT NULL,
|
|
381
|
-
argnames text[],
|
|
382
|
-
argtypes text[],
|
|
383
|
-
argdefaults text[],
|
|
384
|
-
lang_name text,
|
|
385
|
-
definition text,
|
|
386
|
-
CONSTRAINT db_fkey
|
|
387
|
-
FOREIGN KEY(database_id)
|
|
388
|
-
REFERENCES metaschema_public.database (id)
|
|
389
|
-
ON DELETE CASCADE,
|
|
390
|
-
UNIQUE (database_id, name)
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.procedure IS '@omit manyToMany';
|
|
394
|
-
|
|
395
|
-
CREATE INDEX procedure_database_id_idx ON metaschema_public.procedure (database_id);
|
|
396
|
-
|
|
397
|
-
CREATE TABLE metaschema_public.rls_function (
|
|
398
|
-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
399
|
-
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
400
|
-
table_id uuid NOT NULL,
|
|
401
|
-
name text,
|
|
402
|
-
label text,
|
|
403
|
-
description text,
|
|
404
|
-
data jsonb,
|
|
405
|
-
inline boolean DEFAULT false,
|
|
406
|
-
security int DEFAULT 0,
|
|
407
|
-
CONSTRAINT db_fkey
|
|
408
|
-
FOREIGN KEY(database_id)
|
|
409
|
-
REFERENCES metaschema_public.database (id)
|
|
410
|
-
ON DELETE CASCADE,
|
|
411
|
-
CONSTRAINT table_fkey
|
|
412
|
-
FOREIGN KEY(table_id)
|
|
413
|
-
REFERENCES metaschema_public."table" (id)
|
|
414
|
-
ON DELETE CASCADE,
|
|
415
|
-
UNIQUE (database_id, name)
|
|
416
|
-
);
|
|
417
|
-
|
|
418
|
-
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.rls_function IS '@omit manyToMany';
|
|
419
|
-
|
|
420
|
-
COMMENT ON CONSTRAINT table_fkey ON metaschema_public.rls_function IS '@omit manyToMany';
|
|
421
|
-
|
|
422
|
-
CREATE INDEX rls_function_table_id_idx ON metaschema_public.rls_function (table_id);
|
|
423
|
-
|
|
424
|
-
CREATE INDEX rls_function_database_id_idx ON metaschema_public.rls_function (database_id);
|
|
425
|
-
|
|
426
376
|
CREATE TABLE metaschema_public.schema_grant (
|
|
427
377
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
428
378
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
@@ -451,8 +401,9 @@ CREATE TABLE metaschema_public.table_grant (
|
|
|
451
401
|
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
452
402
|
table_id uuid NOT NULL,
|
|
453
403
|
privilege text NOT NULL,
|
|
454
|
-
|
|
404
|
+
grantee_name text NOT NULL,
|
|
455
405
|
field_ids uuid[],
|
|
406
|
+
is_grant boolean NOT NULL DEFAULT true,
|
|
456
407
|
CONSTRAINT db_fkey
|
|
457
408
|
FOREIGN KEY(database_id)
|
|
458
409
|
REFERENCES metaschema_public.database (id)
|
|
@@ -476,7 +427,7 @@ CREATE FUNCTION metaschema_private.table_name_hash(name text) RETURNS bytea AS $
|
|
|
476
427
|
DECODE(MD5(LOWER(inflection.plural (name))), 'hex');
|
|
477
428
|
$EOFCODE$ LANGUAGE sql IMMUTABLE;
|
|
478
429
|
|
|
479
|
-
CREATE UNIQUE INDEX databases_table_unique_name_idx ON metaschema_public."table" (database_id, (metaschema_private.table_name_hash(name)));
|
|
430
|
+
CREATE UNIQUE INDEX databases_table_unique_name_idx ON metaschema_public."table" (database_id, schema_id, (metaschema_private.table_name_hash(name)));
|
|
480
431
|
|
|
481
432
|
CREATE TABLE metaschema_public.trigger_function (
|
|
482
433
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
@@ -501,6 +452,11 @@ CREATE TABLE metaschema_public.trigger (
|
|
|
501
452
|
name text NOT NULL,
|
|
502
453
|
event text,
|
|
503
454
|
function_name text,
|
|
455
|
+
smart_tags jsonb,
|
|
456
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
457
|
+
module text NULL,
|
|
458
|
+
scope int NULL,
|
|
459
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
504
460
|
CONSTRAINT db_fkey
|
|
505
461
|
FOREIGN KEY(database_id)
|
|
506
462
|
REFERENCES metaschema_public.database (id)
|
|
@@ -529,6 +485,10 @@ CREATE TABLE metaschema_public.unique_constraint (
|
|
|
529
485
|
smart_tags jsonb,
|
|
530
486
|
type text,
|
|
531
487
|
field_ids uuid[] NOT NULL,
|
|
488
|
+
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
489
|
+
module text NULL,
|
|
490
|
+
scope int NULL,
|
|
491
|
+
tags citext[] NOT NULL DEFAULT '{}',
|
|
532
492
|
CONSTRAINT db_fkey
|
|
533
493
|
FOREIGN KEY(database_id)
|
|
534
494
|
REFERENCES metaschema_public.database (id)
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
-- Deploy schemas/metaschema_public/tables/limit_function/table to pg
|
|
2
|
-
|
|
3
|
-
-- requires: schemas/metaschema_public/schema
|
|
4
|
-
|
|
5
|
-
BEGIN;
|
|
6
|
-
|
|
7
|
-
CREATE TABLE metaschema_public.limit_function (
|
|
8
|
-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
-
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
10
|
-
|
|
11
|
-
table_id uuid NOT NULL,
|
|
12
|
-
|
|
13
|
-
name text,
|
|
14
|
-
label text,
|
|
15
|
-
description text,
|
|
16
|
-
|
|
17
|
-
data jsonb,
|
|
18
|
-
|
|
19
|
-
security int default 0, -- 0 = invoker, 1 = definer
|
|
20
|
-
|
|
21
|
-
--
|
|
22
|
-
|
|
23
|
-
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
24
|
-
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
25
|
-
|
|
26
|
-
UNIQUE (database_id, name)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.limit_function IS E'@omit manyToMany';
|
|
30
|
-
COMMENT ON CONSTRAINT table_fkey ON metaschema_public.limit_function IS E'@omit manyToMany';
|
|
31
|
-
CREATE INDEX limit_function_table_id_idx ON metaschema_public.limit_function ( table_id );
|
|
32
|
-
CREATE INDEX limit_function_database_id_idx ON metaschema_public.limit_function ( database_id );
|
|
33
|
-
|
|
34
|
-
COMMIT;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
-- Deploy schemas/metaschema_public/tables/procedure/table to pg
|
|
2
|
-
|
|
3
|
-
-- requires: schemas/metaschema_public/schema
|
|
4
|
-
-- requires: schemas/metaschema_public/tables/database/table
|
|
5
|
-
-- requires: schemas/metaschema_public/types/object_category
|
|
6
|
-
|
|
7
|
-
BEGIN;
|
|
8
|
-
|
|
9
|
-
CREATE TABLE metaschema_public.procedure (
|
|
10
|
-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
11
|
-
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
-
|
|
13
|
-
name text NOT NULL,
|
|
14
|
-
|
|
15
|
-
argnames text[],
|
|
16
|
-
argtypes text[],
|
|
17
|
-
argdefaults text[],
|
|
18
|
-
|
|
19
|
-
lang_name text,
|
|
20
|
-
definition text,
|
|
21
|
-
|
|
22
|
-
smart_tags jsonb,
|
|
23
|
-
|
|
24
|
-
category metaschema_public.object_category NOT NULL DEFAULT 'app',
|
|
25
|
-
module text NULL,
|
|
26
|
-
scope int NULL,
|
|
27
|
-
|
|
28
|
-
tags citext[] NOT NULL DEFAULT '{}',
|
|
29
|
-
|
|
30
|
-
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
31
|
-
|
|
32
|
-
UNIQUE (database_id, name)
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.procedure IS E'@omit manyToMany';
|
|
36
|
-
CREATE INDEX procedure_database_id_idx ON metaschema_public.procedure ( database_id );
|
|
37
|
-
|
|
38
|
-
COMMIT;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
-- Deploy schemas/metaschema_public/tables/rls_function/table to pg
|
|
2
|
-
|
|
3
|
-
-- requires: schemas/metaschema_public/schema
|
|
4
|
-
-- requires: schemas/metaschema_public/tables/database/table
|
|
5
|
-
|
|
6
|
-
BEGIN;
|
|
7
|
-
|
|
8
|
-
CREATE TABLE metaschema_public.rls_function (
|
|
9
|
-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
10
|
-
database_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
11
|
-
|
|
12
|
-
table_id uuid NOT NULL,
|
|
13
|
-
|
|
14
|
-
name text,
|
|
15
|
-
label text,
|
|
16
|
-
description text,
|
|
17
|
-
|
|
18
|
-
data jsonb,
|
|
19
|
-
|
|
20
|
-
inline boolean default false,
|
|
21
|
-
security int default 0, -- 0 = invoker, 1 = definer (only when inline is false can we apply this)
|
|
22
|
-
|
|
23
|
-
--
|
|
24
|
-
|
|
25
|
-
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
26
|
-
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
27
|
-
|
|
28
|
-
UNIQUE (database_id, name)
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
COMMENT ON CONSTRAINT db_fkey ON metaschema_public.rls_function IS E'@omit manyToMany';
|
|
32
|
-
COMMENT ON CONSTRAINT table_fkey ON metaschema_public.rls_function IS E'@omit manyToMany';
|
|
33
|
-
CREATE INDEX rls_function_table_id_idx ON metaschema_public.rls_function ( table_id );
|
|
34
|
-
CREATE INDEX rls_function_database_id_idx ON metaschema_public.rls_function ( database_id );
|
|
35
|
-
|
|
36
|
-
COMMIT;
|