fix: migration for mariadb

This commit is contained in:
Ferdinand Mütsch
2025-10-05 23:37:05 +02:00
parent 068223839c
commit c952184324
2 changed files with 9 additions and 4 deletions

View File

@@ -15,10 +15,12 @@ func init() {
return nil
}
const q = "with t1 as " +
"(select id, row_number() over(partition by email order by id) as row_num from users where email is not null) " +
"update users set email = null " +
"where users.id in (select id from t1 where row_num > 1)"
// til: https://chat.mistral.ai/chat/86e338b7-dad7-4478-8950-11efbf94aa4d
const q = "update users " +
"set email = null " +
"where users.id in " +
"(select id from (select id, row_number() over (partition by email order by id) as row_num from users where email is not null) as t1 " +
"where row_num > 1);"
if err := db.Exec(q).Error; err != nil {
return err

View File

@@ -0,0 +1,3 @@
#!/bin/bash
docker run -d -p 3306:3306 -e MARIADB_ROOT_PASSWORD=secretpassword -e MARIADB_DATABASE=wakapi_local -e MARIADB_USER=wakapi_user -e MARIADB_PASSWORD=wakapi --name wakapi-mariadb mariadb:latest