diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6acd0985a..e34cf74d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,11 +41,11 @@ jobs: PGPORT: 5432 PGUSER: postgres PGPASSWORD: password - PGPM_VERSION: 2.7.9 + PGPM_VERSION: 4.7.4 services: pg_db: - image: pyramation/pgvector:13.3-alpine + image: constructiveio/postgres-plus:18 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: password diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index c4e9ac5d3..e27de8438 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -15,11 +15,11 @@ jobs: PGPORT: 5432 PGUSER: postgres PGPASSWORD: password - PGPM_VERSION: 2.7.9 + PGPM_VERSION: 4.7.4 services: pg_db: - image: pyramation/pgvector:13.3-alpine + image: constructiveio/postgres-plus:18 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: password diff --git a/packages/achievements/deploy/schemas/status_public/tables/level_requirements/table.sql b/packages/achievements/deploy/schemas/status_public/tables/level_requirements/table.sql index b762b7036..0bbfb6b00 100644 --- a/packages/achievements/deploy/schemas/status_public/tables/level_requirements/table.sql +++ b/packages/achievements/deploy/schemas/status_public/tables/level_requirements/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE status_public.level_requirements ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), name text NOT NULL, level text NOT NULL, required_count int DEFAULT 1, diff --git a/packages/achievements/deploy/schemas/status_public/tables/user_achievements/table.sql b/packages/achievements/deploy/schemas/status_public/tables/user_achievements/table.sql index 0f9e9756d..e2d5f146f 100644 --- a/packages/achievements/deploy/schemas/status_public/tables/user_achievements/table.sql +++ b/packages/achievements/deploy/schemas/status_public/tables/user_achievements/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE status_public.user_achievements ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), user_id uuid NOT NULL, name text NOT NULL, -- relates to level_requirements.name count int NOT NULL DEFAULT 0, diff --git a/packages/achievements/deploy/schemas/status_public/tables/user_levels/table.sql b/packages/achievements/deploy/schemas/status_public/tables/user_levels/table.sql index 62a5c8446..50467d4c7 100644 --- a/packages/achievements/deploy/schemas/status_public/tables/user_levels/table.sql +++ b/packages/achievements/deploy/schemas/status_public/tables/user_levels/table.sql @@ -7,7 +7,7 @@ BEGIN; -- NOT using yet, so commented it out for simplicity -- CREATE TABLE status_public.user_levels ( --- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), +-- id uuid PRIMARY KEY DEFAULT uuidv7(), -- user_id uuid NOT NULL, -- name text NOT NULL, -- references levels -- created_at timestamptz NOT NULL DEFAULT current_timestamp diff --git a/packages/achievements/deploy/schemas/status_public/tables/user_steps/table.sql b/packages/achievements/deploy/schemas/status_public/tables/user_steps/table.sql index 3164a30c8..0ec40b964 100644 --- a/packages/achievements/deploy/schemas/status_public/tables/user_steps/table.sql +++ b/packages/achievements/deploy/schemas/status_public/tables/user_steps/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE status_public.user_steps ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), user_id uuid NOT NULL, name text NOT NULL, -- references level_requirement count int NOT NULL DEFAULT 1, diff --git a/packages/achievements/pgpm-achievements.control b/packages/achievements/pgpm-achievements.control index a6464ccd6..f685b6086 100644 --- a/packages/achievements/pgpm-achievements.control +++ b/packages/achievements/pgpm-achievements.control @@ -1,8 +1,8 @@ # pgpm-achievements extension comment = 'pgpm-achievements extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-achievements' -requires = 'plpgsql,uuid-ossp,pgpm-jwt-claims,pgpm-verify' +requires = 'plpgsql,pgpm-jwt-claims,pgpm-verify' relocatable = false superuser = false \ No newline at end of file diff --git a/packages/base32/pgpm-base32.control b/packages/base32/pgpm-base32.control index c5e4aec94..918b62397 100644 --- a/packages/base32/pgpm-base32.control +++ b/packages/base32/pgpm-base32.control @@ -1,6 +1,6 @@ # pgpm-base32 extension comment = 'pgpm-base32 extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-base32' requires = 'pgcrypto,plpgsql,pgpm-verify' relocatable = false diff --git a/packages/database-jobs/pgpm-database-jobs.control b/packages/database-jobs/pgpm-database-jobs.control index 228d7e070..f9e37ea50 100644 --- a/packages/database-jobs/pgpm-database-jobs.control +++ b/packages/database-jobs/pgpm-database-jobs.control @@ -1,8 +1,8 @@ # pgpm-database-jobs extension comment = 'pgpm-database-jobs extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-database-jobs' -requires = 'plpgsql,uuid-ossp,pgcrypto,pgpm-verify' +requires = 'plpgsql,pgcrypto,pgpm-verify' relocatable = false superuser = false diff --git a/packages/defaults/pgpm-defaults.control b/packages/defaults/pgpm-defaults.control index d4e112a5b..3cf5c7d6a 100644 --- a/packages/defaults/pgpm-defaults.control +++ b/packages/defaults/pgpm-defaults.control @@ -1,6 +1,6 @@ # pgpm-defaults extension comment = 'pgpm-defaults extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-defaults' requires = 'plpgsql,pgpm-verify' relocatable = false diff --git a/packages/encrypted-secrets-table/__tests__/__snapshots__/secrets-table.test.ts.snap b/packages/encrypted-secrets-table/__tests__/__snapshots__/secrets-table.test.ts.snap index bb2e1d3b3..aa6ea3076 100644 --- a/packages/encrypted-secrets-table/__tests__/__snapshots__/secrets-table.test.ts.snap +++ b/packages/encrypted-secrets-table/__tests__/__snapshots__/secrets-table.test.ts.snap @@ -4,7 +4,7 @@ exports[`encrypted secrets table should have secrets_table with correct structur { "columns": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", "data_type": "uuid", "is_nullable": "NO", diff --git a/packages/encrypted-secrets-table/deploy/schemas/secrets_schema/tables/secrets_table/table.sql b/packages/encrypted-secrets-table/deploy/schemas/secrets_schema/tables/secrets_table/table.sql index 3466fdc0c..f0b12669d 100644 --- a/packages/encrypted-secrets-table/deploy/schemas/secrets_schema/tables/secrets_table/table.sql +++ b/packages/encrypted-secrets-table/deploy/schemas/secrets_schema/tables/secrets_table/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE secrets_schema.secrets_table ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), secrets_owned_field uuid NOT NULL, name text NOT NULL, secrets_value_field bytea NULL, diff --git a/packages/encrypted-secrets-table/pgpm-encrypted-secrets-table.control b/packages/encrypted-secrets-table/pgpm-encrypted-secrets-table.control index c095ff2c9..9a646ee30 100644 --- a/packages/encrypted-secrets-table/pgpm-encrypted-secrets-table.control +++ b/packages/encrypted-secrets-table/pgpm-encrypted-secrets-table.control @@ -1,8 +1,8 @@ # pgpm-encrypted-secrets-table extension comment = 'pgpm-encrypted-secrets-table extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-encrypted-secrets-table' -requires = 'pgcrypto,plpgsql,uuid-ossp,pgpm-verify' +requires = 'pgcrypto,plpgsql,pgpm-verify' relocatable = false superuser = false \ No newline at end of file diff --git a/packages/encrypted-secrets/pgpm-encrypted-secrets.control b/packages/encrypted-secrets/pgpm-encrypted-secrets.control index 4c1f076c1..b1c35cf60 100644 --- a/packages/encrypted-secrets/pgpm-encrypted-secrets.control +++ b/packages/encrypted-secrets/pgpm-encrypted-secrets.control @@ -1,8 +1,8 @@ # pgpm-encrypted-secrets extension comment = 'pgpm-encrypted-secrets extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-encrypted-secrets' -requires = 'pgcrypto,plpgsql,uuid-ossp,pgpm-encrypted-secrets-table,pgpm-verify' +requires = 'pgcrypto,plpgsql,pgpm-encrypted-secrets-table,pgpm-verify' relocatable = false superuser = false diff --git a/packages/faker/deploy/schemas/faker/procedures/utils.sql b/packages/faker/deploy/schemas/faker/procedures/utils.sql index 0362188bf..f37dd51f2 100644 --- a/packages/faker/deploy/schemas/faker/procedures/utils.sql +++ b/packages/faker/deploy/schemas/faker/procedures/utils.sql @@ -420,7 +420,7 @@ LANGUAGE 'sql'; CREATE FUNCTION faker.uuid() returns uuid as $$ SELECT - uuid_generate_v4(); + uuidv7(); $$ LANGUAGE 'sql'; diff --git a/packages/faker/deploy/schemas/faker/tables/cities/table.sql b/packages/faker/deploy/schemas/faker/tables/cities/table.sql index 02f4400df..589ad6dac 100644 --- a/packages/faker/deploy/schemas/faker/tables/cities/table.sql +++ b/packages/faker/deploy/schemas/faker/tables/cities/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE faker.cities ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), city text, state text, zips int[], diff --git a/packages/faker/deploy/schemas/faker/tables/dictionary/table.sql b/packages/faker/deploy/schemas/faker/tables/dictionary/table.sql index bf68f163c..da30648c2 100644 --- a/packages/faker/deploy/schemas/faker/tables/dictionary/table.sql +++ b/packages/faker/deploy/schemas/faker/tables/dictionary/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE faker.dictionary ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), type text, word text ); diff --git a/packages/faker/pgpm-faker.control b/packages/faker/pgpm-faker.control index 463bd49dd..fee340bdd 100644 --- a/packages/faker/pgpm-faker.control +++ b/packages/faker/pgpm-faker.control @@ -1,8 +1,8 @@ # pgpm-faker extension comment = 'pgpm-faker extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-faker' -requires = 'citext,pgcrypto,plpgsql,uuid-ossp,pgpm-types,pgpm-verify' +requires = 'citext,pgcrypto,plpgsql,pgpm-types,pgpm-verify' relocatable = false superuser = false \ No newline at end of file diff --git a/packages/geotypes/pgpm-geo-types.control b/packages/geotypes/pgpm-geo-types.control index aed899b0b..86fcf7e92 100644 --- a/packages/geotypes/pgpm-geo-types.control +++ b/packages/geotypes/pgpm-geo-types.control @@ -1,6 +1,6 @@ # pgpm-geo-types extension comment = 'pgpm-geo-types extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-geo-types' requires = 'plpgsql,citext,postgis,pgpm-types,pgpm-verify' relocatable = false diff --git a/packages/inflection/deploy/schemas/inflection/tables/inflection_rules/table.sql b/packages/inflection/deploy/schemas/inflection/tables/inflection_rules/table.sql index 7344f159a..89f1e6b1f 100644 --- a/packages/inflection/deploy/schemas/inflection/tables/inflection_rules/table.sql +++ b/packages/inflection/deploy/schemas/inflection/tables/inflection_rules/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE inflection.inflection_rules ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), type text, -- singular, plural test text, replacement text diff --git a/packages/inflection/pgpm-inflection.control b/packages/inflection/pgpm-inflection.control index aad5e6649..1049a69bb 100644 --- a/packages/inflection/pgpm-inflection.control +++ b/packages/inflection/pgpm-inflection.control @@ -1,8 +1,8 @@ # pgpm-inflection extension comment = 'pgpm-inflection extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-inflection' -requires = 'plpgsql,unaccent,uuid-ossp,pgpm-verify' +requires = 'plpgsql,unaccent,pgpm-verify' relocatable = false superuser = false \ No newline at end of file diff --git a/packages/jobs/pgpm-jobs.control b/packages/jobs/pgpm-jobs.control index 234dce6ef..ef3af2e2b 100644 --- a/packages/jobs/pgpm-jobs.control +++ b/packages/jobs/pgpm-jobs.control @@ -1,8 +1,8 @@ # pgpm-jobs extension comment = 'pgpm-jobs extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-jobs' -requires = 'plpgsql,uuid-ossp,pgcrypto,pgpm-verify' +requires = 'plpgsql,pgcrypto,pgpm-verify' relocatable = false superuser = false diff --git a/packages/jwt-claims/pgpm-jwt-claims.control b/packages/jwt-claims/pgpm-jwt-claims.control index ebf219343..a5260b5f2 100644 --- a/packages/jwt-claims/pgpm-jwt-claims.control +++ b/packages/jwt-claims/pgpm-jwt-claims.control @@ -2,7 +2,7 @@ comment = 'pgpm-jwt-claims extension' default_version = '0.15.5' module_pathname = '$libdir/pgpm-jwt-claims' -requires = 'plpgsql,uuid-ossp,pgpm-types,pgpm-verify' +requires = 'plpgsql,pgpm-types,pgpm-verify' relocatable = false superuser = false diff --git a/packages/measurements/measurements.control b/packages/measurements/measurements.control index f918719f6..b5ca5dbd4 100644 --- a/packages/measurements/measurements.control +++ b/packages/measurements/measurements.control @@ -2,7 +2,7 @@ comment = 'measurements extension' default_version = '0.0.1' module_pathname = '$libdir/measurements' -requires = 'plpgsql,uuid-ossp,pgpm-verify' +requires = 'plpgsql,pgpm-verify' relocatable = false superuser = false \ No newline at end of file diff --git a/packages/measurements/pgpm-measurements.control b/packages/measurements/pgpm-measurements.control index ba83bcdf6..d25354ecf 100644 --- a/packages/measurements/pgpm-measurements.control +++ b/packages/measurements/pgpm-measurements.control @@ -1,6 +1,6 @@ # pgpm-measurements extension comment = 'pgpm-measurements extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-measurements' requires = 'plpgsql,pgpm-verify' relocatable = false diff --git a/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap b/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap index b1795f3f4..42722cecd 100644 --- a/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap +++ b/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap @@ -22,18 +22,16 @@ exports[`db_meta_modules should have all expected module tables 1`] = ` "rls_module", "secrets_module", "sessions_module", - "table_module", "table_template_module", "user_auth_module", "users_module", - "uuid_module", ], } `; exports[`db_meta_modules should verify all module tables exist in metaschema_modules_public schema 1`] = ` { - "moduleTablesCount": 24, + "moduleTablesCount": 22, "totalTables": 27, } `; @@ -42,7 +40,7 @@ exports[`db_meta_modules should verify emails_module table structure 1`] = ` { "columns": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", "data_type": "uuid", "is_nullable": "NO", @@ -91,7 +89,7 @@ exports[`db_meta_modules should verify field_module table structure 1`] = ` { "columns": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", "data_type": "uuid", "is_nullable": "NO", @@ -150,15 +148,14 @@ exports[`db_meta_modules should verify field_module table structure 1`] = ` exports[`db_meta_modules should verify module table structures have database_id foreign keys 1`] = ` { - "constraintCount": 72600, + "constraintCount": 64152, } `; exports[`db_meta_modules should verify module tables have proper foreign key relationships 1`] = ` { - "constraintCount": 104821, + "constraintCount": 91658, "foreignTables": [ - "apis", "database", "field", "schema", @@ -171,7 +168,7 @@ exports[`db_meta_modules should verify sessions_module table structure 1`] = ` { "columns": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", "data_type": "uuid", "is_nullable": "NO", @@ -252,7 +249,7 @@ exports[`db_meta_modules should verify specific module table column defaults 1`] "column_name": "auth_settings_table_id", }, { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", }, { @@ -286,7 +283,7 @@ exports[`db_meta_modules should verify specific module table column defaults 1`] ], "usersDefaults": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", }, { @@ -313,72 +310,11 @@ exports[`db_meta_modules should verify specific module table column defaults 1`] } `; -exports[`db_meta_modules should verify table_module table structure 1`] = ` -{ - "columns": [ - { - "column_default": "uuid_generate_v4()", - "column_name": "id", - "data_type": "uuid", - "is_nullable": "NO", - }, - { - "column_default": null, - "column_name": "database_id", - "data_type": "uuid", - "is_nullable": "NO", - }, - { - "column_default": "uuid_nil()", - "column_name": "schema_id", - "data_type": "uuid", - "is_nullable": "NO", - }, - { - "column_default": "uuid_nil()", - "column_name": "table_id", - "data_type": "uuid", - "is_nullable": "NO", - }, - { - "column_default": null, - "column_name": "table_name", - "data_type": "text", - "is_nullable": "YES", - }, - { - "column_default": null, - "column_name": "node_type", - "data_type": "text", - "is_nullable": "NO", - }, - { - "column_default": "true", - "column_name": "use_rls", - "data_type": "boolean", - "is_nullable": "NO", - }, - { - "column_default": "'{}'::jsonb", - "column_name": "data", - "data_type": "jsonb", - "is_nullable": "NO", - }, - { - "column_default": null, - "column_name": "fields", - "data_type": "ARRAY", - "is_nullable": "YES", - }, - ], -} -`; - exports[`db_meta_modules should verify table_template_module table structure 1`] = ` { "columns": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", "data_type": "uuid", "is_nullable": "NO", @@ -439,7 +375,7 @@ exports[`db_meta_modules should verify users_module table structure 1`] = ` { "columns": [ { - "column_default": "uuid_generate_v4()", + "column_default": "uuidv7()", "column_name": "id", "data_type": "uuid", "is_nullable": "NO", diff --git a/packages/metaschema-modules/__tests__/modules.test.ts b/packages/metaschema-modules/__tests__/modules.test.ts index 61ec79881..7246c8e82 100644 --- a/packages/metaschema-modules/__tests__/modules.test.ts +++ b/packages/metaschema-modules/__tests__/modules.test.ts @@ -39,11 +39,9 @@ describe('db_meta_modules', () => { 'rls_module', 'secrets_module', 'sessions_module', - 'table_module', 'table_template_module', 'user_auth_module', - 'users_module', - 'uuid_module' + 'users_module' ]; // Query for all module tables in metaschema_modules_public schema @@ -284,35 +282,6 @@ describe('db_meta_modules', () => { expect(snapshot({ columns })).toMatchSnapshot(); }); - // Test for unified table_module with node_type - it('should verify table_module table structure', async () => { - const columns = await pg.any(` - SELECT - column_name, - data_type, - is_nullable, - column_default - FROM information_schema.columns - WHERE table_schema = 'metaschema_modules_public' - AND table_name = 'table_module' - ORDER BY ordinal_position - `); - - // Check that key columns exist - const columnNames = columns.map(c => c.column_name); - expect(columnNames).toContain('id'); - expect(columnNames).toContain('database_id'); - expect(columnNames).toContain('schema_id'); - expect(columnNames).toContain('table_id'); - expect(columnNames).toContain('table_name'); - expect(columnNames).toContain('node_type'); - expect(columnNames).toContain('use_rls'); - expect(columnNames).toContain('data'); - expect(columnNames).toContain('fields'); - - expect(snapshot({ columns })).toMatchSnapshot(); - }); - // Test for table_template_module with node_type for table creation templates it('should verify table_template_module table structure', async () => { const columns = await pg.any(` @@ -341,4 +310,4 @@ describe('db_meta_modules', () => { expect(snapshot({ columns })).toMatchSnapshot(); }); -}); \ No newline at end of file +}); \ No newline at end of file diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/blueprint/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/blueprint/table.sql new file mode 100644 index 000000000..75353e23d --- /dev/null +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/blueprint/table.sql @@ -0,0 +1,119 @@ +-- Deploy schemas/metaschema_modules_public/tables/blueprint/table to pg + +-- requires: schemas/metaschema_modules_public/schema +-- requires: schemas/metaschema_modules_public/tables/blueprint_template/table + +BEGIN; + +CREATE TABLE metaschema_modules_public.blueprint ( + id uuid PRIMARY KEY DEFAULT uuidv7(), + + -- Ownership + scoping + owner_id uuid NOT NULL, + + database_id uuid NOT NULL, + + -- Identity + name text NOT NULL, + + display_name text NOT NULL, + + description text, + + -- The blueprint definition (tables with nodes[] and policies[], relations with $type) + -- This is a mutable copy — the owner can customize before executing + definition jsonb NOT NULL, + + -- Lineage: where did this come from? + template_id uuid DEFAULT NULL, + + -- Execution state + status text NOT NULL DEFAULT 'draft' + CHECK (status IN ('draft', 'constructed', 'failed')), + + constructed_at timestamptz, + + error_details text, + + -- Output: mapping of ref names to created table IDs (populated after construct) + ref_map jsonb NOT NULL DEFAULT '{}', + + -- Snapshot of the definition at construct-time (immutable record of what was actually executed) + constructed_definition jsonb, + + -- Content-addressable Merkle hashes (backend-computed via trigger) + definition_hash uuid, + + table_hashes jsonb, + + created_at timestamptz NOT NULL DEFAULT now(), + + updated_at timestamptz NOT NULL DEFAULT now(), + + CONSTRAINT blueprint_unique_database_name UNIQUE (database_id, name), + CONSTRAINT blueprint_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, + CONSTRAINT blueprint_template_fkey FOREIGN KEY (template_id) REFERENCES metaschema_modules_public.blueprint_template (id) +); + +COMMENT ON TABLE metaschema_modules_public.blueprint IS + 'An owned, executable 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 before executing it with construct_blueprint(). Each blueprint tracks its execution status (draft/constructed/failed) and stores the ref_map of created table IDs after construction.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.id IS + 'Unique identifier for this blueprint.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.owner_id IS + 'The user who owns this blueprint.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.database_id IS + 'The database this blueprint is scoped to. Tables created by construct_blueprint() are provisioned in this database.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.name IS + 'Machine-readable name for the blueprint. Must be unique per database.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.display_name IS + 'Human-readable display name for the blueprint.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.description IS + 'Optional description of the blueprint.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.definition IS + 'The blueprint definition as a JSONB document. Same format as blueprint_template.definition: contains tables[] (with nodes[], fields[], grants[], policies[] using $type) and relations[] (using $type). This is a mutable copy that the owner can customize before executing.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.template_id IS + 'If this blueprint was created by copying a template, the ID of the source template. NULL if built from scratch.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.status IS + '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.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.constructed_at IS + 'Timestamp when construct_blueprint() successfully completed. NULL until constructed.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.error_details IS + 'Error message from the most recent failed construct_blueprint() attempt. NULL unless status is failed.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.ref_map IS + 'Mapping of ref names to created table UUIDs, populated by construct_blueprint() after successful execution. Format: {"products": "uuid", "categories": "uuid", ...}. Defaults to empty object.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.constructed_definition IS + '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.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.created_at IS + 'Timestamp when this blueprint was created.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.definition_hash IS + '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.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.table_hashes IS + 'JSONB map of table ref 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.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint.updated_at IS + 'Timestamp when this blueprint was last modified.'; + + +CREATE INDEX blueprint_owner_id_idx ON metaschema_modules_public.blueprint (owner_id); +CREATE INDEX blueprint_database_id_idx ON metaschema_modules_public.blueprint (database_id); +CREATE INDEX blueprint_template_id_idx ON metaschema_modules_public.blueprint (template_id); +CREATE INDEX blueprint_status_idx ON metaschema_modules_public.blueprint (status); +CREATE INDEX blueprint_definition_hash_idx ON metaschema_modules_public.blueprint (definition_hash); + +COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/blueprint_template/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/blueprint_template/table.sql new file mode 100644 index 000000000..d634212e8 --- /dev/null +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/blueprint_template/table.sql @@ -0,0 +1,137 @@ +-- Deploy schemas/metaschema_modules_public/tables/blueprint_template/table to pg + +-- requires: schemas/metaschema_modules_public/schema + +BEGIN; + +CREATE TABLE metaschema_modules_public.blueprint_template ( + id uuid PRIMARY KEY DEFAULT uuidv7(), + + -- Identity + name text NOT NULL, + + version text NOT NULL DEFAULT '1.0.0', + + display_name text NOT NULL, + + description text, + + -- Ownership + owner_id uuid NOT NULL, + + -- Visibility + visibility text NOT NULL DEFAULT 'private' + CHECK (visibility IN ('private', 'public')), + + -- Categorization + categories text[] NOT NULL DEFAULT '{}', + + tags text[] NOT NULL DEFAULT '{}', + + -- The blueprint definition (tables with nodes[] and policies[], relations with $type) + definition jsonb NOT NULL, + + -- Schema for validating definition structure + definition_schema_version text NOT NULL DEFAULT '1', + + -- Provenance + source text NOT NULL DEFAULT 'user' + CHECK (source IN ('user', 'system', 'agent')), + + -- Complexity indicator + complexity text DEFAULT NULL + CHECK (complexity IS NULL OR complexity IN ('simple', 'moderate', 'complex')), + + -- Marketplace stats (denormalized for query perf) + copy_count integer NOT NULL DEFAULT 0, + + fork_count integer NOT NULL DEFAULT 0, + + -- If this template was forked from another + forked_from_id uuid DEFAULT NULL, + + -- Content-addressable Merkle hashes (backend-computed via trigger) + definition_hash uuid, + + table_hashes jsonb, + + created_at timestamptz NOT NULL DEFAULT now(), + + updated_at timestamptz NOT NULL DEFAULT now(), + + CONSTRAINT blueprint_template_unique_owner_name_version UNIQUE (owner_id, name, version), + CONSTRAINT blueprint_template_forked_from_fkey FOREIGN KEY (forked_from_id) REFERENCES metaschema_modules_public.blueprint_template(id) +); + +COMMENT ON TABLE metaschema_modules_public.blueprint_template IS + 'A shareable, versioned schema recipe for the blueprint marketplace. Templates define arrays of secure_table_provision + relation_provision inputs that together describe a complete domain schema (e.g. e-commerce, telemedicine, habit tracker). Templates are never executed directly — they are copied into a blueprint first via copy_template_to_blueprint(). Can be private (owner-only) or public (marketplace-visible).'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.id IS + 'Unique identifier for this template.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.name IS + 'Machine-readable name for the template (e.g. e_commerce_basic). Must be unique per owner + version.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.version IS + 'Semantic version string. Defaults to 1.0.0.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.display_name IS + 'Human-readable display name for the template (e.g. E-Commerce Basic).'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.description IS + 'Optional description of what the template provisions.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.owner_id IS + 'The user who created or published this template.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.visibility IS + 'Access control for the template. private: only the owner can see and copy. public: anyone can browse and copy from the marketplace. Defaults to private.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.categories IS + 'Domain categories for marketplace browsing (e.g. e-commerce, healthcare, social). Defaults to empty array.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.tags IS + 'Freeform tags for search and discovery (e.g. products, orders, payments). Defaults to empty array.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.definition IS + 'The blueprint definition as a JSONB document. Contains tables[] (each with nodes[] for data behaviors via string shorthand or {"$type": "...", "data": {...}} objects, fields[], grants[], and policies[] using {"$type": "...", "data": {...}}), and relations[] (using $type for relation_type with junction config in data). This is the core payload that gets copied into a blueprint for execution.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.definition_schema_version IS + 'Version of the definition format schema. Used for forward-compatible parsing. Defaults to 1.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.source IS + 'Provenance of the template. user: manually created by a human. system: official curated template from the Constructive team. agent: AI-generated. Defaults to user.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.complexity IS + 'Complexity indicator for marketplace filtering. simple: 3-5 tables. moderate: 6-12 tables. complex: 13+ tables. NULL if not categorized.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.copy_count IS + 'Denormalized count of how many blueprints have been created from this template via copy_template_to_blueprint(). Incremented automatically. Defaults to 0.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.fork_count IS + 'Denormalized count of how many derivative templates have been forked from this template. Defaults to 0.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.forked_from_id IS + 'If this template was forked from another template, the ID of the parent. NULL for original templates.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.created_at IS + 'Timestamp when this template was created.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.definition_hash IS + 'UUIDv5 Merkle root hash of the definition. Computed automatically via trigger from the ordered table_hashes. Used for content-addressable deduplication, provenance tracking, and cross-blueprint structural comparison. NULL columns are backend-computed — clients should never set this directly.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.table_hashes IS + 'JSONB map of table ref names to their individual UUIDv5 content hashes (e.g. {"products": "uuid", "categories": "uuid"}). Each table hash is computed from the canonical jsonb::text of the table entry. Enables structural comparison at the table level across different blueprints. Backend-computed via trigger.'; + +COMMENT ON COLUMN metaschema_modules_public.blueprint_template.updated_at IS + 'Timestamp when this template was last modified.'; + + +CREATE INDEX blueprint_template_owner_id_idx ON metaschema_modules_public.blueprint_template (owner_id); +CREATE INDEX blueprint_template_visibility_idx ON metaschema_modules_public.blueprint_template (visibility); +CREATE INDEX blueprint_template_forked_from_id_idx ON metaschema_modules_public.blueprint_template (forked_from_id); +CREATE INDEX blueprint_template_categories_idx ON metaschema_modules_public.blueprint_template USING gin (categories); +CREATE INDEX blueprint_template_tags_idx ON metaschema_modules_public.blueprint_template USING gin (tags); +CREATE INDEX blueprint_template_definition_hash_idx ON metaschema_modules_public.blueprint_template (definition_hash); + +COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql index 34b7aa9c8..05823df8e 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.connected_accounts_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -24,11 +24,6 @@ CREATE TABLE metaschema_modules_public.connected_accounts_module ( CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.connected_accounts_module IS E'@omit manyToMany'; CREATE INDEX connected_accounts_module_database_id_idx ON metaschema_modules_public.connected_accounts_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql index 438dc1068..394f63fb7 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.crypto_addresses_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -25,11 +25,6 @@ CREATE TABLE metaschema_modules_public.crypto_addresses_module ( CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.crypto_addresses_module IS E'@omit manyToMany'; CREATE INDEX crypto_addresses_module_database_id_idx ON metaschema_modules_public.crypto_addresses_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql index dc5e9f555..639475bd7 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.crypto_auth_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -35,13 +35,7 @@ CREATE TABLE metaschema_modules_public.crypto_auth_module ( CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT secrets_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT users_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany'; -- TOKENS_REMOVAL: tokens_table_fkey comment removed -COMMENT ON CONSTRAINT sessions_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT session_credentials_table_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.crypto_auth_module IS E'@omit manyToMany'; CREATE INDEX crypto_auth_module_database_id_idx ON metaschema_modules_public.crypto_auth_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/default_ids_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/default_ids_module/table.sql index 1c84334ff..15fa40a65 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/default_ids_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/default_ids_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.default_ids_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- @@ -13,7 +13,6 @@ CREATE TABLE metaschema_modules_public.default_ids_module ( CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.default_ids_module IS E'@omit manyToMany'; CREATE INDEX default_ids_module_database_id_idx ON metaschema_modules_public.default_ids_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql index f7ffb3c30..e6ea588a1 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.denormalized_table_field ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, table_id uuid NOT NULL, @@ -31,11 +31,6 @@ CREATE TABLE metaschema_modules_public.denormalized_table_field ( CONSTRAINT ref_field_fkey FOREIGN KEY (ref_field_id) REFERENCES metaschema_public.field (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT ref_table_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT field_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT ref_field_fkey ON metaschema_modules_public.denormalized_table_field IS E'@omit manyToMany'; CREATE INDEX denormalized_table_field_database_id_idx ON metaschema_modules_public.denormalized_table_field ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql index 7ee5cd76d..346629b3d 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.emails_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -24,11 +24,6 @@ CREATE TABLE metaschema_modules_public.emails_module ( CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.emails_module IS E'@omit manyToMany'; CREATE INDEX emails_module_database_id_idx ON metaschema_modules_public.emails_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql index 7aead8019..339867857 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.encrypted_secrets_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- @@ -19,11 +19,6 @@ CREATE TABLE metaschema_modules_public.encrypted_secrets_module ( CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.encrypted_secrets_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.encrypted_secrets_module IS E'@omit manyToMany'; CREATE INDEX encrypted_secrets_module_database_id_idx ON metaschema_modules_public.encrypted_secrets_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.encrypted_secrets_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql index afb49ad06..4b26695b1 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.field_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, private_schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -33,10 +33,6 @@ CREATE TABLE metaschema_modules_public.field_module ( CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT field_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.field_module IS E'@omit manyToMany'; CREATE INDEX field_module_database_id_idx ON metaschema_modules_public.field_module ( database_id ); CREATE INDEX field_module_node_type_idx ON metaschema_modules_public.field_module ( node_type ); diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql index 851943275..e4241c250 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.hierarchy_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- Schema references @@ -56,24 +56,6 @@ CREATE TABLE metaschema_modules_public.hierarchy_module ( CONSTRAINT hierarchy_module_database_unique UNIQUE (database_id) ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; CREATE INDEX hierarchy_module_database_id_idx ON metaschema_modules_public.hierarchy_module ( database_id ); -COMMENT ON CONSTRAINT chart_edges_table_fkey - ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT hierarchy_sprt_table_fkey - ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT chart_edge_grants_table_fkey - ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT entity_table_fkey - ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT users_table_fkey - ON metaschema_modules_public.hierarchy_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql index c71b2d833..0d5e7d0e0 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.invites_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -39,13 +39,6 @@ CREATE TABLE metaschema_modules_public.invites_module ( CONSTRAINT pschema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT emails_table_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT users_table_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT invites_table_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT claimed_invites_table_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT pschema_fkey ON metaschema_modules_public.invites_module IS E'@omit manyToMany'; CREATE INDEX invites_module_database_id_idx ON metaschema_modules_public.invites_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql index 7939b51d6..d35ae245b 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.levels_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- @@ -59,13 +59,6 @@ CREATE TABLE metaschema_modules_public.levels_module ( CONSTRAINT actor_table_fkey FOREIGN KEY (actor_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT steps_table_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT achievements_table_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT levels_table_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT level_requirements_table_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT actor_table_fkey ON metaschema_modules_public.levels_module IS E'@omit manyToMany'; CREATE INDEX user_status_module_database_id_idx ON metaschema_modules_public.levels_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql index bebac890d..14c5035ca 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.limits_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -45,19 +45,6 @@ CREATE TABLE metaschema_modules_public.limits_module ( ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.limits_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.limits_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.limits_module IS E'@omit manyToMany'; CREATE INDEX limits_module_database_id_idx ON metaschema_modules_public.limits_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.limits_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT default_table_fkey - ON metaschema_modules_public.limits_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT actor_table_fkey - ON metaschema_modules_public.limits_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/membership_types_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/membership_types_module/table.sql index 8ee55850d..dc5c8a6f2 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/membership_types_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/membership_types_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.membership_types_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -20,11 +20,6 @@ CREATE TABLE metaschema_modules_public.membership_types_module ( CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.membership_types_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.membership_types_module IS E'@omit manyToMany'; CREATE INDEX membership_types_module_database_id_idx ON metaschema_modules_public.membership_types_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.membership_types_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql index 3a869ec9a..286c02278 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.memberships_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -76,45 +76,6 @@ CREATE TABLE metaschema_modules_public.memberships_module ( CONSTRAINT default_permissions_table_fkey FOREIGN KEY (default_permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; CREATE INDEX memberships_module_database_id_idx ON metaschema_modules_public.memberships_module ( database_id ); -COMMENT ON CONSTRAINT entity_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT entity_table_owner_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT memberships_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT members_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT membership_defaults_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT grants_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT sprt_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT actor_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT limits_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT default_limits_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT permissions_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT default_permissions_table_fkey - ON metaschema_modules_public.memberships_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql index 80ab7fbcd..e35262274 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.permissions_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -48,18 +48,6 @@ CREATE TABLE metaschema_modules_public.permissions_module ( CONSTRAINT actor_table_fkey FOREIGN KEY (actor_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.permissions_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.permissions_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.permissions_module IS E'@omit manyToMany'; CREATE INDEX permissions_module_database_id_idx ON metaschema_modules_public.permissions_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.permissions_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT default_table_fkey - ON metaschema_modules_public.permissions_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT actor_table_fkey - ON metaschema_modules_public.permissions_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql index 38b98e2fe..66053dc60 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.phone_numbers_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -24,11 +24,6 @@ CREATE TABLE metaschema_modules_public.phone_numbers_module ( CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany'; CREATE INDEX phone_numbers_module_database_id_idx ON metaschema_modules_public.phone_numbers_module ( database_id ); COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql index 7c6f8b4c0..b2a0207ba 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.profiles_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -55,33 +55,6 @@ CREATE TABLE metaschema_modules_public.profiles_module ( CONSTRAINT profiles_module_unique UNIQUE (database_id, membership_type) ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; CREATE INDEX profiles_module_database_id_idx ON metaschema_modules_public.profiles_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT profile_permissions_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT profile_grants_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT profile_definition_grants_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT entity_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT actor_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT permissions_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT memberships_table_fkey - ON metaschema_modules_public.profiles_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/relation_provision/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/relation_provision/table.sql index f8f19ffd2..4845e339c 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/relation_provision/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/relation_provision/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.relation_provision ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, @@ -31,6 +31,8 @@ CREATE TABLE metaschema_modules_public.relation_provision ( is_required boolean NOT NULL DEFAULT true, + api_required boolean NOT NULL DEFAULT false, + -- ========================================================================= -- ManyToMany: junction table identity -- ========================================================================= @@ -51,6 +53,18 @@ CREATE TABLE metaschema_modules_public.relation_provision ( use_composite_key boolean NOT NULL DEFAULT false, + -- ========================================================================= + -- Index creation on FK fields + -- ========================================================================= + + create_index boolean NOT NULL DEFAULT true, + + -- ========================================================================= + -- ManyToMany: API visibility (PostGraphile v5 @behavior +manyToMany) + -- ========================================================================= + + expose_in_api boolean NOT NULL DEFAULT true, + -- ========================================================================= -- ManyToMany: field creation (forwarded to secure_table_provision) -- ========================================================================= @@ -65,7 +79,7 @@ CREATE TABLE metaschema_modules_public.relation_provision ( grant_roles text[] NOT NULL DEFAULT ARRAY['authenticated'], - grant_privileges jsonb NOT NULL DEFAULT '[["select","*"],["insert","*"],["delete","*"]]', + grant_privileges jsonb[] NOT NULL DEFAULT ARRAY['["select","*"]'::jsonb, '["insert","*"]'::jsonb, '["delete","*"]'::jsonb], -- ========================================================================= -- ManyToMany: RLS policies (forwarded to secure_table_provision) @@ -167,6 +181,12 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.is_required IS - RelationHasOne: typically true. Ignored for RelationManyToMany (junction FK fields are always required).'; +COMMENT ON COLUMN metaschema_modules_public.relation_provision.api_required IS + 'Whether the FK field should be required at the API level even though it is nullable at the database level. Defaults to false. + When true and is_required is false, the field is created as nullable (allowing SET NULL cascade) but a @requiredInput smart tag is added so PostGraphile treats it as non-null in create/update input types. + When is_required is true, api_required is ignored (the field is already required at both levels). + Ignored for RelationManyToMany (junction FK fields are always required).'; + -- ============================================================================= -- ManyToMany: junction table identity -- ============================================================================= @@ -200,6 +220,28 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.use_composite_key use_composite_key and node_type=''DataId'' are mutually exclusive — using both would create two conflicting PKs. Ignored for RelationBelongsTo/RelationHasOne.'; +COMMENT ON COLUMN metaschema_modules_public.relation_provision.create_index IS + 'Whether to create a btree index on FK fields created by this relation. Defaults to true. + PostgreSQL does not automatically index foreign key columns (only the referenced PK side is indexed). + Without indexes on FK columns, JOINs, CASCADE deletes, and RLS policy lookups perform sequential scans. + - RelationBelongsTo: creates an index on the FK field on the source table. + - RelationHasMany: creates an index on the FK field on the target table. + - RelationHasOne: skipped — the unique constraint already creates an implicit index. + - RelationManyToMany: creates indexes on both FK fields on the junction table. + Set to false only for very small tables or write-heavy tables where index maintenance cost outweighs read performance.'; + +-- ============================================================================= +-- ManyToMany: API visibility +-- ============================================================================= + +COMMENT ON COLUMN metaschema_modules_public.relation_provision.expose_in_api IS + 'For RelationManyToMany: whether to expose the M:N shortcut fields in the GraphQL API. Defaults to true. + When true, sets @behavior +manyToMany on the junction table smart_tags so PostGraphile generates + clean M:N connection fields (e.g., event.contacts instead of event.contactEventsByEventId). + When false (or toggled off via UPDATE), the behavior tag is removed and the M:N fields disappear from GraphQL. + Toggling is supported: UPDATE expose_in_api to true/false and the smart tag is added/removed automatically. + Ignored for RelationBelongsTo/RelationHasOne/RelationHasMany.'; + -- ============================================================================= -- ManyToMany: field creation (forwarded to secure_table_provision) -- ============================================================================= @@ -227,7 +269,7 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.grant_roles IS 'For RelationManyToMany: database roles to grant privileges to on the junction table. Forwarded to secure_table_provision as-is. Supports multiple roles, e.g. ARRAY[''authenticated'', ''admin'']. Each role receives all privileges defined in grant_privileges. Defaults to ARRAY[''authenticated'']. Ignored for RelationBelongsTo/RelationHasOne.'; COMMENT ON COLUMN metaschema_modules_public.relation_provision.grant_privileges IS - 'For RelationManyToMany: privilege grants for the junction table. Forwarded to secure_table_provision as-is. Format: array of [privilege, columns] tuples. Examples: [["select","*"],["insert","*"]] for full access, or [["update",["name","bio"]]] for column-level grants. "*" means all columns. Defaults to select/insert/delete for all columns. Ignored for RelationBelongsTo/RelationHasOne.'; + 'For RelationManyToMany: privilege grants for the junction table. Forwarded to secure_table_provision as-is. Format: PostgreSQL array of jsonb [privilege, columns] tuples. Examples: ARRAY[''["select","*"]''::jsonb, ''["insert","*"]''::jsonb] for full access, or ARRAY[''["update",["name","bio"]]''::jsonb] for column-level grants. "*" means all columns. Defaults to select/insert/delete for all columns. Ignored for RelationBelongsTo/RelationHasOne.'; -- ============================================================================= -- ManyToMany: RLS policies (forwarded to secure_table_provision) @@ -275,10 +317,6 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.out_source_field_ COMMENT ON COLUMN metaschema_modules_public.relation_provision.out_target_field_id IS 'Output column for RelationManyToMany: the UUID of the FK field on the junction table referencing the target table. Populated by the trigger. NULL for RelationBelongsTo/RelationHasOne. Callers should not set this directly.'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.relation_provision IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT source_table_fkey ON metaschema_modules_public.relation_provision IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT target_table_fkey ON metaschema_modules_public.relation_provision IS E'@omit manyToMany'; - CREATE INDEX relation_provision_database_id_idx ON metaschema_modules_public.relation_provision ( database_id ); CREATE INDEX relation_provision_relation_type_idx ON metaschema_modules_public.relation_provision ( relation_type ); CREATE INDEX relation_provision_source_table_id_idx ON metaschema_modules_public.relation_provision ( source_table_id ); diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql index 61828349d..11264ca00 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql @@ -6,10 +6,9 @@ BEGIN; CREATE TABLE metaschema_modules_public.rls_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, - api_id uuid NOT NULL DEFAULT uuid_nil(), schema_id uuid NOT NULL DEFAULT uuid_nil(), private_schema_id uuid NOT NULL DEFAULT uuid_nil(), session_credentials_table_id uuid NOT NULL DEFAULT uuid_nil(), @@ -25,7 +24,6 @@ CREATE TABLE metaschema_modules_public.rls_module ( -- CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, - CONSTRAINT api_fkey FOREIGN KEY (api_id) REFERENCES services_public.apis (id) ON DELETE CASCADE, CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE, CONSTRAINT sessions_table_fkey FOREIGN KEY (sessions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE, CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE, @@ -33,12 +31,9 @@ CREATE TABLE metaschema_modules_public.rls_module ( CONSTRAINT pschema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE, -- - CONSTRAINT api_id_uniq UNIQUE(api_id) + CONSTRAINT database_id_uniq UNIQUE(database_id) ); -COMMENT ON CONSTRAINT api_fkey ON metaschema_modules_public.rls_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.rls_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT pschema_fkey ON metaschema_modules_public.rls_module IS E'@omit manyToMany'; COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.rls_module IS E'@omit'; COMMENT ON CONSTRAINT session_credentials_table_fkey ON metaschema_modules_public.rls_module IS E'@omit'; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secrets_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secrets_module/table.sql index a1aa97581..c06e2a0c3 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secrets_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secrets_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.secrets_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -18,11 +18,6 @@ CREATE TABLE metaschema_modules_public.secrets_module ( ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.secrets_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.secrets_module IS E'@omit manyToMany'; CREATE INDEX secrets_module_database_id_idx ON metaschema_modules_public.secrets_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.secrets_module IS E'@omit manyToMany'; - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql index d5cdd7b1d..ed3f0bd4e 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.secure_table_provision ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, @@ -21,9 +21,11 @@ CREATE TABLE metaschema_modules_public.secure_table_provision ( node_data jsonb NOT NULL DEFAULT '{}', + fields jsonb[] NOT NULL DEFAULT '{}', + grant_roles text[] NOT NULL DEFAULT ARRAY['authenticated'], - grant_privileges jsonb NOT NULL DEFAULT '[]', + grant_privileges jsonb[] NOT NULL DEFAULT '{}', policy_type text DEFAULT NULL, @@ -69,13 +71,16 @@ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.use_rls IS '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.'; COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.node_data IS - '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. Defaults to ''{}''.'; + '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 ''{}''.'; + +COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.fields IS + '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).'; COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.grant_roles IS 'Database roles to grant privileges to. Supports multiple roles, e.g. ARRAY[''authenticated'', ''admin'']. Each role receives all privileges defined in grant_privileges. Defaults to ARRAY[''authenticated''].'; COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.grant_privileges IS - 'Array of [privilege, columns] tuples defining table grants. Examples: [["select","*"],["insert","*"]] for full access, or [["update",["name","bio"]]] for column-level grants. "*" means all columns; an array means column-level grant. Defaults to ''[]'' (no grants). The trigger validates this is a proper jsonb array.'; + 'PostgreSQL array of jsonb [privilege, columns] tuples defining table grants. Examples: ARRAY[''["select","*"]''::jsonb, ''["insert","*"]''::jsonb] for full access, or ARRAY[''["update",["name","bio"]]''::jsonb] for column-level grants. "*" means all columns; an array means column-level grant. Defaults to ''{}'' (no grants). Type safety is enforced by PostgreSQL at INSERT time.'; COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_type IS 'Policy generator type, e.g. ''AuthzEntityMembership'', ''AuthzMembership'', ''AuthzAllowAll''. NULL means no policy is created. When set, the trigger automatically enables RLS on the target table.'; @@ -98,9 +103,6 @@ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_data I COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.out_fields IS '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 generator. NULL when node_type is NULL or before the trigger runs. Callers should not set this directly.'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany'; CREATE INDEX secure_table_provision_database_id_idx ON metaschema_modules_public.secure_table_provision ( database_id ); CREATE INDEX secure_table_provision_table_id_idx ON metaschema_modules_public.secure_table_provision ( table_id ); diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/sessions_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/sessions_module/table.sql index f04e65eda..ae23470ad 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/sessions_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/sessions_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.sessions_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- @@ -29,17 +29,13 @@ CREATE TABLE metaschema_modules_public.sessions_module ( CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.sessions_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.sessions_module IS E'@omit manyToMany'; CREATE INDEX sessions_module_database_id_idx ON metaschema_modules_public.sessions_module ( database_id ); COMMENT ON CONSTRAINT sessions_table_fkey - ON metaschema_modules_public.sessions_module IS E'@fieldName sessionsTableBySessionsTableId\n@omit manyToMany'; + ON metaschema_modules_public.sessions_module IS E'@fieldName sessionsTableBySessionsTableId'; COMMENT ON CONSTRAINT session_credentials_table_fkey - ON metaschema_modules_public.sessions_module IS E'@fieldName sessionCredentialsTableBySessionCredentialsTableId\n@omit manyToMany'; + ON metaschema_modules_public.sessions_module IS E'@fieldName sessionCredentialsTableBySessionCredentialsTableId'; COMMENT ON CONSTRAINT auth_settings_table_fkey - ON metaschema_modules_public.sessions_module IS E'@fieldName authSettingsTableByAuthSettingsTableId\n@omit manyToMany'; -COMMENT ON CONSTRAINT users_table_fkey - ON metaschema_modules_public.sessions_module IS E'@omit manyToMany'; + ON metaschema_modules_public.sessions_module IS E'@fieldName authSettingsTableByAuthSettingsTableId'; COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_module/table.sql deleted file mode 100644 index 532d2d514..000000000 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_module/table.sql +++ /dev/null @@ -1,37 +0,0 @@ --- Deploy schemas/metaschema_modules_public/tables/table_module/table to pg - --- requires: schemas/metaschema_modules_public/schema - -BEGIN; - -CREATE TABLE metaschema_modules_public.table_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), - database_id uuid NOT NULL, - - schema_id uuid NOT NULL DEFAULT uuid_nil(), - - table_id uuid NOT NULL DEFAULT uuid_nil(), - - table_name text DEFAULT NULL, - - node_type text NOT NULL, - - use_rls boolean NOT NULL DEFAULT true, - - data jsonb NOT NULL DEFAULT '{}', - - fields uuid[], - - CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, - CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE, - CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE -); - -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.table_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.table_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.table_module IS E'@omit manyToMany'; -CREATE INDEX table_module_database_id_idx ON metaschema_modules_public.table_module ( database_id ); -CREATE INDEX table_module_table_id_idx ON metaschema_modules_public.table_module ( table_id ); -CREATE INDEX table_module_node_type_idx ON metaschema_modules_public.table_module ( node_type ); - -COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql index dde40ceab..2ef7d10b0 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.table_template_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -33,11 +33,6 @@ CREATE TABLE metaschema_modules_public.table_template_module ( CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany'; CREATE INDEX table_template_module_database_id_idx ON metaschema_modules_public.table_template_module ( database_id ); CREATE INDEX table_template_module_schema_id_idx ON metaschema_modules_public.table_template_module ( schema_id ); CREATE INDEX table_template_module_private_schema_id_idx ON metaschema_modules_public.table_template_module ( private_schema_id ); diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql index 37ecb043c..74ffcde87 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.user_auth_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -56,8 +56,6 @@ CREATE TABLE metaschema_modules_public.user_auth_module ( CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.user_auth_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.user_auth_module IS E'@omit manyToMany'; CREATE INDEX user_auth_module_database_id_idx ON metaschema_modules_public.user_auth_module ( database_id ); COMMENT ON CONSTRAINT email_table_fkey diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql index fd929d7af..c736df901 100644 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_modules_public.users_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, -- schema_id uuid NOT NULL DEFAULT uuid_nil(), @@ -24,15 +24,6 @@ CREATE TABLE metaschema_modules_public.users_module ( CONSTRAINT type_table_fkey FOREIGN KEY (type_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.users_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.users_module IS E'@omit manyToMany'; CREATE INDEX users_module_database_id_idx ON metaschema_modules_public.users_module ( database_id ); -COMMENT ON CONSTRAINT table_fkey - ON metaschema_modules_public.users_module IS E'@omit manyToMany'; - -COMMENT ON CONSTRAINT type_table_fkey - ON metaschema_modules_public.users_module IS E'@omit manyToMany'; - - COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/uuid_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/uuid_module/table.sql deleted file mode 100644 index aed73b571..000000000 --- a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/uuid_module/table.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Deploy schemas/metaschema_modules_public/tables/uuid_module/table to pg - --- requires: schemas/metaschema_modules_public/schema - -BEGIN; - -CREATE TABLE metaschema_modules_public.uuid_module ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), - database_id uuid NOT NULL, - -- - schema_id uuid NOT NULL DEFAULT uuid_nil(), - uuid_function text NOT NULL DEFAULT 'uuid_generate_v4', - uuid_seed text NOT NULL, - -- - CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE, - CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE -); - -COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.uuid_module IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.uuid_module IS E'@omit manyToMany'; -CREATE INDEX uuid_module_database_id_idx ON metaschema_modules_public.uuid_module ( database_id ); - -COMMIT; diff --git a/packages/metaschema-modules/metaschema-modules.control b/packages/metaschema-modules/metaschema-modules.control index d26f37baf..e0ea0b88d 100644 --- a/packages/metaschema-modules/metaschema-modules.control +++ b/packages/metaschema-modules/metaschema-modules.control @@ -2,6 +2,6 @@ comment = 'metaschema-modules extension' default_version = '0.15.5' module_pathname = '$libdir/metaschema-modules' -requires = 'plpgsql,metaschema-schema,services,pgpm-verify' +requires = 'plpgsql,uuid-ossp,metaschema-schema,services,pgpm-verify' relocatable = false superuser = false diff --git a/packages/metaschema-modules/pgpm.plan b/packages/metaschema-modules/pgpm.plan index 1c0b81bb4..01c0f9581 100644 --- a/packages/metaschema-modules/pgpm.plan +++ b/packages/metaschema-modules/pgpm.plan @@ -14,7 +14,6 @@ schemas/metaschema_modules_public/tables/denormalized_table_field/table [schemas schemas/metaschema_modules_public/tables/emails_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/emails_module/table schemas/metaschema_modules_public/tables/encrypted_secrets_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/encrypted_secrets_module/table schemas/metaschema_modules_public/tables/field_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/field_module/table -schemas/metaschema_modules_public/tables/table_module/table [schemas/metaschema_modules_public/schema] 2026-01-12T00:00:00Z devin # add schemas/metaschema_modules_public/tables/table_module/table schemas/metaschema_modules_public/tables/invites_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/invites_module/table schemas/metaschema_modules_public/tables/levels_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/levels_module/table schemas/metaschema_modules_public/tables/limits_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/limits_module/table @@ -29,8 +28,10 @@ schemas/services_public/tables/sites/table [schemas/services_public/schema] 2017 schemas/metaschema_modules_public/tables/sessions_module/table [schemas/metaschema_modules_public/schema] 2026-01-24T00:00:00Z devin # add schemas/metaschema_modules_public/tables/sessions_module/table schemas/metaschema_modules_public/tables/user_auth_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/user_auth_module/table schemas/metaschema_modules_public/tables/users_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/users_module/table -schemas/metaschema_modules_public/tables/uuid_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_modules_public/tables/uuid_module/table + schemas/metaschema_modules_public/tables/hierarchy_module/table [schemas/metaschema_modules_public/schema] 2024-12-28T00:00:00Z skitch # add schemas/metaschema_modules_public/tables/hierarchy_module/table schemas/metaschema_modules_public/tables/table_template_module/table [schemas/metaschema_modules_public/schema] 2026-01-14T00:00:00Z devin # add schemas/metaschema_modules_public/tables/table_template_module/table schemas/metaschema_modules_public/tables/secure_table_provision/table [schemas/metaschema_modules_public/schema] 2026-02-25T00:00:00Z Constructive # add schemas/metaschema_modules_public/tables/secure_table_provision/table schemas/metaschema_modules_public/tables/relation_provision/table [schemas/metaschema_modules_public/schema] 2026-02-26T00:00:00Z Constructive # add schemas/metaschema_modules_public/tables/relation_provision/table +schemas/metaschema_modules_public/tables/blueprint_template/table [schemas/metaschema_modules_public/schema] 2026-03-20T00:00:00Z Constructive # add blueprint_template table for shareable schema recipes +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 # add blueprint table for owned executable blueprints diff --git a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/blueprint/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/blueprint/table.sql new file mode 100644 index 000000000..2c916fd81 --- /dev/null +++ b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/blueprint/table.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_modules_public/tables/blueprint/table from pg + +BEGIN; + +DROP TABLE IF EXISTS metaschema_modules_public.blueprint; + +COMMIT; diff --git a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/blueprint_template/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/blueprint_template/table.sql new file mode 100644 index 000000000..29c2dd41d --- /dev/null +++ b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/blueprint_template/table.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_modules_public/tables/blueprint_template/table from pg + +BEGIN; + +DROP TABLE IF EXISTS metaschema_modules_public.blueprint_template; + +COMMIT; diff --git a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/table_module/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/table_module/table.sql deleted file mode 100644 index e2cdf8263..000000000 --- a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/table_module/table.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Revert schemas/metaschema_modules_public/tables/table_module/table from pg - -BEGIN; - -DROP TABLE IF EXISTS metaschema_modules_public.table_module; - -COMMIT; diff --git a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/uuid_module/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/uuid_module/table.sql deleted file mode 100644 index 60ff0c8dc..000000000 --- a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/uuid_module/table.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Revert schemas/metaschema_modules_public/tables/uuid_module/table from pg - -BEGIN; - -DROP TABLE metaschema_modules_public.uuid_module; - -COMMIT; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/blueprint/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/blueprint/table.sql new file mode 100644 index 000000000..7a71abb5b --- /dev/null +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/blueprint/table.sql @@ -0,0 +1,26 @@ +-- Verify schemas/metaschema_modules_public/tables/blueprint/table on pg + +BEGIN; + +SELECT + id, + owner_id, + database_id, + name, + display_name, + description, + definition, + template_id, + status, + constructed_at, + error_details, + ref_map, + constructed_definition, + definition_hash, + table_hashes, + created_at, + updated_at +FROM metaschema_modules_public.blueprint +WHERE FALSE; + +ROLLBACK; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/blueprint_template/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/blueprint_template/table.sql new file mode 100644 index 000000000..e26f09cbe --- /dev/null +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/blueprint_template/table.sql @@ -0,0 +1,29 @@ +-- Verify schemas/metaschema_modules_public/tables/blueprint_template/table on pg + +BEGIN; + +SELECT + id, + name, + version, + display_name, + description, + owner_id, + visibility, + categories, + tags, + definition, + definition_schema_version, + source, + complexity, + copy_count, + fork_count, + forked_from_id, + definition_hash, + table_hashes, + created_at, + updated_at +FROM metaschema_modules_public.blueprint_template +WHERE FALSE; + +ROLLBACK; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql index 188f14db2..711221854 100644 --- a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql @@ -11,6 +11,7 @@ SELECT field_name, delete_action, is_required, + api_required, junction_table_id, junction_table_name, junction_schema_id, diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql index 1ade01ccf..b9a983eee 100644 --- a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql @@ -11,6 +11,7 @@ SELECT node_type, use_rls, node_data, + fields, grant_roles, grant_privileges, policy_type, diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/table_module/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/table_module/table.sql deleted file mode 100644 index 80cd415b0..000000000 --- a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/table_module/table.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Verify schemas/metaschema_modules_public/tables/table_module/table on pg - -BEGIN; - -SELECT - id, - database_id, - schema_id, - table_id, - table_name, - node_type, - use_rls, - data, - fields -FROM metaschema_modules_public.table_module -WHERE FALSE; - -ROLLBACK; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/uuid_module/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/uuid_module/table.sql deleted file mode 100644 index 0ddf4bfbf..000000000 --- a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/uuid_module/table.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Verify schemas/metaschema_modules_public/tables/uuid_module/table on pg - -BEGIN; - -SELECT verify_table ('metaschema_modules_public.uuid_module'); - -ROLLBACK; diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/check_constraint/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/check_constraint/table.sql index 91a199ebf..99e83cb44 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/check_constraint/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/check_constraint/table.sql @@ -8,7 +8,7 @@ BEGIN; CREATE TABLE metaschema_public.check_constraint ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -32,8 +32,6 @@ CREATE TABLE metaschema_public.check_constraint ( CHECK (field_ids <> '{}') ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.check_constraint IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.check_constraint IS E'@omit manyToMany'; CREATE INDEX check_constraint_table_id_idx ON metaschema_public.check_constraint ( table_id ); CREATE INDEX check_constraint_database_id_idx ON metaschema_public.check_constraint ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/database/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/database/table.sql index c9299c373..e9adbb4bf 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/database/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/database/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_public.database ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), owner_id uuid, schema_hash text, diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/default_privilege/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/default_privilege/table.sql index 08b1f3f6e..c6f94f1b3 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/default_privilege/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/default_privilege/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE metaschema_public.default_privilege ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), schema_id uuid NOT NULL, @@ -30,8 +30,6 @@ CREATE TABLE metaschema_public.default_privilege ( UNIQUE (schema_id, object_type, privilege, grantee_name, is_grant) ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_public.default_privilege IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.default_privilege IS E'@omit manyToMany'; CREATE INDEX default_privilege_schema_id_idx ON metaschema_public.default_privilege ( schema_id ); CREATE INDEX default_privilege_database_id_idx ON metaschema_public.default_privilege ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/embedding_chunks/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/embedding_chunks/table.sql new file mode 100644 index 000000000..8f7e541c9 --- /dev/null +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/embedding_chunks/table.sql @@ -0,0 +1,59 @@ +-- Deploy schemas/metaschema_public/tables/embedding_chunks/table to pg + +-- requires: schemas/metaschema_public/schema +-- requires: schemas/metaschema_public/tables/database/table +-- requires: schemas/metaschema_public/tables/table/table +-- requires: schemas/metaschema_public/tables/field/table + +BEGIN; + +CREATE TABLE metaschema_public.embedding_chunks ( + id uuid PRIMARY KEY DEFAULT uuidv7(), + database_id uuid NOT NULL DEFAULT uuid_nil(), + + table_id uuid NOT NULL, + embedding_field_id uuid, + chunks_table_id uuid, + chunks_table_name text, + + -- content field configuration + content_field_name text NOT NULL DEFAULT 'content', + + -- embedding configuration + dimensions int NOT NULL DEFAULT 768, + metric text NOT NULL DEFAULT 'cosine', + + -- chunking configuration + chunk_size int NOT NULL DEFAULT 1000, + chunk_overlap int NOT NULL DEFAULT 200, + chunk_strategy text NOT NULL DEFAULT 'fixed', + + -- metadata fields from parent to copy into chunks + metadata_fields jsonb, + + -- job configuration + enqueue_chunking_job boolean NOT NULL DEFAULT true, + chunking_task_name text NOT NULL DEFAULT 'generate_chunks', + + -- FK field on chunks table pointing to parent + parent_fk_field_id uuid, + + CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, + CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE, + CONSTRAINT chunks_table_fkey FOREIGN KEY (chunks_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL, + CONSTRAINT embedding_field_fkey FOREIGN KEY (embedding_field_id) REFERENCES metaschema_public.field (id) ON DELETE SET NULL, + CONSTRAINT parent_fk_field_fkey FOREIGN KEY (parent_fk_field_id) REFERENCES metaschema_public.field (id) ON DELETE SET NULL, + + CONSTRAINT valid_metric CHECK (metric IN ('cosine', 'l2', 'ip')), + CONSTRAINT valid_chunk_strategy CHECK (chunk_strategy IN ('fixed', 'sentence', 'paragraph', 'semantic')), + CONSTRAINT valid_dimensions CHECK (dimensions > 0), + CONSTRAINT valid_chunk_size CHECK (chunk_size > 0), + CONSTRAINT valid_chunk_overlap CHECK (chunk_overlap >= 0 AND chunk_overlap < chunk_size) +); + + +CREATE INDEX embedding_chunks_table_id_idx ON metaschema_public.embedding_chunks ( table_id ); +CREATE INDEX embedding_chunks_database_id_idx ON metaschema_public.embedding_chunks ( database_id ); +CREATE INDEX embedding_chunks_chunks_table_id_idx ON metaschema_public.embedding_chunks ( chunks_table_id ); + +COMMIT; diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/enum/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/enum/table.sql index 232f6686d..ae9ba3a66 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/enum/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/enum/table.sql @@ -8,7 +8,7 @@ BEGIN; CREATE TABLE metaschema_public.enum ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL, name text NOT NULL, @@ -32,8 +32,6 @@ CREATE TABLE metaschema_public.enum ( UNIQUE (schema_id, name) ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.enum IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT schema_fkey ON metaschema_public.enum IS E'@omit manyToMany'; CREATE INDEX enum_schema_id_idx ON metaschema_public.enum ( schema_id ); CREATE INDEX enum_database_id_idx ON metaschema_public.enum ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/field/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/field/table.sql index a2e08484d..60c9c6518 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/field/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/field/table.sql @@ -23,7 +23,7 @@ BEGIN; -- AND NOT attisdropped; CREATE TABLE metaschema_public.field ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -35,13 +35,11 @@ CREATE TABLE metaschema_public.field ( smart_tags jsonb, is_required boolean NOT NULL DEFAULT FALSE, + api_required boolean NOT NULL DEFAULT FALSE, default_value text NULL DEFAULT NULL, -- AST column for SQL expression validation (AST is the source of truth) default_value_ast jsonb NULL DEFAULT NULL, - -- hidden from API using @omit keyword, a Graphile feature ONLY - is_hidden boolean NOT NULL DEFAULT FALSE, - type citext NOT NULL, -- typmods DO THIS SOON! @@ -70,8 +68,6 @@ CREATE TABLE metaschema_public.field ( UNIQUE (table_id, name) ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.field IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.field IS E'@omit manyToMany'; CREATE INDEX field_table_id_idx ON metaschema_public.field ( table_id ); CREATE INDEX field_database_id_idx ON metaschema_public.field ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/foreign_key_constraint/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/foreign_key_constraint/table.sql index 14d5a1e4c..989a4f6bd 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/foreign_key_constraint/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/foreign_key_constraint/table.sql @@ -8,7 +8,7 @@ BEGIN; CREATE TABLE metaschema_public.foreign_key_constraint ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -36,8 +36,6 @@ CREATE TABLE metaschema_public.foreign_key_constraint ( CHECK (ref_field_ids <> '{}') ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.foreign_key_constraint IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.foreign_key_constraint IS E'@omit manyToMany'; CREATE INDEX foreign_key_constraint_table_id_idx ON metaschema_public.foreign_key_constraint ( table_id ); CREATE INDEX foreign_key_constraint_database_id_idx ON metaschema_public.foreign_key_constraint ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/full_text_search/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/full_text_search/table.sql index 4cb2c03c7..5c6847777 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/full_text_search/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/full_text_search/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE metaschema_public.full_text_search ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -21,8 +21,6 @@ CREATE TABLE metaschema_public.full_text_search ( CHECK (cardinality(field_ids) = cardinality(weights) AND cardinality(weights) = cardinality(langs)) ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.full_text_search IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.full_text_search IS E'@omit manyToMany'; CREATE INDEX full_text_search_table_id_idx ON metaschema_public.full_text_search ( table_id ); CREATE INDEX full_text_search_database_id_idx ON metaschema_public.full_text_search ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/index/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/index/table.sql index 320d44b1a..ac10e060e 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/index/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/index/table.sql @@ -8,7 +8,7 @@ BEGIN; CREATE TABLE metaschema_public.index ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, table_id uuid NOT NULL, name text NOT NULL DEFAULT '', @@ -22,6 +22,9 @@ CREATE TABLE metaschema_public.index ( where_clause jsonb, is_unique boolean NOT NULL default false, + options jsonb, + op_classes text[], + smart_tags jsonb, category metaschema_public.object_category NOT NULL DEFAULT 'app', @@ -37,8 +40,6 @@ CREATE TABLE metaschema_public.index ( UNIQUE (database_id, name) ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.index IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.index IS E'@omit manyToMany'; CREATE INDEX index_table_id_idx ON metaschema_public.index ( table_id ); CREATE INDEX index_database_id_idx ON metaschema_public.index ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/policy/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/policy/table.sql index f8429b84f..bd6067d49 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/policy/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/policy/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE metaschema_public.policy ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -39,8 +39,6 @@ CREATE TABLE metaschema_public.policy ( UNIQUE (table_id, name) ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.policy IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.policy IS E'@omit manyToMany'; CREATE INDEX policy_table_id_idx ON metaschema_public.policy ( table_id ); CREATE INDEX policy_database_id_idx ON metaschema_public.policy ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/primary_key_constraint/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/primary_key_constraint/table.sql index 00e8b7ac1..e7a1f7a9b 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/primary_key_constraint/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/primary_key_constraint/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE metaschema_public.primary_key_constraint ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -29,8 +29,6 @@ CREATE TABLE metaschema_public.primary_key_constraint ( CHECK (field_ids <> '{}') ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.primary_key_constraint IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.primary_key_constraint IS E'@omit manyToMany'; CREATE INDEX primary_key_constraint_table_id_idx ON metaschema_public.primary_key_constraint ( table_id ); CREATE INDEX primary_key_constraint_database_id_idx ON metaschema_public.primary_key_constraint ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema/table.sql index f22c7f0c6..ad79ee119 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE metaschema_public.schema ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, name text NOT NULL, @@ -37,7 +37,6 @@ CREATE TABLE metaschema_public.schema ( ALTER TABLE metaschema_public.schema ADD CONSTRAINT schema_namechk CHECK (char_length(name) > 2); -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.schema IS E'@omit manyToMany'; CREATE INDEX schema_database_id_idx ON metaschema_public.schema ( database_id ); COMMIT; diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema_grant/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema_grant/table.sql index e3be7743c..1235d040c 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema_grant/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/schema_grant/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE metaschema_public.schema_grant ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), schema_id uuid NOT NULL, @@ -18,8 +18,6 @@ CREATE TABLE metaschema_public.schema_grant ( ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_public.schema_grant IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.schema_grant IS E'@omit manyToMany'; CREATE INDEX schema_grant_schema_id_idx ON metaschema_public.schema_grant ( schema_id ); CREATE INDEX schema_grant_database_id_idx ON metaschema_public.schema_grant ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table/table.sql index d76eb1cc2..5beefa08d 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE metaschema_public.table ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), schema_id uuid NOT NULL, @@ -42,8 +42,6 @@ CREATE TABLE metaschema_public.table ( ALTER TABLE metaschema_public.table ADD COLUMN inherits_id uuid NULL REFERENCES metaschema_public.table(id); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_public.table IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.table IS E'@omit manyToMany'; CREATE INDEX table_schema_id_idx ON metaschema_public.table ( schema_id ); CREATE INDEX table_database_id_idx ON metaschema_public.table ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table_grant/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table_grant/table.sql index d11af29f8..68273ad2e 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table_grant/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/table_grant/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE metaschema_public.table_grant ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -22,8 +22,6 @@ CREATE TABLE metaschema_public.table_grant ( CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.table_grant IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.table_grant IS E'@omit manyToMany'; CREATE INDEX table_grant_table_id_idx ON metaschema_public.table_grant ( table_id ); CREATE INDEX table_grant_database_id_idx ON metaschema_public.table_grant ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger/table.sql index c38e79c0b..eb61da234 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger/table.sql @@ -9,7 +9,7 @@ BEGIN; -- https://www.postgresql.org/docs/12/sql-createtrigger.html CREATE TABLE metaschema_public.trigger ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -31,8 +31,6 @@ CREATE TABLE metaschema_public.trigger ( UNIQUE(table_id, name) ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.trigger IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.trigger IS E'@omit manyToMany'; CREATE INDEX trigger_table_id_idx ON metaschema_public.trigger ( table_id ); CREATE INDEX trigger_database_id_idx ON metaschema_public.trigger ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger_function/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger_function/table.sql index ac51da868..6c568d1a0 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger_function/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/trigger_function/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE metaschema_public.trigger_function ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, name text NOT NULL, @@ -17,7 +17,6 @@ CREATE TABLE metaschema_public.trigger_function ( UNIQUE (database_id, name) ); -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.trigger_function IS E'@omit manyToMany'; CREATE INDEX trigger_function_database_id_idx ON metaschema_public.trigger_function ( database_id ); COMMIT; diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/unique_constraint/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/unique_constraint/table.sql index ff46166aa..9a03732a8 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/unique_constraint/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/unique_constraint/table.sql @@ -8,7 +8,7 @@ BEGIN; CREATE TABLE metaschema_public.unique_constraint ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, @@ -34,8 +34,6 @@ CREATE TABLE metaschema_public.unique_constraint ( CHECK (field_ids <> '{}') ); -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.unique_constraint IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.unique_constraint IS E'@omit manyToMany'; CREATE INDEX unique_constraint_table_id_idx ON metaschema_public.unique_constraint ( table_id ); CREATE INDEX unique_constraint_database_id_idx ON metaschema_public.unique_constraint ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view/table.sql index 7058ea017..4fc9b6bea 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view/table.sql @@ -9,7 +9,7 @@ BEGIN; CREATE TABLE metaschema_public.view ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), schema_id uuid NOT NULL, @@ -48,9 +48,6 @@ CREATE TABLE metaschema_public.view ( UNIQUE (schema_id, name) ); -COMMENT ON CONSTRAINT schema_fkey ON metaschema_public.view IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.view IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.view IS E'@omit manyToMany'; CREATE INDEX view_schema_id_idx ON metaschema_public.view ( schema_id ); CREATE INDEX view_database_id_idx ON metaschema_public.view ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_grant/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_grant/table.sql index 9e5dd2ed0..a87f7e255 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_grant/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_grant/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE metaschema_public.view_grant ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), view_id uuid NOT NULL, @@ -25,8 +25,6 @@ CREATE TABLE metaschema_public.view_grant ( UNIQUE (view_id, grantee_name, privilege, is_grant) ); -COMMENT ON CONSTRAINT view_fkey ON metaschema_public.view_grant IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.view_grant IS E'@omit manyToMany'; CREATE INDEX view_grant_view_id_idx ON metaschema_public.view_grant ( view_id ); CREATE INDEX view_grant_database_id_idx ON metaschema_public.view_grant ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_rule/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_rule/table.sql index fc52303ac..116203ea7 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_rule/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_rule/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE metaschema_public.view_rule ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL DEFAULT uuid_nil(), view_id uuid NOT NULL, @@ -25,8 +25,6 @@ COMMENT ON TABLE metaschema_public.view_rule IS 'DO INSTEAD rules for views (e.g COMMENT ON COLUMN metaschema_public.view_rule.event IS 'INSERT, UPDATE, or DELETE'; COMMENT ON COLUMN metaschema_public.view_rule.action IS 'NOTHING (for read-only) or custom action'; -COMMENT ON CONSTRAINT view_fkey ON metaschema_public.view_rule IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON metaschema_public.view_rule IS E'@omit manyToMany'; CREATE INDEX view_rule_view_id_idx ON metaschema_public.view_rule ( view_id ); CREATE INDEX view_rule_database_id_idx ON metaschema_public.view_rule ( database_id ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_table/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_table/table.sql index e01b87aee..6992e061c 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_table/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/view_table/table.sql @@ -10,7 +10,7 @@ BEGIN; -- This provides referential integrity for views that reference multiple tables. -- The primary table is stored in view.table_id; this table stores additional joined tables. CREATE TABLE metaschema_public.view_table ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), view_id uuid NOT NULL, table_id uuid NOT NULL, @@ -24,8 +24,6 @@ CREATE TABLE metaschema_public.view_table ( ); COMMENT ON TABLE metaschema_public.view_table IS 'Junction table linking views to their joined tables for referential integrity'; -COMMENT ON CONSTRAINT view_fkey ON metaschema_public.view_table IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT table_fkey ON metaschema_public.view_table IS E'@omit manyToMany'; CREATE INDEX view_table_view_id_idx ON metaschema_public.view_table ( view_id ); CREATE INDEX view_table_table_id_idx ON metaschema_public.view_table ( table_id ); diff --git a/packages/metaschema-schema/pgpm.plan b/packages/metaschema-schema/pgpm.plan index d7d0f44a3..6ced647e1 100644 --- a/packages/metaschema-schema/pgpm.plan +++ b/packages/metaschema-schema/pgpm.plan @@ -29,3 +29,5 @@ schemas/metaschema_public/tables/view_grant/table [schemas/metaschema_public/sch 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 # add schemas/metaschema_public/tables/view_rule/table 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 # add schemas/metaschema_public/tables/default_privilege/table schemas/metaschema_public/tables/enum/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/schema/table schemas/metaschema_public/types/object_category] 2026-03-15T00:00:00Z devin # add schemas/metaschema_public/tables/enum/table +schemas/metaschema_public/tables/embedding_chunks/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/tables/field/table] 2026-03-19T00:00:00Z devin # add schemas/metaschema_public/tables/embedding_chunks/table + diff --git a/packages/metaschema-schema/revert/schemas/metaschema_public/tables/embedding_chunks/table.sql b/packages/metaschema-schema/revert/schemas/metaschema_public/tables/embedding_chunks/table.sql new file mode 100644 index 000000000..2c1919e8d --- /dev/null +++ b/packages/metaschema-schema/revert/schemas/metaschema_public/tables/embedding_chunks/table.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_public/tables/embedding_chunks/table from pg + +BEGIN; + +DROP TABLE IF EXISTS metaschema_public.embedding_chunks; + +COMMIT; diff --git a/packages/metaschema-schema/verify/schemas/metaschema_public/tables/embedding_chunks/table.sql b/packages/metaschema-schema/verify/schemas/metaschema_public/tables/embedding_chunks/table.sql new file mode 100644 index 000000000..d054f598d --- /dev/null +++ b/packages/metaschema-schema/verify/schemas/metaschema_public/tables/embedding_chunks/table.sql @@ -0,0 +1,25 @@ +-- Verify schemas/metaschema_public/tables/embedding_chunks/table on pg + +BEGIN; + +SELECT + id, + database_id, + table_id, + embedding_field_id, + chunks_table_id, + chunks_table_name, + content_field_name, + dimensions, + metric, + chunk_size, + chunk_overlap, + chunk_strategy, + metadata_fields, + enqueue_chunking_job, + chunking_task_name, + parent_fk_field_id +FROM metaschema_public.embedding_chunks +WHERE FALSE; + +ROLLBACK; diff --git a/packages/services/deploy/schemas/services_public/tables/api_modules/table.sql b/packages/services/deploy/schemas/services_public/tables/api_modules/table.sql index e95741f97..befbdb7fc 100644 --- a/packages/services/deploy/schemas/services_public/tables/api_modules/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/api_modules/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE services_public.api_modules ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, api_id uuid NOT NULL, name text NOT NULL, @@ -27,10 +27,8 @@ COMMENT ON COLUMN services_public.api_modules.name IS 'Module name (e.g. auth, u COMMENT ON COLUMN services_public.api_modules.data IS 'JSON configuration data for this module'; ALTER TABLE services_public.api_modules ADD CONSTRAINT api_modules_api_id_fkey FOREIGN KEY ( api_id ) REFERENCES services_public.apis ( id ); -COMMENT ON CONSTRAINT api_modules_api_id_fkey ON services_public.api_modules IS E'@omit manyToMany'; CREATE INDEX api_modules_api_id_idx ON services_public.api_modules ( api_id ); -COMMENT ON CONSTRAINT db_fkey ON services_public.api_modules IS E'@omit manyToMany'; CREATE INDEX api_modules_database_id_idx ON services_public.api_modules ( database_id ); diff --git a/packages/services/deploy/schemas/services_public/tables/api_schemas/table.sql b/packages/services/deploy/schemas/services_public/tables/api_schemas/table.sql index 4530e72a9..60d12de5c 100644 --- a/packages/services/deploy/schemas/services_public/tables/api_schemas/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/api_schemas/table.sql @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE services_public.api_schemas ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, schema_id uuid NOT NULL, api_id uuid NOT NULL, @@ -24,9 +24,6 @@ COMMENT ON COLUMN services_public.api_schemas.database_id IS 'Reference to the m COMMENT ON COLUMN services_public.api_schemas.schema_id IS 'Metaschema schema being exposed through the API'; COMMENT ON COLUMN services_public.api_schemas.api_id IS 'API that exposes this schema'; --- COMMENT ON CONSTRAINT schema_fkey ON services_public.api_schemas IS E'@omit manyToMany'; --- COMMENT ON CONSTRAINT api_fkey ON services_public.api_schemas IS E'@omit manyToMany'; -COMMENT ON CONSTRAINT db_fkey ON services_public.api_schemas IS E'@omit manyToMany'; CREATE INDEX api_schemas_database_id_idx ON services_public.api_schemas ( database_id ); diff --git a/packages/services/deploy/schemas/services_public/tables/apis/table.sql b/packages/services/deploy/schemas/services_public/tables/apis/table.sql index b8c907590..1b068295f 100644 --- a/packages/services/deploy/schemas/services_public/tables/apis/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/apis/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE services_public.apis ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, name text NOT NULL, dbname text NOT NULL DEFAULT current_database(), @@ -29,7 +29,6 @@ COMMENT ON COLUMN services_public.apis.role_name IS 'PostgreSQL role used for au COMMENT ON COLUMN services_public.apis.anon_role IS 'PostgreSQL role used for anonymous/unauthenticated requests'; COMMENT ON COLUMN services_public.apis.is_public IS 'Whether this API is publicly accessible without authentication'; -COMMENT ON CONSTRAINT db_fkey ON services_public.apis IS E'@omit manyToMany'; CREATE INDEX apis_database_id_idx ON services_public.apis ( database_id ); COMMIT; diff --git a/packages/services/deploy/schemas/services_public/tables/apps/table.sql b/packages/services/deploy/schemas/services_public/tables/apps/table.sql index 1858d10d7..b9856e923 100644 --- a/packages/services/deploy/schemas/services_public/tables/apps/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/apps/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE services_public.apps ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, site_id uuid NOT NULL, name text, @@ -35,10 +35,8 @@ COMMENT ON COLUMN services_public.apps.app_id_prefix IS 'Apple App ID prefix (Te COMMENT ON COLUMN services_public.apps.play_store_link IS 'URL to the Google Play Store listing'; ALTER TABLE services_public.apps ADD CONSTRAINT apps_site_id_fkey FOREIGN KEY ( site_id ) REFERENCES services_public.sites ( id ); -COMMENT ON CONSTRAINT apps_site_id_fkey ON services_public.apps IS E'@omit manyToMany'; CREATE INDEX apps_site_id_idx ON services_public.apps ( site_id ); -COMMENT ON CONSTRAINT db_fkey ON services_public.apps IS E'@omit manyToMany'; CREATE INDEX apps_database_id_idx ON services_public.apps ( database_id ); diff --git a/packages/services/deploy/schemas/services_public/tables/domains/table.sql b/packages/services/deploy/schemas/services_public/tables/domains/table.sql index 26aa06f38..bf1c12e84 100644 --- a/packages/services/deploy/schemas/services_public/tables/domains/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/domains/table.sql @@ -8,7 +8,7 @@ BEGIN; CREATE TABLE services_public.domains ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, api_id uuid, @@ -37,13 +37,10 @@ COMMENT ON COLUMN services_public.domains.site_id IS 'Site this domain routes to COMMENT ON COLUMN services_public.domains.subdomain IS 'Subdomain portion of the hostname'; COMMENT ON COLUMN services_public.domains.domain IS 'Root domain of the hostname'; -COMMENT ON CONSTRAINT db_fkey ON services_public.domains IS E'@omit manyToMany'; CREATE INDEX domains_database_id_idx ON services_public.domains ( database_id ); -COMMENT ON CONSTRAINT api_fkey ON services_public.domains IS E'@omit manyToMany'; CREATE INDEX domains_api_id_idx ON services_public.domains ( api_id ); -COMMENT ON CONSTRAINT site_fkey ON services_public.domains IS E'@omit manyToMany'; CREATE INDEX domains_site_id_idx ON services_public.domains ( site_id ); COMMIT; diff --git a/packages/services/deploy/schemas/services_public/tables/site_metadata/table.sql b/packages/services/deploy/schemas/services_public/tables/site_metadata/table.sql index 9d6d5afcb..0cc0462b9 100644 --- a/packages/services/deploy/schemas/services_public/tables/site_metadata/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/site_metadata/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE services_public.site_metadata ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, site_id uuid NOT NULL, title text, @@ -32,10 +32,8 @@ COMMENT ON COLUMN services_public.site_metadata.description IS 'Meta description COMMENT ON COLUMN services_public.site_metadata.og_image IS 'Open Graph image for social media previews'; ALTER TABLE services_public.site_metadata ADD CONSTRAINT site_metadata_site_id_fkey FOREIGN KEY ( site_id ) REFERENCES services_public.sites ( id ); -COMMENT ON CONSTRAINT site_metadata_site_id_fkey ON services_public.site_metadata IS E'@omit manyToMany'; CREATE INDEX site_metadata_site_id_idx ON services_public.site_metadata ( site_id ); -COMMENT ON CONSTRAINT db_fkey ON services_public.site_metadata IS E'@omit manyToMany'; CREATE INDEX site_metadata_database_id_idx ON services_public.site_metadata ( database_id ); COMMIT; diff --git a/packages/services/deploy/schemas/services_public/tables/site_modules/table.sql b/packages/services/deploy/schemas/services_public/tables/site_modules/table.sql index 0fc227459..20bdf25f7 100644 --- a/packages/services/deploy/schemas/services_public/tables/site_modules/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/site_modules/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE services_public.site_modules ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, site_id uuid NOT NULL, name text NOT NULL, @@ -25,10 +25,8 @@ COMMENT ON COLUMN services_public.site_modules.name IS 'Module name (e.g. user_a COMMENT ON COLUMN services_public.site_modules.data IS 'JSON configuration data for this module'; ALTER TABLE services_public.site_modules ADD CONSTRAINT site_modules_site_id_fkey FOREIGN KEY ( site_id ) REFERENCES services_public.sites ( id ); -COMMENT ON CONSTRAINT site_modules_site_id_fkey ON services_public.site_modules IS E'@omit manyToMany'; CREATE INDEX site_modules_site_id_idx ON services_public.site_modules ( site_id ); -COMMENT ON CONSTRAINT db_fkey ON services_public.site_modules IS E'@omit manyToMany'; CREATE INDEX site_modules_database_id_idx ON services_public.site_modules ( database_id ); diff --git a/packages/services/deploy/schemas/services_public/tables/site_themes/table.sql b/packages/services/deploy/schemas/services_public/tables/site_themes/table.sql index 2c1fd17e2..bd88291b2 100644 --- a/packages/services/deploy/schemas/services_public/tables/site_themes/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/site_themes/table.sql @@ -7,7 +7,7 @@ BEGIN; CREATE TABLE services_public.site_themes ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, site_id uuid NOT NULL, theme jsonb NOT NULL, @@ -24,10 +24,8 @@ COMMENT ON COLUMN services_public.site_themes.site_id IS 'Site this theme belong COMMENT ON COLUMN services_public.site_themes.theme IS 'JSONB object containing theme tokens (colors, typography, spacing, etc.)'; ALTER TABLE services_public.site_themes ADD CONSTRAINT site_themes_site_id_fkey FOREIGN KEY ( site_id ) REFERENCES services_public.sites ( id ); -COMMENT ON CONSTRAINT site_themes_site_id_fkey ON services_public.site_themes IS E'@omit manyToMany'; CREATE INDEX site_themes_site_id_idx ON services_public.site_themes ( site_id ); -COMMENT ON CONSTRAINT db_fkey ON services_public.site_themes IS E'@omit manyToMany'; CREATE INDEX site_themes_database_id_idx ON services_public.site_themes ( database_id ); COMMIT; diff --git a/packages/services/deploy/schemas/services_public/tables/sites/table.sql b/packages/services/deploy/schemas/services_public/tables/sites/table.sql index c9bccfc82..149a7178e 100644 --- a/packages/services/deploy/schemas/services_public/tables/sites/table.sql +++ b/packages/services/deploy/schemas/services_public/tables/sites/table.sql @@ -6,7 +6,7 @@ BEGIN; CREATE TABLE services_public.sites ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + id uuid PRIMARY KEY DEFAULT uuidv7(), database_id uuid NOT NULL, title text, description text, @@ -35,7 +35,6 @@ COMMENT ON COLUMN services_public.sites.apple_touch_icon IS 'Apple touch icon fo COMMENT ON COLUMN services_public.sites.logo IS 'Primary logo image for the site'; COMMENT ON COLUMN services_public.sites.dbname IS 'PostgreSQL database name this site connects to'; -COMMENT ON CONSTRAINT db_fkey ON services_public.sites IS E'@omit manyToMany'; CREATE INDEX sites_database_id_idx ON services_public.sites ( database_id ); COMMIT; diff --git a/packages/stamps/pgpm-stamps.control b/packages/stamps/pgpm-stamps.control index 42541d0f7..19449b9c0 100644 --- a/packages/stamps/pgpm-stamps.control +++ b/packages/stamps/pgpm-stamps.control @@ -1,6 +1,6 @@ # pgpm-stamps extension comment = 'pgpm-stamps extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-stamps' requires = 'plpgsql,pgpm-jwt-claims,pgpm-verify' relocatable = false diff --git a/packages/totp/pgpm-totp.control b/packages/totp/pgpm-totp.control index 98e02a5bc..56003b43d 100644 --- a/packages/totp/pgpm-totp.control +++ b/packages/totp/pgpm-totp.control @@ -1,6 +1,6 @@ # pgpm-totp extension comment = 'pgpm-totp extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-totp' requires = 'pgcrypto,plpgsql,pgpm-base32,pgpm-verify' relocatable = false diff --git a/packages/utils/pgpm-utils.control b/packages/utils/pgpm-utils.control index c80698abc..6722dbd65 100644 --- a/packages/utils/pgpm-utils.control +++ b/packages/utils/pgpm-utils.control @@ -1,6 +1,6 @@ # pgpm-utils extension comment = 'pgpm-utils extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-utils' requires = 'plpgsql,pgpm-verify' relocatable = false diff --git a/packages/verify/pgpm-verify.control b/packages/verify/pgpm-verify.control index 1a07371d7..7b3c7b8fe 100644 --- a/packages/verify/pgpm-verify.control +++ b/packages/verify/pgpm-verify.control @@ -1,6 +1,6 @@ # pgpm-verify extension comment = 'pgpm-verify extension' -default_version = '0.15.3' +default_version = '0.15.5' module_pathname = '$libdir/pgpm-verify' requires = 'plpgsql' relocatable = false