Overview
Comment: | Make sure we disable foreign keys when replacing table |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable | 1.1.19 |
Files: | files | file ages | folders |
SHA3-256: |
a6914f978c50e41bc212a587348e5221 |
User & Date: | bohwaz on 2022-01-12 01:46:50 |
Other Links: | manifest | tags |
Context
2022-01-12
| ||
02:22 | Quote columns names check-in: 2f9c90a19d user: bohwaz tags: trunk, stable, 1.1.19 | |
01:46 | Make sure we disable foreign keys when replacing table check-in: a6914f978c user: bohwaz tags: trunk, stable, 1.1.19 | |
00:14 | Switch to U_NOCASE collation check-in: 7e45abbf2c user: bohwaz tags: trunk, stable, 1.1.19 | |
Changes
Modified src/include/lib/Garradin/Upgrade.php from [35a588e215] to [3d4aa3a2f8].
︙ | ︙ | |||
372 373 374 375 376 377 378 | $db->import(ROOT . '/include/data/1.1.15_migration.sql'); $db->commit(); } if (version_compare($v, '1.1.19', '<')) { // Some people were able to insert invalid charsets in the database, this messes up the indexes // Let's try to fix that | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | $db->import(ROOT . '/include/data/1.1.15_migration.sql'); $db->commit(); } if (version_compare($v, '1.1.19', '<')) { // Some people were able to insert invalid charsets in the database, this messes up the indexes // Let's try to fix that $db->beginSchemaUpdate(); $db->createFunction('utf8_encode', [Utils::class, 'utf8_encode']); $db->exec('END; VACUUM; BEGIN;'); // This will rebuild the index correctly, fixing the corrupted DB // Now let's fix the content itself $res = $db->first('SELECT * FROM membres WHERE 1;'); $columns = array_keys((array) $res); $columns = array_map(fn($c) => sprintf('%s = utf8_encode(%1$s)', $c), $columns); $db->exec(sprintf('UPDATE membres SET %s;', implode(', ', $columns))); // Let's re-create users table with the correct index $champs = Config::getInstance()->champs_membres; $db->exec('ALTER TABLE membres RENAME TO membres_old;'); $champs->create('membres'); $champs->copy('membres_old', 'membres'); $db->exec('DROP TABLE membres_old;'); $db->commitSchemaUpdate(); } // Vérification de la cohérence des clés étrangères $db->foreignKeyCheck(); // Delete local cached files Utils::resetCache(USER_TEMPLATES_CACHE_ROOT); |
︙ | ︙ |