usememos / memos

An open-source, lightweight note-taking solution. The pain-less way to create your meaningful notes. Your Notes, Your Way.
https://usememos.com
MIT License
34.21k stars 2.48k forks source link

start failure 0.23.0.rc1 #4127

Open dream7180 opened 3 days ago

dream7180 commented 3 days ago

Describe the bug

Archlinux, start failure, either pre-built binary or self-complied binary. message: 2024/11/13 18:14:28 ERROR failed to migrate error="Error 1366 (22007): Incorrect string value: '\xF0\x9F\x91\x8D\",...' for column memos.system_setting.value at row 1\nfailed to execute statement\ngithub.com/usememos/memos/store.(Store).execute\n\t/home/runner/work/memos/memos/store/migrator.go:251\ngithub.com/usememos/memos/store.(Store).Migrate\n\t/home/runner/work/memos/memos/store/migrator.go:88\nmain.init.func1\n\t/home/runner/work/memos/memos/bin/memos/main.go:61\ngithub.com/spf13/cobra.(Command).execute\n\t/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:989\ngithub.com/spf13/cobra.(Command).ExecuteC\n\t/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117\ngithub.com/spf13/cobra.(Command).Execute\n\t/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041\nmain.main\n\t/home/runner/work/memos/memos/bin/memos/main.go:171\nruntime.main\n\t/opt/hostedtoolcache/go/1.23.3/x64/src/runtime/proc.go:272\nruntime.goexit\n\t/opt/hostedtoolcache/go/1.23.3/x64/src/runtime/asm_amd64.s:1700\nmigrate error: UPDATE reaction SET reaction_type = '👍' WHERE reaction_type = 'THUMBS_UP';\nUPDATE reaction SET reaction_type = '👎' WHERE reaction_type = 'THUMBS_DOWN';\nUPDATE reaction SET reaction_type = '💛' WHERE reaction_type = 'HEART';\nUPDATE reaction SET reaction_type = '🔥' WHERE reaction_type = 'FIRE';\nUPDATE reaction SET reaction_type = '👏' WHERE reaction_type = 'CLAPPING_HANDS';\nUPDATE reaction SET reaction_type = '😂' WHERE reaction_type = 'LAUGH';\nUPDATE reaction SET reaction_type = '👌' WHERE reaction_type = 'OK_HAND';\nUPDATE reaction SET reaction_type = '🚀' WHERE reaction_type = 'ROCKET';\nUPDATE reaction SET reaction_type = '👀' WHERE reaction_type = 'EYES';\nUPDATE reaction SET reaction_type = '🤔' WHERE reaction_type = 'THINKING_FACE';\nUPDATE reaction SET reaction_type = '🤡' WHERE reaction_type = 'CLOWN_FACE';\nUPDATE reaction SET reaction_type = '❓' WHERE reaction_type = 'QUESTION_MARK';\n\nINSERT INTO system_setting (name, value, description)\nVALUES (\n 'MEMO_RELATED',\n '{\"contentLengthLimit\":8192,\"reactions\":[\"👍\",\"👎\",\"💛\",\"🔥\",\"👏\",\"😂\",\"👌\",\"🚀\",\"👀\",\"🤔\",\"🤡\",\"❓\"]}',\n ''\n)\nON DUPLICATE KEY UPDATE\nvalue = \n JSON_SET(\n value, \n '$.reactions', \n JSON_ARRAY('👍', '👎', '💛', '🔥', '👏', '😂', '👌', '🚀', '👀', '🤔', '🤡', '❓')\n );\n\ngithub.com/usememos/memos/store.(Store).Migrate\n\t/home/runner/work/memos/memos/store/migrator.go:89\nmain.init.func1\n\t/home/runner/work/memos/memos/bin/memos/main.go:61\ngithub.com/spf13/cobra.(Command).execute\n\t/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:989\ngithub.com/spf13/cobra.(Command).ExecuteC\n\t/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117\ngithub.com/spf13/cobra.(*Command).Execute\n\t/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041\nmain.main\n\t/home/runner/work/memos/memos/bin/memos/main.go:171\nruntime.main\n\t/opt/hostedtoolcache/go/1.23.3/x64/src/runtime/proc.go:272\nruntime.goexit\n\t/opt/hostedtoolcache/go/1.23.3/x64/src/runtime/asm_amd64.s:1700"

Steps to reproduce

start memos as service.

The version of Memos you're using.

v0.23.0-rc.1

Screenshots or additional context

0.22.5 runs OK

johnnyjoygh commented 2 days ago

It looks like we already handle the empty reactions setting https://github.com/usememos/memos/commit/378b6a51c136f41e5df93453423b4d8c9855a666, so we can just remove the related migration scripts. @boojack

RoccoSmit commented 2 days ago

@dream7180, what db are you using? Is it MySQL?

dream7180 commented 2 days ago

yes. Mariadb (mysql)

RoccoSmit commented 1 day ago

What charset are you running on your db? You can find out by running the following script

SELECT @@character_set_database, @@collation_database

I believe you need to use utf8mb4 to allow for emoji chars

dream7180 commented 1 day ago

CHARACTER SET utf8 COLLATE utf8_general_ci

I have to convert charset to utf8mb4?

RoccoSmit commented 1 day ago

We can set the charset just for the required columns so that it doesn't matter what charset users chose when they created their db

If you cant wait for the code update, you can change the charset of your db instance, but please back up your db first just in case

RoccoSmit commented 1 day ago

PR submitted https://github.com/usememos/memos/pull/4131