feat(database): add Compatible indexes for Mongo and SQL dialects - #1613
Draft
ChrisPdgn wants to merge 2 commits into
Draft
feat(database): add Compatible indexes for Mongo and SQL dialects#1613ChrisPdgn wants to merge 2 commits into
ChrisPdgn wants to merge 2 commits into
Conversation
Make schema indexes first-class on Mongo, PostgreSQL, MySQL, MariaDB, and SQLite. Platform models use Compatible Ascending/Descending so the same declarations create live indexes on every dialect. Admin create/get/delete/import/export persist into _DeclaredSchema without a full schema rebuild.
Repair the ModelOptionsIndexTypes union that failed tsc, stop stuffing Sequelize field objects into Conduit index types, and move the index suites into src/__tests__/indexes.
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.
Description
Rewrite of the approved #643 index work from current
origin/main(not a cherry-pick/rebase of the staleindexesbranch).Schema indexes are now first-class on MongoDB, PostgreSQL, MySQL, MariaDB, and SQLite. Platform models (authorization + chat) declare
CompatibleIndexTypeAscending/Descending so the same indexes exist on SQL too (kkopanidis CHANGES_REQUESTED on #643).What this does
CompatibleIndexType(Ascending/Descending) plus optionalunique. Maps to Mongo1/-1and SQLBTREE ASC/DESC._DeclaredSchemavia metadata update. No full schema rebuild/sync()for index create/delete.getIndexesuses the live engine as source of truth and overlays declared types (hybrid).nameis optional; a deterministic name is generated when missing (platform schemas no longer require a name).originalSchema.collectionNameeverywhere (no hardcodedcnd_prefix).skip/limit). Same-name indexes are skipped on import.validateModelOptionsacceptsindexesand still allowsconduit.readPreference.dropIndexis awaited (no fire-and-forget).Intentionally not changed / not ported
getDatabaseType()still returns'PostgreSQL'(no'postgres'rename).ActorIndex/ObjectIndexdocuments — only their schema index declarations changed to Compatible.case 'mysql' || 'mariadb', metadata-onlygetIndexes,createSchemaFromAdapterrebuild for indexes, unbounded export, required index names, import always treating unique as database-owned, ReverseMongoIndexTypeMap display-name round-trip.Fixes #643 (implementation rewrite; this PR does not close or merge #643 by itself).
Type of change
How Has This Been Tested?
Unit tests covering T1–T42 plus existing SchemaAdmin PUT/PATCH tests:
Result: 9 suites, 54 passed.
Live-engine integration tests were not run in this environment (no Mongo/SQL). Recommended follow-up: smoke create/get/delete/import/export of a Compatible unique + descending compound index on Mongo, PostgreSQL, MySQL/MariaDB, and SQLite.
Test Configuration:
@conduitplatform/database,@conduitplatform/grpc-sdkChecklist:
Remaining risks
showIndexrow shapes differ by SQL dialect; unusual engine-specific indexes may normalize oddly.DESCuses Sequelize{ name, order }field objects — worth a live MySQL/MariaDB/SQLite check.modelOptions.indexes; they do not recreate indexes oninstanceSync.