Skip to content

enh/snowflake ids - #9186

Open
max-nextcloud wants to merge 8 commits into
refactor/introduce-icontextfrom
enh/snowflake-ids
Open

enh/snowflake ids#9186
max-nextcloud wants to merge 8 commits into
refactor/introduce-icontextfrom
enh/snowflake-ids

Conversation

@max-nextcloud

@max-nextcloud max-nextcloud commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

enh(document): use snowflake ids

Do not rely on autoincrement ids,
which require shuffling tables around in the migration
as some databases cannot change columns to autoincrement.

$document->id is now a string,
which conflicts with the definition in the Entity class.
Mute the psalm warning about this for now.

Proper solution will be to migrate to the new ORM.
https://carlschwan.eu/2026/08/18/modern-stable-apis-for-your-nextcloud-application/

Todo

  • AttachmentService::cleanupAttachments(int $fileId) is being called with the documentId from Cron/Cleanup:37
  • The change to auto-increment in the migration is still in place
  • ResetDocument - no file ids.
  • Front-end types are not migrated, they still advertize number

Signed-off-by: Max <max@nextcloud.com>
@max-nextcloud
max-nextcloud force-pushed the enh/snowflake-ids branch 2 times, most recently from 1569518 to c83be29 Compare September 8, 2026 07:03
@max-nextcloud
max-nextcloud requested a review from blizzz September 8, 2026 07:03
@max-nextcloud
max-nextcloud force-pushed the enh/snowflake-ids branch 5 times, most recently from 0723ece to 666af57 Compare September 8, 2026 11:49
@max-nextcloud
max-nextcloud marked this pull request as ready for review September 8, 2026 12:26
Do not rely on autoincrement ids,
which require shuffling tables around in the migration
as some databases cannot change columns to autoincrement.

`$document->id` is now a string,
which conflicts with the definition in the Entity class.
Mute the psalm warning about this for now.

Proper solution will be to migrate to the new ORM.
https://carlschwan.eu/2026/08/18/modern-stable-apis-for-your-nextcloud-application/

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>

@blizzz blizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. Claude found a few items:

  • AttachmentService::cleanupAttachments(int $fileId) is being called with the documentId from Cron/Cleanup:37
  • Front-end types are not migrated, they still advertize number
  • The change to auto-increment in the migration is still in place

Comment thread lib/Command/ResetDocument.php Outdated
It does not work on all database types.
Therefore we will use snowflake ids instead.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
@max-nextcloud
max-nextcloud requested a review from blizzz September 9, 2026 11:52
Signed-off-by: Max <max@nextcloud.com>
… fileId

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz

blizzz commented Sep 9, 2026

Copy link
Copy Markdown
Member

OK, i think my attempt was utter nonsense. But the issue should not really be dependent upon the snowflake ID, but the change in general, and the frontend passing a file id here 🤔

– after all, attachment resolver was left unticked in #9062 (comment), but the Controller changed, so I guess we have to make it work.

Max, feel free to drop my silly commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants