pgsql automatically creates indexes on unique columns, so the manually created indexes on those columns are redundant on that database. This will remove tham.

This commit is contained in:
Matthew Barbour 2019-06-25 10:05:36 -05:00 committed by Shish
parent dfeb3bf5df
commit 8794258072

View file

@ -154,6 +154,10 @@ class Upgrade extends Extension
log_info("upgrade", "Changing filename column to VARCHAR(255)");
if ($database->get_driver_name() == DatabaseDriver::PGSQL) {
$database->execute('ALTER TABLE images ALTER COLUMN filename SET DATA TYPE VARCHAR(255)');
// Postgresql creates a unique index for unique columns, not just a constraint,
// so we don't need two indexes on the same column
$database->execute('DROP INDEX IF EXISTS images_hash_idx');
$database->execute('DROP INDEX IF EXISTS users_name_idx');
} elseif ($database->get_driver_name() == DatabaseDriver::MYSQL) {
$database->execute('ALTER TABLE images MODIFY COLUMN filename VARCHAR(255) NOT NULL');
}