feat: add membership_type column to storage_module for multi-scope storage#58
Merged
pyramation merged 1 commit intomainfrom Apr 19, 2026
Merged
Conversation
…orage - Add membership_type int column (NULL = app-level AuthzMembership, non-NULL = entity-scoped AuthzEntityMembership) - Rename default table names from buckets/files/upload_requests to app_buckets/app_files/app_upload_requests - Add unique index on (database_id, COALESCE(membership_type, -1)) to enforce one module per scope - Update entity_table_id comment to reflect app-level vs entity-scoped usage Syncs with constructive-db PR #876 (merged).
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Updates the
storage_moduletable schema to support multi-scope (multi-tenant) storage. This syncs the publishedmetaschema-modulespackage with the schema changes already merged inconstructive-db(PR #876).Changes to
storage_module/table.sql:New column
membership_type int DEFAULT NULL— discriminates storage scope:NULL= app-level storage (gated byAuthzMembershipviaapp_sprt)AuthzEntityMembership, value matches the entity's membership type)Renamed default table names —
buckets/files/upload_requests→app_buckets/app_files/app_upload_requeststo clearly identify database-level (app-scope) storage tables vs entity-scoped ones.New unique index
storage_module_unique_scopeon(database_id, COALESCE(membership_type, -1))— enforces at most one storage module per scope per database (one app-level + one per membership type).Why:
constructivePR #1009 adds multi-scope bucket resolution to the GraphQL plugins, which queriesstorage_module.membership_type. CI fails because the published package doesn't have this column yet. Publishing this update unblocks that PR.Review & Testing Checklist for Human
constructive-db/pgpm-modules/metaschema-modules/deploy/.../storage_module/table.sqlonmainto confirm no drift'buckets'/'files'/'upload_requests'to'app_buckets'/'app_files'/'app_upload_requests'affects all newly provisioned databasesCOALESCE(membership_type, -1)to treat NULL as a distinct value; confirm-1will never be a validmembership_typeNotes
verify_table()still works since the table name hasn't changed, and revert is aDROP TABLE.CREATE TABLEdeploy script, not anALTER TABLEmigration. Existing databases will need a separate migration to add the column and index.Link to Devin session: https://app.devin.ai/sessions/18879be982854a40abe5c9b915aa4a84
Requested by: @pyramation