From 5f093e2d3dec64084e19681e2268517b21b9407f Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 14 Jan 2026 00:42:59 +0000 Subject: [PATCH 1/4] feat: upstream metaschema changes from constructive-db metaschema-modules package: - Add table_module table for table-level modules with node_type pattern - Add user_profiles_module table for user profiles configuration - Add user_settings_module table for user settings configuration - Add organization_settings_module table for organization settings configuration - Update field_module to add node_type column and index - Update memberships_module to add default_is_approved and default_is_verified columns metaschema-schema package: - Add object_category enum type ('core', 'module', 'app') for unified categorization - Update policy table: rename template to policy_type, add smart_tags, category, module, scope, tags - Update schema table: add smart_tags, category, module, scope, tags, is_public - Update table: use object_category instead of inline table_category type - Update field: use object_category instead of inline field_category type - Update procedure, trigger, index tables: add categorization columns - Update check_constraint, foreign_key_constraint, primary_key_constraint, unique_constraint: add categorization columns - Update pgpm.plan with object_category type and dependencies --- .../tables/field_module/table.sql | 5 +-- .../tables/memberships_module/table.sql | 3 ++ .../organization_settings_module/table.sql | 34 +++++++++++++++++++ .../tables/table_module/table.sql | 34 +++++++++++++++++++ .../tables/user_profiles_module/table.sql | 34 +++++++++++++++++++ .../tables/user_settings_module/table.sql | 34 +++++++++++++++++++ packages/metaschema-modules/pgpm.plan | 4 +++ .../organization_settings_module/table.sql | 7 ++++ .../tables/table_module/table.sql | 7 ++++ .../tables/user_profiles_module/table.sql | 7 ++++ .../tables/user_settings_module/table.sql | 7 ++++ .../organization_settings_module/table.sql | 16 +++++++++ .../tables/table_module/table.sql | 16 +++++++++ .../tables/user_profiles_module/table.sql | 16 +++++++++ .../tables/user_settings_module/table.sql | 16 +++++++++ .../tables/check_constraint/table.sql | 10 +++++- .../metaschema_public/tables/field/table.sql | 25 ++------------ .../tables/foreign_key_constraint/table.sql | 9 +++-- .../metaschema_public/tables/index/table.sql | 10 ++++-- .../metaschema_public/tables/policy/table.sql | 15 ++++---- .../tables/primary_key_constraint/table.sql | 10 +++++- .../tables/procedure/table.sql | 14 +++++--- .../metaschema_public/tables/schema/table.sql | 15 +++++--- .../metaschema_public/tables/table/table.sql | 5 ++- .../tables/trigger/table.sql | 14 +++++--- .../tables/unique_constraint/table.sql | 11 +++--- .../types/object_category.sql | 9 +++++ packages/metaschema-schema/pgpm.plan | 23 +++++++------ .../types/object_category.sql | 7 ++++ .../types/object_category.sql | 7 ++++ 30 files changed, 357 insertions(+), 67 deletions(-) create mode 100644 packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql create mode 100644 packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_module/table.sql create mode 100644 packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql create mode 100644 packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql create mode 100644 packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql create mode 100644 packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/table_module/table.sql create mode 100644 packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql create mode 100644 packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql create mode 100644 packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql create mode 100644 packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/table_module/table.sql create mode 100644 packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql create mode 100644 packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql create mode 100644 packages/metaschema-schema/deploy/schemas/metaschema_public/types/object_category.sql create mode 100644 packages/metaschema-schema/revert/schemas/metaschema_public/types/object_category.sql create mode 100644 packages/metaschema-schema/verify/schemas/metaschema_public/types/object_category.sql 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 bd404ea6..dd6c431d 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 @@ -13,8 +13,8 @@ CREATE TABLE metaschema_modules_public.field_module ( table_id uuid NOT NULL DEFAULT uuid_nil(), field_id uuid NOT NULL DEFAULT uuid_nil(), - -- data = '{"regexp":"^kjhsdkjhsd$"}' - -- data = '{"min":10, "max": 20}' + node_type text NOT NULL, + data jsonb NOT NULL DEFAULT '{}', triggers text[], @@ -32,6 +32,7 @@ COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.field_module IS E' 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 ); 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 3a869ec9..0cac915f 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 @@ -54,6 +54,9 @@ CREATE TABLE metaschema_modules_public.memberships_module ( entity_ids_by_perm text NULL, entity_ids_function text NULL, + default_is_approved boolean NOT NULL DEFAULT TRUE, + default_is_verified boolean NOT NULL DEFAULT TRUE, + -- CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql new file mode 100644 index 00000000..b93b66ef --- /dev/null +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql @@ -0,0 +1,34 @@ +-- Deploy schemas/metaschema_modules_public/tables/organization_settings_module/table to pg + +-- requires: schemas/metaschema_modules_public/schema + +BEGIN; + +CREATE TABLE metaschema_modules_public.organization_settings_module ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + database_id uuid NOT NULL, + + schema_id uuid NOT NULL DEFAULT uuid_nil(), + private_schema_id uuid NOT NULL DEFAULT uuid_nil(), + + table_id uuid NOT NULL DEFAULT uuid_nil(), + owner_table_id uuid NOT NULL DEFAULT uuid_nil(), + + table_name text NOT NULL, + + -- + 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 owner_table_fkey FOREIGN KEY (owner_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, + 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.organization_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.organization_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.organization_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.organization_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.organization_settings_module IS E'@omit manyToMany'; +CREATE INDEX organization_settings_module_database_id_idx ON metaschema_modules_public.organization_settings_module ( database_id ); + +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 new file mode 100644 index 00000000..b4b360a3 --- /dev/null +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/table_module/table.sql @@ -0,0 +1,34 @@ +-- 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, + + private_schema_id uuid NOT NULL DEFAULT uuid_nil(), + + table_id uuid NOT NULL, + + node_type text NOT NULL, + + 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 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.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/user_profiles_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql new file mode 100644 index 00000000..285f483e --- /dev/null +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql @@ -0,0 +1,34 @@ +-- Deploy schemas/metaschema_modules_public/tables/user_profiles_module/table to pg + +-- requires: schemas/metaschema_modules_public/schema + +BEGIN; + +CREATE TABLE metaschema_modules_public.user_profiles_module ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + database_id uuid NOT NULL, + + schema_id uuid NOT NULL DEFAULT uuid_nil(), + private_schema_id uuid NOT NULL DEFAULT uuid_nil(), + + table_id uuid NOT NULL DEFAULT uuid_nil(), + owner_table_id uuid NOT NULL DEFAULT uuid_nil(), + + table_name text NOT NULL, + + -- + 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 owner_table_fkey FOREIGN KEY (owner_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, + 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.user_profiles_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.user_profiles_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.user_profiles_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.user_profiles_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.user_profiles_module IS E'@omit manyToMany'; +CREATE INDEX user_profiles_module_database_id_idx ON metaschema_modules_public.user_profiles_module ( database_id ); + +COMMIT; diff --git a/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql new file mode 100644 index 00000000..ed38c80a --- /dev/null +++ b/packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql @@ -0,0 +1,34 @@ +-- Deploy schemas/metaschema_modules_public/tables/user_settings_module/table to pg + +-- requires: schemas/metaschema_modules_public/schema + +BEGIN; + +CREATE TABLE metaschema_modules_public.user_settings_module ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), + database_id uuid NOT NULL, + + schema_id uuid NOT NULL DEFAULT uuid_nil(), + private_schema_id uuid NOT NULL DEFAULT uuid_nil(), + + table_id uuid NOT NULL DEFAULT uuid_nil(), + owner_table_id uuid NOT NULL DEFAULT uuid_nil(), + + table_name text NOT NULL, + + -- + 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 owner_table_fkey FOREIGN KEY (owner_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, + 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.user_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.user_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.user_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.user_settings_module IS E'@omit manyToMany'; +COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.user_settings_module IS E'@omit manyToMany'; +CREATE INDEX user_settings_module_database_id_idx ON metaschema_modules_public.user_settings_module ( database_id ); + +COMMIT; diff --git a/packages/metaschema-modules/pgpm.plan b/packages/metaschema-modules/pgpm.plan index 10f4bd23..1c43224e 100644 --- a/packages/metaschema-modules/pgpm.plan +++ b/packages/metaschema-modules/pgpm.plan @@ -30,3 +30,7 @@ schemas/metaschema_modules_public/tables/user_auth_module/table [schemas/metasch 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_module/table [schemas/metaschema_modules_public/schema] 2026-01-14T00:00:00Z devin # add schemas/metaschema_modules_public/tables/table_module/table +schemas/metaschema_modules_public/tables/user_profiles_module/table [schemas/metaschema_modules_public/schema] 2026-01-14T00:00:00Z devin # add schemas/metaschema_modules_public/tables/user_profiles_module/table +schemas/metaschema_modules_public/tables/user_settings_module/table [schemas/metaschema_modules_public/schema] 2026-01-14T00:00:00Z devin # add schemas/metaschema_modules_public/tables/user_settings_module/table +schemas/metaschema_modules_public/tables/organization_settings_module/table [schemas/metaschema_modules_public/schema] 2026-01-14T00:00:00Z devin # add schemas/metaschema_modules_public/tables/organization_settings_module/table diff --git a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql new file mode 100644 index 00000000..8b045968 --- /dev/null +++ b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_modules_public/tables/organization_settings_module/table from pg + +BEGIN; + +DROP TABLE IF EXISTS metaschema_modules_public.organization_settings_module; + +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 new file mode 100644 index 00000000..e2cdf826 --- /dev/null +++ b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/table_module/table.sql @@ -0,0 +1,7 @@ +-- 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/user_profiles_module/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql new file mode 100644 index 00000000..521fdee0 --- /dev/null +++ b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_modules_public/tables/user_profiles_module/table from pg + +BEGIN; + +DROP TABLE IF EXISTS metaschema_modules_public.user_profiles_module; + +COMMIT; diff --git a/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql new file mode 100644 index 00000000..95138ae6 --- /dev/null +++ b/packages/metaschema-modules/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_modules_public/tables/user_settings_module/table from pg + +BEGIN; + +DROP TABLE IF EXISTS metaschema_modules_public.user_settings_module; + +COMMIT; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql new file mode 100644 index 00000000..ef5ee55d --- /dev/null +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/organization_settings_module/table.sql @@ -0,0 +1,16 @@ +-- Verify schemas/metaschema_modules_public/tables/organization_settings_module/table on pg + +BEGIN; + +SELECT + id, + database_id, + schema_id, + private_schema_id, + table_id, + owner_table_id, + table_name +FROM metaschema_modules_public.organization_settings_module +WHERE FALSE; + +ROLLBACK; 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 new file mode 100644 index 00000000..e9467249 --- /dev/null +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/table_module/table.sql @@ -0,0 +1,16 @@ +-- Verify schemas/metaschema_modules_public/tables/table_module/table on pg + +BEGIN; + +SELECT + id, + database_id, + private_schema_id, + table_id, + node_type, + data, + fields +FROM metaschema_modules_public.table_module +WHERE FALSE; + +ROLLBACK; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql new file mode 100644 index 00000000..cf61cae2 --- /dev/null +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_profiles_module/table.sql @@ -0,0 +1,16 @@ +-- Verify schemas/metaschema_modules_public/tables/user_profiles_module/table on pg + +BEGIN; + +SELECT + id, + database_id, + schema_id, + private_schema_id, + table_id, + owner_table_id, + table_name +FROM metaschema_modules_public.user_profiles_module +WHERE FALSE; + +ROLLBACK; diff --git a/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql new file mode 100644 index 00000000..d6ece694 --- /dev/null +++ b/packages/metaschema-modules/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql @@ -0,0 +1,16 @@ +-- Verify schemas/metaschema_modules_public/tables/user_settings_module/table on pg + +BEGIN; + +SELECT + id, + database_id, + schema_id, + private_schema_id, + table_id, + owner_table_id, + table_name +FROM metaschema_modules_public.user_settings_module +WHERE FALSE; + +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 3b73bf5e..91a199eb 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 @@ -3,6 +3,7 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/database/table -- requires: schemas/metaschema_public/tables/table/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -15,7 +16,14 @@ CREATE TABLE metaschema_public.check_constraint ( type text, field_ids uuid[] NOT NULL, expr jsonb, - -- + + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, 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 3b100692..e1851a39 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 @@ -3,27 +3,10 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/table/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; --- TODO should we just query this table and make a view? --- https://www.postgresql.org/docs/9.2/catalog-pg-attribute.html - --- IF YOU WANT TO REMOVE THIS TABLE, answer the qustion, how would you add RLS to this: --- SELECT --- attrelid::text AS tbl --- , attname::text AS col --- , p.attnum::int as id, --- t.typname as typename - --- FROM pg_catalog.pg_attribute p --- INNER JOIN pg_catalog.pg_type t ON (t.oid = p.atttypid) --- WHERE attrelid = 'dude_schema.products'::regclass --- AND p.attnum > 0 --- AND NOT attisdropped; - -CREATE TYPE metaschema_public.field_category AS ENUM ('core', 'module', 'app'); - CREATE TABLE metaschema_public.field ( id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), database_id uuid NOT NULL DEFAULT uuid_nil(), @@ -58,11 +41,7 @@ CREATE TABLE metaschema_public.field ( tags citext[] NOT NULL DEFAULT '{}', - -- Field categorization for system/module/app fields (mirrors table categorization) - -- category: 'core' for system fields (id, entity_id, actor_id), 'module' for module-generated fields, 'app' for user-defined fields - -- module: the module name that created this field (e.g., 'users', 'permissions', 'memberships') - -- scope: membership_type int (1=app, 2=org, 3=group, NULL=not scoped) - category metaschema_public.field_category NOT NULL DEFAULT 'app', + category metaschema_public.object_category NOT NULL DEFAULT 'app', module text NULL, scope int NULL, 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 983f6ca7..f6b0bc8e 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 @@ -3,6 +3,7 @@ -- requires: schemas/metaschema_public/tables/field/table -- requires: schemas/metaschema_public/tables/table/table -- requires: schemas/metaschema_public/schema +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -18,10 +19,14 @@ CREATE TABLE metaschema_public.foreign_key_constraint ( field_ids uuid[] NOT NULL, ref_table_id uuid NOT NULL REFERENCES metaschema_public.table (id) ON DELETE CASCADE, ref_field_ids uuid[] NOT NULL, - delete_action char(1) DEFAULT 'c', -- postgres default is 'a' + delete_action char(1) DEFAULT 'c', update_action char(1) DEFAULT 'a', - -- + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, 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 fa4e7383..f575950c 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 @@ -3,6 +3,7 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/table/table -- requires: schemas/metaschema_public/tables/database/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -21,12 +22,17 @@ CREATE TABLE metaschema_public.index ( where_clause jsonb, is_unique boolean NOT NULL default false, - -- + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, - -- index names are UNIQUE across schemas, so for portability we will check against database_id UNIQUE (database_id, name) ); 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 f6e07f18..e3ea79fc 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 @@ -2,6 +2,7 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/table/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -14,17 +15,19 @@ CREATE TABLE metaschema_public.policy ( role_name text, privilege text, - -- using_expression text, - -- check_expression text, - -- policy_text text, - permissive boolean default true, disabled boolean default false, - template text, + policy_type text, data jsonb, - -- + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, 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 52354546..00e8b7ac 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 @@ -1,6 +1,7 @@ -- Deploy schemas/metaschema_public/tables/primary_key_constraint/table to pg -- requires: schemas/metaschema_public/schema +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -12,7 +13,14 @@ CREATE TABLE metaschema_public.primary_key_constraint ( name text, type text, field_ids uuid[] NOT NULL, - -- + + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/procedure/table.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/procedure/table.sql index 1eca75a5..701ff7b2 100644 --- a/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/procedure/table.sql +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/tables/procedure/table.sql @@ -2,6 +2,7 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/database/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -11,16 +12,21 @@ CREATE TABLE metaschema_public.procedure ( name text NOT NULL, - -- MAYBE MAKE A SPECIAL RLS functions for policy making... - - -- can we make this all JSON? argnames text[], argtypes text[], argdefaults text[], lang_name text, definition text, - -- + + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', + CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, UNIQUE (database_id, name) 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 416ee699..cccf5d5e 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 @@ -2,6 +2,7 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/database/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -13,7 +14,16 @@ CREATE TABLE metaschema_public.schema ( schema_name text NOT NULL, label text, description text, - -- + + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', + + is_public boolean NOT NULL DEFAULT TRUE, CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE, @@ -21,9 +31,6 @@ CREATE TABLE metaschema_public.schema ( UNIQUE (schema_name) ); --- TODO: build out services --- COMMENT ON COLUMN metaschema_public.schema.schema_name IS '@omit'; - ALTER TABLE metaschema_public.schema ADD CONSTRAINT schema_namechk CHECK (char_length(name) > 2); 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 d0ada290..e5d8bfdf 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 @@ -2,11 +2,10 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/database/table -- requires: schemas/metaschema_public/tables/schema/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; -CREATE TYPE metaschema_public.table_category AS ENUM ('core', 'module', 'app'); - CREATE TABLE metaschema_public.table ( id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), database_id uuid NOT NULL DEFAULT uuid_nil(), @@ -20,7 +19,7 @@ CREATE TABLE metaschema_public.table ( smart_tags jsonb, - category metaschema_public.table_category NOT NULL DEFAULT 'app', + category metaschema_public.object_category NOT NULL DEFAULT 'app', module text NULL, scope int NULL, 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 5575ea2b..0258142a 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 @@ -2,20 +2,26 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/table/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; --- https://www.postgresql.org/docs/12/sql-createtrigger.html - CREATE TABLE metaschema_public.trigger ( id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (), database_id uuid NOT NULL DEFAULT uuid_nil(), table_id uuid NOT NULL, name text NOT NULL, - event text, -- INSERT, UPDATE, DELETE, or TRUNCATE + event text, function_name text, - -- + + smart_tags jsonb, + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, 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 d00f3ced..6497989b 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 @@ -3,6 +3,7 @@ -- requires: schemas/metaschema_public/schema -- requires: schemas/metaschema_public/tables/database/table -- requires: schemas/metaschema_public/tables/table/table +-- requires: schemas/metaschema_public/types/object_category BEGIN; @@ -16,14 +17,16 @@ CREATE TABLE metaschema_public.unique_constraint ( smart_tags jsonb, type text, field_ids uuid[] NOT NULL, - -- + + category metaschema_public.object_category NOT NULL DEFAULT 'app', + module text NULL, + scope int NULL, + + tags citext[] NOT NULL DEFAULT '{}', 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, - -- TODO these are unique across schema, NOT table. We'll need to update this to have database_id - -- for portability - UNIQUE (table_id, name), CHECK (field_ids <> '{}') ); diff --git a/packages/metaschema-schema/deploy/schemas/metaschema_public/types/object_category.sql b/packages/metaschema-schema/deploy/schemas/metaschema_public/types/object_category.sql new file mode 100644 index 00000000..ea77e21e --- /dev/null +++ b/packages/metaschema-schema/deploy/schemas/metaschema_public/types/object_category.sql @@ -0,0 +1,9 @@ +-- Deploy schemas/metaschema_public/types/object_category to pg + +-- requires: schemas/metaschema_public/schema + +BEGIN; + +CREATE TYPE metaschema_public.object_category AS ENUM ('core', 'module', 'app'); + +COMMIT; diff --git a/packages/metaschema-schema/pgpm.plan b/packages/metaschema-schema/pgpm.plan index 48cb4828..e0a761a1 100644 --- a/packages/metaschema-schema/pgpm.plan +++ b/packages/metaschema-schema/pgpm.plan @@ -4,26 +4,27 @@ schemas/metaschema_private/schema [pgpm-inflection:schemas/inflection/tables/inflection_rules/indexes/inflection_rules_type_idx pgpm-database-jobs:schemas/app_jobs/triggers/tg_add_job_with_row pgpm-types:schemas/public/domains/url] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_private/schema schemas/metaschema_public/schema 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/schema +schemas/metaschema_public/types/object_category [schemas/metaschema_public/schema] 2026-01-14T00:00:00Z devin # add schemas/metaschema_public/types/object_category schemas/metaschema_public/tables/database/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/database/table -schemas/metaschema_public/tables/schema/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/schema/table -schemas/metaschema_public/tables/table/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/schema/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/table/table -schemas/metaschema_public/tables/check_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/check_constraint/table +schemas/metaschema_public/tables/schema/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/schema/table +schemas/metaschema_public/tables/table/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/schema/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/table/table +schemas/metaschema_public/tables/check_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/check_constraint/table schemas/metaschema_public/tables/extension/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/extension/table schemas/metaschema_public/tables/database_extension/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/extension/table schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/database_extension/table schemas/metaschema_public/tables/database/indexes/databases_database_unique_name_idx [schemas/metaschema_private/schema schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/database/indexes/databases_database_unique_name_idx -schemas/metaschema_public/tables/field/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/field/table +schemas/metaschema_public/tables/field/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/field/table schemas/metaschema_public/tables/field/indexes/databases_field_uniq_names_idx [schemas/metaschema_public/schema schemas/metaschema_public/tables/field/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/field/indexes/databases_field_uniq_names_idx -schemas/metaschema_public/tables/foreign_key_constraint/table [schemas/metaschema_public/tables/field/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/foreign_key_constraint/table +schemas/metaschema_public/tables/foreign_key_constraint/table [schemas/metaschema_public/tables/field/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/schema schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/foreign_key_constraint/table schemas/metaschema_public/tables/full_text_search/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/full_text_search/table -schemas/metaschema_public/tables/index/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/index/table +schemas/metaschema_public/tables/index/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/tables/database/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/index/table schemas/metaschema_public/tables/limit_function/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/limit_function/table -schemas/metaschema_public/tables/policy/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/policy/table -schemas/metaschema_public/tables/primary_key_constraint/table [schemas/metaschema_public/schema] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/primary_key_constraint/table -schemas/metaschema_public/tables/procedure/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/procedure/table +schemas/metaschema_public/tables/policy/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/policy/table +schemas/metaschema_public/tables/primary_key_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/primary_key_constraint/table +schemas/metaschema_public/tables/procedure/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/procedure/table schemas/metaschema_public/tables/rls_function/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/rls_function/table schemas/metaschema_public/tables/schema_grant/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/schema/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/schema_grant/table schemas/metaschema_public/tables/table_grant/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/table_grant/table schemas/metaschema_public/tables/table/indexes/databases_table_unique_name_idx [schemas/metaschema_public/schema schemas/metaschema_private/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/table/indexes/databases_table_unique_name_idx schemas/metaschema_public/tables/trigger_function/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/trigger_function/table -schemas/metaschema_public/tables/trigger/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/trigger/table -schemas/metaschema_public/tables/unique_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/unique_constraint/table +schemas/metaschema_public/tables/trigger/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/table/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/trigger/table +schemas/metaschema_public/tables/unique_constraint/table [schemas/metaschema_public/schema schemas/metaschema_public/tables/database/table schemas/metaschema_public/tables/table/table schemas/metaschema_public/types/object_category] 2017-08-11T08:11:51Z skitch # add schemas/metaschema_public/tables/unique_constraint/table diff --git a/packages/metaschema-schema/revert/schemas/metaschema_public/types/object_category.sql b/packages/metaschema-schema/revert/schemas/metaschema_public/types/object_category.sql new file mode 100644 index 00000000..84ba74ed --- /dev/null +++ b/packages/metaschema-schema/revert/schemas/metaschema_public/types/object_category.sql @@ -0,0 +1,7 @@ +-- Revert schemas/metaschema_public/types/object_category from pg + +BEGIN; + +DROP TYPE IF EXISTS metaschema_public.object_category; + +COMMIT; diff --git a/packages/metaschema-schema/verify/schemas/metaschema_public/types/object_category.sql b/packages/metaschema-schema/verify/schemas/metaschema_public/types/object_category.sql new file mode 100644 index 00000000..9d5c82f5 --- /dev/null +++ b/packages/metaschema-schema/verify/schemas/metaschema_public/types/object_category.sql @@ -0,0 +1,7 @@ +-- Verify schemas/metaschema_public/types/object_category on pg + +BEGIN; + +SELECT 'core'::metaschema_public.object_category; + +ROLLBACK; From 86b1a53ce4a20f8e4155ea494b25c2d2693ad2cb Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 14 Jan 2026 00:48:55 +0000 Subject: [PATCH 2/4] test: update snapshots for new module tables Updated snapshots to include the 4 new module tables: - table_module - user_profiles_module - user_settings_module - organization_settings_module Also updated constraint counts to reflect the new foreign key relationships. --- .../__tests__/__snapshots__/modules.test.ts.snap | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap b/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap index 02f33501..4220a140 100644 --- a/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap +++ b/packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap @@ -16,13 +16,17 @@ exports[`db_meta_modules should have all expected module tables 1`] = ` "limits_module", "membership_types_module", "memberships_module", + "organization_settings_module", "permissions_module", "phone_numbers_module", "profiles_module", "rls_module", "secrets_module", + "table_module", "tokens_module", "user_auth_module", + "user_profiles_module", + "user_settings_module", "users_module", "uuid_module", ], @@ -31,8 +35,8 @@ exports[`db_meta_modules should have all expected module tables 1`] = ` exports[`db_meta_modules should verify all module tables exist in metaschema_modules_public schema 1`] = ` { - "moduleTablesCount": 22, - "totalTables": 23, + "moduleTablesCount": 26, + "totalTables": 27, } `; @@ -87,13 +91,13 @@ exports[`db_meta_modules should verify emails_module table structure 1`] = ` exports[`db_meta_modules should verify module table structures have database_id foreign keys 1`] = ` { - "constraintCount": 57222, + "constraintCount": 78650, } `; exports[`db_meta_modules should verify module tables have proper foreign key relationships 1`] = ` { - "constraintCount": 78690, + "constraintCount": 113921, "foreignTables": [ "apis", "database", From b9a9fb56e7c10943dd7f73b5fdd94b692c1f508d Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 14 Jan 2026 00:55:32 +0000 Subject: [PATCH 3/4] fix: remove field_category drop from field table revert script The field table now uses the shared object_category type instead of the inline field_category type, so the revert script should not try to drop field_category. --- .../revert/schemas/metaschema_public/tables/field/table.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/metaschema-schema/revert/schemas/metaschema_public/tables/field/table.sql b/packages/metaschema-schema/revert/schemas/metaschema_public/tables/field/table.sql index 1d2ad6c7..ee7d49d0 100644 --- a/packages/metaschema-schema/revert/schemas/metaschema_public/tables/field/table.sql +++ b/packages/metaschema-schema/revert/schemas/metaschema_public/tables/field/table.sql @@ -4,6 +4,5 @@ BEGIN; DROP INDEX metaschema_public.field_database_id_idx; DROP INDEX metaschema_public.field_table_id_idx; DROP TABLE metaschema_public.field; -DROP TYPE metaschema_public.field_category; COMMIT; From 183aa121fc5e43529c89c513400cde3f3da95e03 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 14 Jan 2026 01:13:04 +0000 Subject: [PATCH 4/4] refactor: remove default_is_approved/default_is_verified from memberships_module These columns are being removed in favor of a secure-by-default approach. --- .../tables/memberships_module/table.sql | 3 --- 1 file changed, 3 deletions(-) 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 0cac915f..3a869ec9 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 @@ -54,9 +54,6 @@ CREATE TABLE metaschema_modules_public.memberships_module ( entity_ids_by_perm text NULL, entity_ids_function text NULL, - default_is_approved boolean NOT NULL DEFAULT TRUE, - default_is_verified boolean NOT NULL DEFAULT TRUE, - -- CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,