Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/metaschema-schema/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
EXTENSION = metaschema-schema
DATA = sql/metaschema-schema--0.15.5.sql
DATA = sql/metaschema-schema--0.31.0.sql

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ CREATE TABLE metaschema_public.database (

hash uuid,

-- Singleton flag marking the platform (constructive) database itself.
-- Write-once: first row to set it wins; immutable once true.
platform boolean NOT NULL DEFAULT false,

created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now(),

Expand All @@ -23,6 +27,10 @@ CREATE TABLE metaschema_public.database (
ALTER TABLE metaschema_public.database
ADD CONSTRAINT db_namechk CHECK (char_length(name) > 2);

CREATE UNIQUE INDEX databases_database_platform_singleton_idx
ON metaschema_public.database (platform)
WHERE platform;

COMMENT ON COLUMN metaschema_public.database.schema_hash IS '@omit';

COMMIT;
2 changes: 1 addition & 1 deletion packages/metaschema-schema/metaschema-schema.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# metaschema-schema extension
comment = 'metaschema-schema extension'
default_version = '0.15.5'
default_version = '0.31.0'
module_pathname = '$libdir/metaschema-schema'
requires = 'citext,hstore,pgpm-inflection,pgpm-database-jobs,pgpm-types,pgcrypto,plpgsql,postgis,uuid-ossp,pgpm-verify'
relocatable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ CREATE TABLE metaschema_public.database (
name text,
label text,
hash uuid,
platform boolean NOT NULL DEFAULT false,
created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now(),
UNIQUE (schema_hash)
Expand All @@ -45,6 +46,8 @@ ALTER TABLE metaschema_public.database
ADD CONSTRAINT db_namechk
CHECK (char_length(name) > 2);

CREATE UNIQUE INDEX databases_database_platform_singleton_idx ON metaschema_public.database (platform) WHERE platform;

COMMENT ON COLUMN metaschema_public.database.schema_hash IS '@omit';

CREATE TABLE metaschema_public.schema (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
BEGIN;

SELECT verify_table ('metaschema_public.database');
SELECT verify_index ('metaschema_public.database', 'databases_database_platform_singleton_idx');

ROLLBACK;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports[`services functionality should handle complete meta workflow with servic
"label": null,
"name": "my-meta-db",
"owner_id": "[ID]",
"platform": false,
"schema_hash": null,
"updated_at": "[DATE]",
}
Expand Down
Loading