@pgpm/metaschema-modules 0.20.0 → 0.20.2
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/deploy/schemas/metaschema_modules_public/tables/blueprint/table.sql +3 -33
- package/deploy/schemas/metaschema_modules_public/tables/blueprint_construction/table.sql +84 -0
- package/deploy/schemas/metaschema_modules_public/tables/relation_provision/table.sql +8 -19
- package/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +5 -10
- package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +47 -0
- package/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql +1 -1
- package/package.json +3 -3
- package/pgpm.plan +2 -1
- package/revert/schemas/metaschema_modules_public/tables/blueprint_construction/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/storage_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/blueprint/table.sql +0 -5
- package/verify/schemas/metaschema_modules_public/tables/blueprint_construction/table.sql +10 -0
- package/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql +4 -2
- package/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +1 -2
- package/verify/schemas/metaschema_modules_public/tables/storage_module/table.sql +7 -0
- package/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql +0 -39
- package/revert/schemas/metaschema_modules_public/tables/field_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/field_module/table.sql +0 -9
|
@@ -27,20 +27,6 @@ CREATE TABLE metaschema_modules_public.blueprint (
|
|
|
27
27
|
-- Lineage: where did this come from?
|
|
28
28
|
template_id uuid DEFAULT NULL,
|
|
29
29
|
|
|
30
|
-
-- Execution state
|
|
31
|
-
status text NOT NULL DEFAULT 'draft'
|
|
32
|
-
CHECK (status IN ('draft', 'constructed', 'failed')),
|
|
33
|
-
|
|
34
|
-
constructed_at timestamptz,
|
|
35
|
-
|
|
36
|
-
error_details text,
|
|
37
|
-
|
|
38
|
-
-- Output: mapping of ref names to created table IDs (populated after construct)
|
|
39
|
-
ref_map jsonb NOT NULL DEFAULT '{}',
|
|
40
|
-
|
|
41
|
-
-- Snapshot of the definition at construct-time (immutable record of what was actually executed)
|
|
42
|
-
constructed_definition jsonb,
|
|
43
|
-
|
|
44
30
|
-- Content-addressable Merkle hashes (backend-computed via trigger)
|
|
45
31
|
definition_hash uuid,
|
|
46
32
|
|
|
@@ -56,7 +42,7 @@ CREATE TABLE metaschema_modules_public.blueprint (
|
|
|
56
42
|
);
|
|
57
43
|
|
|
58
44
|
COMMENT ON TABLE metaschema_modules_public.blueprint IS
|
|
59
|
-
'An owned,
|
|
45
|
+
'An owned, editable blueprint scoped to a specific database. Created by copying from a blueprint_template via copy_template_to_blueprint() or built from scratch. The owner can customize the definition at any time. Execute it with construct_blueprint() which creates a separate blueprint_construction record to track the build.';
|
|
60
46
|
|
|
61
47
|
COMMENT ON COLUMN metaschema_modules_public.blueprint.id IS
|
|
62
48
|
'Unique identifier for this blueprint.';
|
|
@@ -77,26 +63,11 @@ COMMENT ON COLUMN metaschema_modules_public.blueprint.description IS
|
|
|
77
63
|
'Optional description of the blueprint.';
|
|
78
64
|
|
|
79
65
|
COMMENT ON COLUMN metaschema_modules_public.blueprint.definition IS
|
|
80
|
-
'The blueprint definition as a JSONB document.
|
|
66
|
+
'The blueprint definition as a JSONB document. Contains tables[] (each with table_name, optional schema_name, nodes[] for data behaviors, fields[], grants[], and policies[] using $type), relations[] (using $type with source_table/target_table and optional source_schema/target_schema), indexes[] (using table_name + column), and full_text_searches[] (using table_name + field + sources[]). Everything is name-based — no UUIDs in the definition.';
|
|
81
67
|
|
|
82
68
|
COMMENT ON COLUMN metaschema_modules_public.blueprint.template_id IS
|
|
83
69
|
'If this blueprint was created by copying a template, the ID of the source template. NULL if built from scratch.';
|
|
84
70
|
|
|
85
|
-
COMMENT ON COLUMN metaschema_modules_public.blueprint.status IS
|
|
86
|
-
'Execution state of the blueprint. draft: not yet executed (definition can still be modified). constructed: successfully executed via construct_blueprint(). failed: execution failed (see error_details). Defaults to draft.';
|
|
87
|
-
|
|
88
|
-
COMMENT ON COLUMN metaschema_modules_public.blueprint.constructed_at IS
|
|
89
|
-
'Timestamp when construct_blueprint() successfully completed. NULL until constructed.';
|
|
90
|
-
|
|
91
|
-
COMMENT ON COLUMN metaschema_modules_public.blueprint.error_details IS
|
|
92
|
-
'Error message from the most recent failed construct_blueprint() attempt. NULL unless status is failed.';
|
|
93
|
-
|
|
94
|
-
COMMENT ON COLUMN metaschema_modules_public.blueprint.ref_map IS
|
|
95
|
-
'Mapping of ref names to created table UUIDs, populated by construct_blueprint() after successful execution. Format: {"products": "uuid", "categories": "uuid", ...}. Defaults to empty object.';
|
|
96
|
-
|
|
97
|
-
COMMENT ON COLUMN metaschema_modules_public.blueprint.constructed_definition IS
|
|
98
|
-
'Immutable snapshot of the definition at construct-time. Preserved so the exact definition that was executed is recorded even if the user later modifies the definition for re-execution. NULL until constructed.';
|
|
99
|
-
|
|
100
71
|
COMMENT ON COLUMN metaschema_modules_public.blueprint.created_at IS
|
|
101
72
|
'Timestamp when this blueprint was created.';
|
|
102
73
|
|
|
@@ -104,7 +75,7 @@ COMMENT ON COLUMN metaschema_modules_public.blueprint.definition_hash IS
|
|
|
104
75
|
'UUIDv5 Merkle root hash of the definition. Computed automatically via trigger from the ordered table_hashes. Used for content-addressable deduplication and provenance tracking. Backend-computed — clients should never set this directly.';
|
|
105
76
|
|
|
106
77
|
COMMENT ON COLUMN metaschema_modules_public.blueprint.table_hashes IS
|
|
107
|
-
'JSONB map of table
|
|
78
|
+
'JSONB map of table names to their individual UUIDv5 content hashes. Each table hash is computed from the canonical jsonb::text of the table entry. Enables structural comparison at the table level across blueprints and templates. Backend-computed via trigger.';
|
|
108
79
|
|
|
109
80
|
COMMENT ON COLUMN metaschema_modules_public.blueprint.updated_at IS
|
|
110
81
|
'Timestamp when this blueprint was last modified.';
|
|
@@ -113,7 +84,6 @@ COMMENT ON COLUMN metaschema_modules_public.blueprint.updated_at IS
|
|
|
113
84
|
CREATE INDEX blueprint_owner_id_idx ON metaschema_modules_public.blueprint (owner_id);
|
|
114
85
|
CREATE INDEX blueprint_database_id_idx ON metaschema_modules_public.blueprint (database_id);
|
|
115
86
|
CREATE INDEX blueprint_template_id_idx ON metaschema_modules_public.blueprint (template_id);
|
|
116
|
-
CREATE INDEX blueprint_status_idx ON metaschema_modules_public.blueprint (status);
|
|
117
87
|
CREATE INDEX blueprint_definition_hash_idx ON metaschema_modules_public.blueprint (definition_hash);
|
|
118
88
|
|
|
119
89
|
COMMIT;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/blueprint_construction/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
-- requires: schemas/metaschema_modules_public/tables/blueprint/table
|
|
5
|
+
|
|
6
|
+
BEGIN;
|
|
7
|
+
|
|
8
|
+
CREATE TABLE metaschema_modules_public.blueprint_construction (
|
|
9
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
10
|
+
|
|
11
|
+
-- What was constructed
|
|
12
|
+
blueprint_id uuid NOT NULL,
|
|
13
|
+
|
|
14
|
+
database_id uuid NOT NULL,
|
|
15
|
+
|
|
16
|
+
-- The schema used as the default for tables without an explicit schema_name
|
|
17
|
+
schema_id uuid,
|
|
18
|
+
|
|
19
|
+
-- Execution state
|
|
20
|
+
status text NOT NULL DEFAULT 'pending'
|
|
21
|
+
CHECK (status IN ('pending', 'constructing', 'constructed', 'failed')),
|
|
22
|
+
|
|
23
|
+
error_details text,
|
|
24
|
+
|
|
25
|
+
-- Output: mapping of table names to created table IDs (populated after construct)
|
|
26
|
+
table_map jsonb NOT NULL DEFAULT '{}',
|
|
27
|
+
|
|
28
|
+
-- Snapshot of the definition at construct-time (immutable record of what was actually executed)
|
|
29
|
+
constructed_definition jsonb,
|
|
30
|
+
|
|
31
|
+
constructed_at timestamptz,
|
|
32
|
+
|
|
33
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
34
|
+
|
|
35
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
36
|
+
|
|
37
|
+
CONSTRAINT blueprint_construction_blueprint_fkey
|
|
38
|
+
FOREIGN KEY (blueprint_id) REFERENCES metaschema_modules_public.blueprint(id) ON DELETE CASCADE,
|
|
39
|
+
CONSTRAINT blueprint_construction_db_fkey
|
|
40
|
+
FOREIGN KEY (database_id) REFERENCES metaschema_public.database(id) ON DELETE CASCADE
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
COMMENT ON TABLE metaschema_modules_public.blueprint_construction IS
|
|
44
|
+
'Tracks individual construction attempts of a blueprint. Each time construct_blueprint() is called, a new record is created here. This separates the editable blueprint definition from its build history, allowing blueprints to be re-executed, constructed into multiple databases, and maintain an audit trail of all construction attempts.';
|
|
45
|
+
|
|
46
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.id IS
|
|
47
|
+
'Unique identifier for this construction attempt.';
|
|
48
|
+
|
|
49
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.blueprint_id IS
|
|
50
|
+
'The blueprint that was constructed.';
|
|
51
|
+
|
|
52
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.database_id IS
|
|
53
|
+
'The database the blueprint was constructed into.';
|
|
54
|
+
|
|
55
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.schema_id IS
|
|
56
|
+
'The default schema used for tables that did not specify an explicit schema_name. NULL if not yet resolved.';
|
|
57
|
+
|
|
58
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.status IS
|
|
59
|
+
'Execution state of this construction attempt. pending: created but not yet started. constructing: currently executing. constructed: successfully completed. failed: execution failed (see error_details).';
|
|
60
|
+
|
|
61
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.error_details IS
|
|
62
|
+
'Error message from a failed construction attempt. NULL unless status is failed.';
|
|
63
|
+
|
|
64
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.table_map IS
|
|
65
|
+
'Mapping of table names to created table UUIDs, populated after successful construction. Format: {"products": "uuid", "categories": "uuid", ...}. Defaults to empty object.';
|
|
66
|
+
|
|
67
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.constructed_definition IS
|
|
68
|
+
'Immutable snapshot of the definition at construct-time. Preserved so the exact definition that was executed is recorded even if the user later modifies the blueprint definition.';
|
|
69
|
+
|
|
70
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.constructed_at IS
|
|
71
|
+
'Timestamp when construction successfully completed. NULL until constructed.';
|
|
72
|
+
|
|
73
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.created_at IS
|
|
74
|
+
'Timestamp when this construction attempt was created.';
|
|
75
|
+
|
|
76
|
+
COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.updated_at IS
|
|
77
|
+
'Timestamp when this construction attempt was last modified.';
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
CREATE INDEX blueprint_construction_blueprint_id_idx ON metaschema_modules_public.blueprint_construction (blueprint_id);
|
|
81
|
+
CREATE INDEX blueprint_construction_database_id_idx ON metaschema_modules_public.blueprint_construction (database_id);
|
|
82
|
+
CREATE INDEX blueprint_construction_status_idx ON metaschema_modules_public.blueprint_construction (status);
|
|
83
|
+
|
|
84
|
+
COMMIT;
|
|
@@ -66,12 +66,10 @@ CREATE TABLE metaschema_modules_public.relation_provision (
|
|
|
66
66
|
expose_in_api boolean NOT NULL DEFAULT true,
|
|
67
67
|
|
|
68
68
|
-- =========================================================================
|
|
69
|
-
-- ManyToMany: field creation (forwarded to
|
|
69
|
+
-- ManyToMany: field creation (forwarded to provision_table)
|
|
70
70
|
-- =========================================================================
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
node_data jsonb NOT NULL DEFAULT '{}',
|
|
72
|
+
nodes jsonb NOT NULL DEFAULT '[]',
|
|
75
73
|
|
|
76
74
|
-- =========================================================================
|
|
77
75
|
-- ManyToMany: grants (forwarded to secure_table_provision)
|
|
@@ -139,7 +137,7 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.database_id IS
|
|
|
139
137
|
'The database this relation belongs to. Required. Must match the database of both source_table_id and target_table_id.';
|
|
140
138
|
|
|
141
139
|
COMMENT ON COLUMN metaschema_modules_public.relation_provision.relation_type IS
|
|
142
|
-
'The type of relation to create. Uses SuperCase naming
|
|
140
|
+
'The type of relation to create. Uses SuperCase naming:
|
|
143
141
|
- RelationBelongsTo: creates a FK field on source_table referencing target_table (e.g., tasks belongs to projects -> tasks.project_id). Field name auto-derived from target table.
|
|
144
142
|
- RelationHasMany: creates a FK field on target_table referencing source_table (e.g., projects has many tasks -> tasks.project_id). Field name auto-derived from source table. Inverse of BelongsTo — same FK, different perspective.
|
|
145
143
|
- RelationHasOne: creates a FK field + unique constraint on source_table referencing target_table (e.g., user_settings has one user -> user_settings.user_id with UNIQUE). Also supports shared-primary-key patterns (e.g., user_profiles.id = users.id) by setting field_name to the existing PK field.
|
|
@@ -246,20 +244,11 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.expose_in_api IS
|
|
|
246
244
|
-- ManyToMany: field creation (forwarded to secure_table_provision)
|
|
247
245
|
-- =============================================================================
|
|
248
246
|
|
|
249
|
-
COMMENT ON COLUMN metaschema_modules_public.relation_provision.
|
|
250
|
-
'For RelationManyToMany:
|
|
251
|
-
Examples: DataId
|
|
252
|
-
|
|
253
|
-
Ignored for RelationBelongsTo/RelationHasOne.';
|
|
254
|
-
|
|
255
|
-
COMMENT ON COLUMN metaschema_modules_public.relation_provision.node_data IS
|
|
256
|
-
'For RelationManyToMany: configuration passed to the generator function for field creation on the junction table. Forwarded to secure_table_provision as-is. The trigger does not interpret or validate this value.
|
|
257
|
-
Only used when node_type is set. Structure varies by node_type. Examples:
|
|
258
|
-
- DataId: {"field_name": "id"} (default field name is ''id'')
|
|
259
|
-
- DataEntityMembership: {"entity_field_name": "entity_id", "include_id": false, "include_user_fk": true}
|
|
260
|
-
- DataDirectOwner: {"owner_field_name": "owner_id"}
|
|
261
|
-
Defaults to ''{}'' (empty object).
|
|
262
|
-
Ignored for RelationBelongsTo/RelationHasOne.';
|
|
247
|
+
COMMENT ON COLUMN metaschema_modules_public.relation_provision.nodes IS
|
|
248
|
+
'For RelationManyToMany: array of node objects to apply to the junction table. Each element is a jsonb object with a required "$type" key and an optional "data" key. Forwarded to provision_table as-is. The trigger does not interpret or validate this value.
|
|
249
|
+
Examples: [{"$type": "DataId"}, {"$type": "DataTimestamps"}, {"$type": "DataDirectOwner", "data": {"owner_field_name": "author_id"}}].
|
|
250
|
+
Defaults to ''[]'' (no node processing beyond the FK fields and composite key if use_composite_key is true).
|
|
251
|
+
Ignored for RelationBelongsTo/RelationHasOne/RelationHasMany.';
|
|
263
252
|
|
|
264
253
|
-- =============================================================================
|
|
265
254
|
-- ManyToMany: grants (forwarded to secure_table_provision)
|
|
@@ -15,12 +15,10 @@ CREATE TABLE metaschema_modules_public.secure_table_provision (
|
|
|
15
15
|
|
|
16
16
|
table_name text DEFAULT NULL,
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
nodes jsonb NOT NULL DEFAULT '[]',
|
|
19
19
|
|
|
20
20
|
use_rls boolean NOT NULL DEFAULT true,
|
|
21
21
|
|
|
22
|
-
node_data jsonb NOT NULL DEFAULT '{}',
|
|
23
|
-
|
|
24
22
|
fields jsonb[] NOT NULL DEFAULT '{}',
|
|
25
23
|
|
|
26
24
|
grant_roles text[] NOT NULL DEFAULT ARRAY['authenticated'],
|
|
@@ -47,7 +45,7 @@ CREATE TABLE metaschema_modules_public.secure_table_provision (
|
|
|
47
45
|
);
|
|
48
46
|
|
|
49
47
|
COMMENT ON TABLE metaschema_modules_public.secure_table_provision IS
|
|
50
|
-
'Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via
|
|
48
|
+
'Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via nodes[] array (supporting multiple Data* modules per row), (2) grant privileges via grant_privileges, (3) create RLS policies via policy_type. Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent.';
|
|
51
49
|
|
|
52
50
|
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.id IS
|
|
53
51
|
'Unique identifier for this provision row.';
|
|
@@ -64,14 +62,12 @@ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.table_id IS
|
|
|
64
62
|
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.table_name IS
|
|
65
63
|
'Name of the target table. Used to create or look up the table when table_id is not provided. If omitted, it is backfilled from the resolved table.';
|
|
66
64
|
|
|
67
|
-
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.
|
|
68
|
-
'
|
|
65
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.nodes IS
|
|
66
|
+
'Array of node objects to apply to the table. Each element is a jsonb object with a required "$type" key (one of: DataId, DataDirectOwner, DataEntityMembership, DataOwnershipInEntity, DataTimestamps, DataPeoplestamps, DataPublishable, DataSoftDelete, DataEmbedding, DataFullTextSearch, DataSlug, etc.) and an optional "data" key containing generator-specific configuration. Supports multiple nodes per row, matching the blueprint definition format. Example: [{"$type": "DataId"}, {"$type": "DataTimestamps"}, {"$type": "DataDirectOwner", "data": {"owner_field_name": "author_id"}}]. Defaults to ''[]'' (no node processing).';
|
|
69
67
|
|
|
70
68
|
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.use_rls IS
|
|
71
69
|
'If true and Row Level Security is not yet enabled on the target table, enable it. Automatically set to true by the trigger when policy_type is provided. Defaults to true.';
|
|
72
70
|
|
|
73
|
-
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.node_data IS
|
|
74
|
-
'Configuration passed to the generator function for field creation (only used when node_type is set). Known keys include: field_name (text, default ''id'') for DataId, owner_field_name (text, default ''owner_id'') for DataDirectOwner/DataOwnershipInEntity, entity_field_name (text, default ''entity_id'') for DataEntityMembership/DataOwnershipInEntity, include_id (boolean, default true) for most node_types, include_user_fk (boolean, default true) to add FK to users table, create_index (boolean, default true) to create btree indexes on FK fields for join and cascade performance. Defaults to ''{}''.';
|
|
75
71
|
|
|
76
72
|
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.fields IS
|
|
77
73
|
'PostgreSQL array of jsonb field definition objects to create on the target table. Each object has keys: "name" (text, required), "type" (text, required), "default" (text, optional), "is_required" (boolean, optional, defaults to false), "min" (float, optional), "max" (float, optional), "regexp" (text, optional), "index" (boolean, optional, defaults to false — creates a btree index on the field). min/max generate CHECK constraints: for text/citext they constrain character_length, for integer/float types they constrain the value. regexp generates a CHECK (col ~ pattern) constraint for text/citext. Fields are created via metaschema.create_field() after any node_type generator runs, and their IDs are appended to out_fields. Example: ARRAY[''{"name":"username","type":"citext","max":256,"regexp":"^[a-z0-9_]+$"}''::jsonb, ''{"name":"score","type":"integer","min":0,"max":100}''::jsonb]. Defaults to ''{}'' (no additional fields).';
|
|
@@ -101,11 +97,10 @@ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_data I
|
|
|
101
97
|
'Opaque configuration passed through to metaschema.create_policy(). Structure varies by policy_type and is not interpreted by this trigger. Defaults to ''{}''.';
|
|
102
98
|
|
|
103
99
|
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.out_fields IS
|
|
104
|
-
'Output column populated by the trigger after field creation. Contains the UUIDs of the metaschema fields created on the target table by this provision row''s
|
|
100
|
+
'Output column populated by the trigger after field creation. Contains the UUIDs of the metaschema fields created on the target table by this provision row''s nodes. NULL when nodes is empty or before the trigger runs. Callers should not set this directly.';
|
|
105
101
|
|
|
106
102
|
|
|
107
103
|
CREATE INDEX secure_table_provision_database_id_idx ON metaschema_modules_public.secure_table_provision ( database_id );
|
|
108
104
|
CREATE INDEX secure_table_provision_table_id_idx ON metaschema_modules_public.secure_table_provision ( table_id );
|
|
109
|
-
CREATE INDEX secure_table_provision_node_type_idx ON metaschema_modules_public.secure_table_provision ( node_type );
|
|
110
105
|
|
|
111
106
|
COMMIT;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/storage_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.storage_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
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
|
+
-- Generated table IDs (populated by the generator)
|
|
16
|
+
buckets_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
files_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
18
|
+
upload_requests_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
19
|
+
|
|
20
|
+
-- Table names (input to the generator)
|
|
21
|
+
buckets_table_name text NOT NULL DEFAULT 'buckets',
|
|
22
|
+
files_table_name text NOT NULL DEFAULT 'files',
|
|
23
|
+
upload_requests_table_name text NOT NULL DEFAULT 'upload_requests',
|
|
24
|
+
|
|
25
|
+
-- Entity table for RLS (users table, since users and orgs share it)
|
|
26
|
+
entity_table_id uuid NULL,
|
|
27
|
+
|
|
28
|
+
-- Per-database configurable settings (NULL = use plugin defaults)
|
|
29
|
+
upload_url_expiry_seconds integer NULL, -- Presigned PUT URL expiry (default: 900 = 15 min)
|
|
30
|
+
download_url_expiry_seconds integer NULL, -- Presigned GET URL expiry (default: 3600 = 1 hour)
|
|
31
|
+
default_max_file_size bigint NULL, -- Global max file size in bytes (default: 200MB). Bucket-level overrides this.
|
|
32
|
+
max_filename_length integer NULL, -- Max filename length in chars (default: 1024)
|
|
33
|
+
cache_ttl_seconds integer NULL, -- LRU cache TTL for this config (default: 300 dev / 3600 prod)
|
|
34
|
+
|
|
35
|
+
-- Constraints
|
|
36
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
37
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
38
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
39
|
+
CONSTRAINT buckets_table_fkey FOREIGN KEY (buckets_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
40
|
+
CONSTRAINT files_table_fkey FOREIGN KEY (files_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
41
|
+
CONSTRAINT upload_requests_table_fkey FOREIGN KEY (upload_requests_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
42
|
+
CONSTRAINT entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module ( database_id );
|
|
46
|
+
|
|
47
|
+
COMMIT;
|
|
@@ -16,7 +16,7 @@ CREATE TABLE metaschema_modules_public.table_template_module (
|
|
|
16
16
|
|
|
17
17
|
table_name text NOT NULL,
|
|
18
18
|
|
|
19
|
-
-- Node type
|
|
19
|
+
-- Node type (e.g., 'TableUserProfiles', 'TableOrganizationSettings', 'TableUserSettings')
|
|
20
20
|
node_type text NOT NULL,
|
|
21
21
|
|
|
22
22
|
-- Type-specific parameters as jsonb
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/metaschema-modules",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Module metadata handling and dependency tracking",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pgpm/metaschema-schema": "0.20.
|
|
24
|
+
"@pgpm/metaschema-schema": "0.20.2",
|
|
25
25
|
"@pgpm/verify": "0.20.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "109293dbfe8c205a9265ab36c8cb99efa5dcc1fb"
|
|
39
39
|
}
|
package/pgpm.plan
CHANGED
|
@@ -13,7 +13,6 @@ schemas/metaschema_modules_public/tables/default_ids_module/table [schemas/metas
|
|
|
13
13
|
schemas/metaschema_modules_public/tables/denormalized_table_field/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/denormalized_table_field/table
|
|
14
14
|
schemas/metaschema_modules_public/tables/emails_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/emails_module/table
|
|
15
15
|
schemas/metaschema_modules_public/tables/encrypted_secrets_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/encrypted_secrets_module/table
|
|
16
|
-
schemas/metaschema_modules_public/tables/field_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/field_module/table
|
|
17
16
|
schemas/metaschema_modules_public/tables/invites_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/invites_module/table
|
|
18
17
|
schemas/metaschema_modules_public/tables/levels_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/levels_module/table
|
|
19
18
|
schemas/metaschema_modules_public/tables/limits_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/limits_module/table
|
|
@@ -35,3 +34,5 @@ schemas/metaschema_modules_public/tables/secure_table_provision/table [schemas/m
|
|
|
35
34
|
schemas/metaschema_modules_public/tables/relation_provision/table [schemas/metaschema_modules_public/schema] 2026-02-26T00:00:00Z Constructive <developers@constructive.io> # add schemas/metaschema_modules_public/tables/relation_provision/table
|
|
36
35
|
schemas/metaschema_modules_public/tables/blueprint_template/table [schemas/metaschema_modules_public/schema] 2026-03-20T00:00:00Z Constructive <developers@constructive.io> # add blueprint_template table for shareable schema recipes
|
|
37
36
|
schemas/metaschema_modules_public/tables/blueprint/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/blueprint_template/table] 2026-03-20T00:00:01Z Constructive <developers@constructive.io> # add blueprint table for owned executable blueprints
|
|
37
|
+
schemas/metaschema_modules_public/tables/blueprint_construction/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/blueprint/table] 2026-03-31T00:00:00Z Constructive <developers@constructive.io> # add blueprint_construction table for construction state tracking
|
|
38
|
+
schemas/metaschema_modules_public/tables/storage_module/table [schemas/metaschema_modules_public/schema] 2026-03-24T00:00:00Z devin <devin@cognition.ai> # add storage_module config table for files and buckets
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- Verify schemas/metaschema_modules_public/tables/blueprint_construction/table
|
|
2
|
+
|
|
3
|
+
BEGIN;
|
|
4
|
+
|
|
5
|
+
SELECT id, blueprint_id, database_id, schema_id, status, error_details,
|
|
6
|
+
table_map, constructed_definition, constructed_at, created_at, updated_at
|
|
7
|
+
FROM metaschema_modules_public.blueprint_construction
|
|
8
|
+
WHERE FALSE;
|
|
9
|
+
|
|
10
|
+
ROLLBACK;
|
|
@@ -18,14 +18,16 @@ SELECT
|
|
|
18
18
|
source_field_name,
|
|
19
19
|
target_field_name,
|
|
20
20
|
use_composite_key,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
create_index,
|
|
22
|
+
expose_in_api,
|
|
23
|
+
nodes,
|
|
23
24
|
grant_roles,
|
|
24
25
|
grant_privileges,
|
|
25
26
|
policy_type,
|
|
26
27
|
policy_privileges,
|
|
27
28
|
policy_role,
|
|
28
29
|
policy_permissive,
|
|
30
|
+
policy_name,
|
|
29
31
|
policy_data,
|
|
30
32
|
out_field_id,
|
|
31
33
|
out_junction_table_id,
|
|
@@ -1,39 +0,0 @@
|
|
|
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 uuidv7(),
|
|
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
|
-
-- Node type from node_type_registry (e.g., 'FieldSlug', 'FieldImmutable', 'FieldInflection', 'FieldOwned')
|
|
17
|
-
node_type text NOT NULL,
|
|
18
|
-
|
|
19
|
-
-- Type-specific parameters as jsonb
|
|
20
|
-
-- FieldSlug: {"source_field_id": "uuid"}
|
|
21
|
-
-- FieldImmutable: {} (no extra params)
|
|
22
|
-
-- FieldInflection: {"ops": ["snake_case", "uppercase"]}
|
|
23
|
-
-- FieldOwned: {"role_key_field_id": "uuid", "protected_field_ids": ["uuid", ...]}
|
|
24
|
-
data jsonb NOT NULL DEFAULT '{}',
|
|
25
|
-
|
|
26
|
-
triggers text[],
|
|
27
|
-
functions text[],
|
|
28
|
-
|
|
29
|
-
--
|
|
30
|
-
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
31
|
-
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
32
|
-
CONSTRAINT field_fkey FOREIGN KEY (field_id) REFERENCES metaschema_public.field (id) ON DELETE CASCADE,
|
|
33
|
-
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
CREATE INDEX field_module_database_id_idx ON metaschema_modules_public.field_module ( database_id );
|
|
37
|
-
CREATE INDEX field_module_node_type_idx ON metaschema_modules_public.field_module ( node_type );
|
|
38
|
-
|
|
39
|
-
COMMIT;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
-- Verify schemas/metaschema_modules_public/tables/field_module/table on pg
|
|
2
|
-
|
|
3
|
-
BEGIN;
|
|
4
|
-
|
|
5
|
-
SELECT id, database_id, private_schema_id, table_id, field_id, node_type, data, triggers, functions
|
|
6
|
-
FROM metaschema_modules_public.field_module
|
|
7
|
-
WHERE FALSE;
|
|
8
|
-
|
|
9
|
-
ROLLBACK;
|