Skip to content

Commit 2e0ed26

Browse files
abnegateclaude
andcommitted
fix(sqlite): keep perms UNIQUE narrow under shared tables
A composite (_document, _type, _permission, _tenant) constraint matches MariaDB's shape but trips the upsert path that re-inserts permissions without re-reading the existing rows. Revert to the existing (_document, _type, _permission) constraint until the shared-tables permission diff is sorted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e7416c2 commit 2e0ed26

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Database/Adapter/SQLite.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,12 @@ public function createCollection(string $name, array $attributes = [], array $in
219219
$this->createIndex($id, '_created_at', Database::INDEX_KEY, [ '_createdAt'], [], []);
220220
$this->createIndex($id, '_updated_at', Database::INDEX_KEY, [ '_updatedAt'], [], []);
221221

222-
$permsColumns = $this->sharedTables
223-
? ['_document', '_type', '_permission', '_tenant']
224-
: ['_document', '_type', '_permission'];
225-
$this->createIndex("{$id}_perms", '_index_1', Database::INDEX_UNIQUE, $permsColumns, [], []);
222+
// Permissions UNIQUE stays on (_document, _type, _permission)
223+
// for now even under shared tables: composite unique with
224+
// _tenant trips upsert flows that re-insert permissions
225+
// without first re-loading the existing rows. Revisit once
226+
// the upsert permission diff is hardened.
227+
$this->createIndex("{$id}_perms", '_index_1', Database::INDEX_UNIQUE, ['_document', '_type', '_permission'], [], []);
226228
$this->createIndex("{$id}_perms", '_index_2', Database::INDEX_KEY, ['_permission', '_type'], [], []);
227229

228230
if ($this->sharedTables) {

0 commit comments

Comments
 (0)