-
Notifications
You must be signed in to change notification settings - Fork 0
feat: upstream constructive-db changes to pgpm-modules #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pyramation
merged 3 commits into
main
from
devin/1775106651-upstream-constructive-db-changes
Apr 2, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...-modules/deploy/schemas/metaschema_modules_public/tables/blueprint_construction/table.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| -- Deploy schemas/metaschema_modules_public/tables/blueprint_construction/table to pg | ||
|
|
||
| -- requires: schemas/metaschema_modules_public/schema | ||
| -- requires: schemas/metaschema_modules_public/tables/blueprint/table | ||
|
|
||
| BEGIN; | ||
|
|
||
| CREATE TABLE metaschema_modules_public.blueprint_construction ( | ||
| id uuid PRIMARY KEY DEFAULT uuidv7(), | ||
|
|
||
| -- What was constructed | ||
| blueprint_id uuid NOT NULL, | ||
|
|
||
| database_id uuid NOT NULL, | ||
|
|
||
| -- The schema used as the default for tables without an explicit schema_name | ||
| schema_id uuid, | ||
|
|
||
| -- Execution state | ||
| status text NOT NULL DEFAULT 'pending' | ||
| CHECK (status IN ('pending', 'constructing', 'constructed', 'failed')), | ||
|
|
||
| error_details text, | ||
|
|
||
| -- Output: mapping of table names to created table IDs (populated after construct) | ||
| table_map jsonb NOT NULL DEFAULT '{}', | ||
|
|
||
| -- Snapshot of the definition at construct-time (immutable record of what was actually executed) | ||
| constructed_definition jsonb, | ||
|
|
||
| constructed_at timestamptz, | ||
|
|
||
| created_at timestamptz NOT NULL DEFAULT now(), | ||
|
|
||
| updated_at timestamptz NOT NULL DEFAULT now(), | ||
|
|
||
| CONSTRAINT blueprint_construction_blueprint_fkey | ||
| FOREIGN KEY (blueprint_id) REFERENCES metaschema_modules_public.blueprint(id) ON DELETE CASCADE, | ||
| CONSTRAINT blueprint_construction_db_fkey | ||
| FOREIGN KEY (database_id) REFERENCES metaschema_public.database(id) ON DELETE CASCADE | ||
| ); | ||
|
|
||
| COMMENT ON TABLE metaschema_modules_public.blueprint_construction IS | ||
| 'Tracks individual construction attempts of a blueprint. Each time construct_blueprint() is called, a new record is created here. This separates the editable blueprint definition from its build history, allowing blueprints to be re-executed, constructed into multiple databases, and maintain an audit trail of all construction attempts.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.id IS | ||
| 'Unique identifier for this construction attempt.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.blueprint_id IS | ||
| 'The blueprint that was constructed.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.database_id IS | ||
| 'The database the blueprint was constructed into.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.schema_id IS | ||
| 'The default schema used for tables that did not specify an explicit schema_name. NULL if not yet resolved.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.status IS | ||
| 'Execution state of this construction attempt. pending: created but not yet started. constructing: currently executing. constructed: successfully completed. failed: execution failed (see error_details).'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.error_details IS | ||
| 'Error message from a failed construction attempt. NULL unless status is failed.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.table_map IS | ||
| 'Mapping of table names to created table UUIDs, populated after successful construction. Format: {"products": "uuid", "categories": "uuid", ...}. Defaults to empty object.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.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 blueprint definition.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.constructed_at IS | ||
| 'Timestamp when construction successfully completed. NULL until constructed.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.created_at IS | ||
| 'Timestamp when this construction attempt was created.'; | ||
|
|
||
| COMMENT ON COLUMN metaschema_modules_public.blueprint_construction.updated_at IS | ||
| 'Timestamp when this construction attempt was last modified.'; | ||
|
|
||
|
|
||
| CREATE INDEX blueprint_construction_blueprint_id_idx ON metaschema_modules_public.blueprint_construction (blueprint_id); | ||
| CREATE INDEX blueprint_construction_database_id_idx ON metaschema_modules_public.blueprint_construction (database_id); | ||
| CREATE INDEX blueprint_construction_status_idx ON metaschema_modules_public.blueprint_construction (status); | ||
|
|
||
| COMMIT; |
39 changes: 0 additions & 39 deletions
39
...metaschema-modules/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Redundant unreachable
(database)s$plural guard after catch-all(.+base)s$The plural guard
('plural', '(database)s$', NULL)on line 17 is unreachable because the immediately preceding rule('plural', '(.+base)s$', NULL)on line 16 already matches "databases" (since.+basematches "database"). The inflection engine (packages/inflection/deploy/schemas/inflection/procedures/plural.sql:20-31) processes rules in insertion order and returns on the first match, so the(database)s$guard will never execute. This is dead code that could mislead future maintainers into thinking it's meaningful.Was this helpful? React with 👍 or 👎 to provide feedback.