nextcloud_ynh icon indicating copy to clipboard operation
nextcloud_ynh copied to clipboard

Migrate mysql db to utf8

Open kay0u opened this issue 3 years ago • 31 comments

Problem

  • Description of why you made this PR

Solution

  • Fix https://github.com/YunoHost-Apps/nextcloud_ynh/pull/384

PR Status

  • [ ] Code finished.
  • [ ] Tested with Package_check.
  • [ ] Fix or enhancement tested.
  • [ ] Upgrade from last version tested.
  • [ ] Can be reviewed and tested.

Validation


Minor decision

  • Upgrade previous version :
  • [ ] Code review :
  • [ ] Approval (LGTM) :
  • [ ] Approval (LGTM) :

Package_check results


  • An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*

kay0u avatar Feb 25 '21 11:02 kay0u

!testme

kay0u avatar Feb 25 '21 11:02 kay0u

:stuck_out_tongue_winking_eye: Test Badge

yunohost-bot avatar Feb 25 '21 11:02 yunohost-bot

While you're at it, I would suggest to change charset to utf8mb4 : utf8 is an alias for utf8mb3, which is the UTF-8 subset of characters that are at most 3 bytes long. utf8mb4, on the other side, cant represent any UTF-8 value.

edit: and many thanks for all the work done here :) .

Samuel-BF avatar Mar 08 '21 13:03 Samuel-BF

!testme

kay0u avatar Mar 08 '21 15:03 kay0u

Alrighty! Test Badge

yunohost-bot avatar Mar 08 '21 15:03 yunohost-bot

Thank you for pointing this out to me, let see if it works

kay0u avatar Mar 08 '21 15:03 kay0u

Hmm it doesn't work

kay0u avatar Mar 09 '21 15:03 kay0u

!testme

kay0u avatar Mar 11 '21 12:03 kay0u

:rocket: Test Badge

yunohost-bot avatar Mar 11 '21 12:03 yunohost-bot

!testme

kay0u avatar Mar 18 '21 10:03 kay0u

Alrighty! Test Badge

yunohost-bot avatar Mar 18 '21 10:03 yunohost-bot

!testme

kay0u avatar Mar 18 '21 13:03 kay0u

:rocket: Test Badge

yunohost-bot avatar Mar 18 '21 13:03 yunohost-bot

That will be nice when implemented. Thanks @kay0u

Thatoo avatar Aug 26 '21 22:08 Thatoo

Passing by following this discussion : https://github.com/YunoHost/yunohost/pull/1284#issuecomment-906758754

Basically our my.cnf is super old, modern debian conf has character-set-server = utf8mb4 but we ain't using it ... I'm quite tempted to look into implementing a DB general migration in Yunohost (for example during the buster->bullseye transition) - assuming it's "just" about running a ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

That would prevent nextcloud from having to implement super custom login about specifying the character set all over the place ... and apparently seafile needs this too.

alexAubin avatar Aug 26 '21 22:08 alexAubin

ofc, that'd be great!

kay0u avatar Aug 26 '21 23:08 kay0u

(By the way I was having a look into this for migrations in the core yesterday, turns out the ALTER DATABASE only changes the default charset for new tables but doesn't change any existing table ... Theres also a similar ALTER TABLE instruction which is only meaningful if the table content is already encoded with the appropriate charset and doesn't magically migrate the thing ... but afaik in the context of Nextcloud, exec_occ db:convert-mysql-charset does precisely all the re-encoding ? ... but in the general case there's no magic solution for any DB)

alexAubin avatar Oct 21 '21 15:10 alexAubin

I'm not sure to understand... @alexAubin Is it possible to migrate the database to utf8mb4? Will be done during migration do bullseyes?

Thatoo avatar Nov 07 '21 12:11 Thatoo

Hello,

Any news about that ? I might be running into issues because of that non-UT8 character set for another app (FreshRSS https://github.com/FreshRSS/FreshRSS/issues/4139) and I wonder if that's a change I need to do for all databases or if they are independents in some way.

Thanks in advance :)

lapineige avatar Jan 10 '22 21:01 lapineige

I think this PR will be obsolete after the Bullseye migration if I understood correctly.

kay0u avatar Jan 12 '22 09:01 kay0u

Eeeeh not exactly because the new config only affects newly create tables. For old one, one still has to convert the content of the table, which is not a trivial operation and is apparently app-specific (you can't just take any random SQL DB and convert it). This is why the exec_occ db:convert-mysql-charset exists and handles the reencoding.

alexAubin avatar Jan 12 '22 12:01 alexAubin

But in my experience for Nextcloud, this conversion is likely to fail. IDK what to do with that.

kay0u avatar Jan 12 '22 14:01 kay0u

!testme

kay0u avatar Jan 12 '22 14:01 kay0u

:rocket: Test Badge

yunohost-bot avatar Jan 12 '22 14:01 yunohost-bot

!testme

ericgaspar avatar Apr 11 '22 07:04 ericgaspar

:rocket: Test Badge

yunohost-bot avatar Apr 11 '22 07:04 yunohost-bot

Does that mean old yunohost nextcloud won't be able to migrate mysql to utf8?

Thatoo avatar Jul 03 '22 09:07 Thatoo

Looks like the official procedure has slightly changed in Nextcloud 22 (notably, rather use of maintenance:repair command instead of db:convert-mysql-charset). Maybe that migration could be more robust/reliable...?

JimboJoe avatar Jul 11 '22 13:07 JimboJoe

!testme

ericgaspar avatar Aug 06 '22 16:08 ericgaspar

Fingers crossed! Test Badge

yunohost-bot avatar Aug 06 '22 16:08 yunohost-bot