-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
TASK: Add migration for workspaceName constraints #5202
Conversation
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.
+1 by reading. Thanks a lot for cleaning after me 🫣
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.
Migration was not necessary.
as desired :)
Hä but no,
i dont understand? It didnt work after all? |
🤔 The migration just handles to long workspaceNames |
Wait what is the problem with that? uppercase? |
Yes, the new constraint only allows lowercase.
|
jup bastis change only allows lowercase workspace names... i guess |
I'd go for lowercase everything. |
🙈 Also, it's not allowed to start with a number anymore ... and the md5 hash could be a number. |
Wait.... but the regex in the migration should find your |
$statement = <<<SQL | ||
UPDATE {$eventTableName} | ||
SET | ||
payload = JSON_SET(payload, '$.workspaceName', SUBSTR(MD5(JSON_UNQUOTE(JSON_EXTRACT(payload, '$.workspaceName'))), 1, 30)) |
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.
I read through this more in-depth now and I wonder why you used SUBSTR(..., 1, ...)
– if the original value was uppercase it would still be invalid afterwards.
My original suggestion was:
CONCAT('w', MD5(JSON_UNQUOTE(JSON_EXTRACT(payload, '$.workspaceName')))))
(note the "w"-prefix)
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.
The md5 hash is 32 chars long, but the workspaceName can just be 30 chars long. So I had to shorten it. To reduce the chance of collision, I removed the prefix to be able to keep 30 chars of the hash instead of 29.
But yeah...
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.
Ah, right, sorry
LEFT(CONCAT('w', MD5(JSON_UNQUOTE(JSON_EXTRACT(payload, '$.workspaceName'))))), 30)
could work
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.
Ah, I hadn't realized: SUBSTR(..., 1, x)
is the same as LEFT(..., x)
(since it's not zero-based like in PHP).
Still, the first character of an MD5 could be a digit
Bääähhh... what about "baseWorkspaceName"? This also needs to be migrated, right? @bwaidelich And after the migration a projection replay is needed for workspace projection. |
This migration rewrites all events containing a workspaceName, which doesn't match the new workspaceName constraints and rewrites them with (shortend) a md5 hash of themself.
Run the migration with:
If the migration found some workspaceNames or baseWorkspaceNames to migrate, please run a projection replay of the workspace projection.
This sould just be neccesary if you update your Neos 9 from <= beta10 to a newer version.
Fixes #5201