forked from Cavemanon/cavepaintings
pm also used char for postgres
This commit is contained in:
@@ -356,7 +356,7 @@ class Database
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
public function standardise_boolean(string $table, string $column): void
|
||||
public function standardise_boolean(string $table, string $column, boolean $include_postgres=false): void
|
||||
{
|
||||
$d = $this->get_driver_name();
|
||||
if ($d == DatabaseDriver::MYSQL) {
|
||||
@@ -373,5 +373,11 @@ class Database
|
||||
# text, so we can in-place replace a char with a bool
|
||||
$this->execute("UPDATE $table SET $column = ($column IN ('Y', 1))");
|
||||
}
|
||||
if ($d == DatabaseDriver::PGSQL) {
|
||||
$this->execute("ALTER TABLE $table ADD COLUMN ${column}_b BOOLEAN DEFAULT FALSE NOT NULL");
|
||||
$this->execute("UPDATE $table SET ${column}_b = ($column = 'Y')");
|
||||
$this->execute("ALTER TABLE $table DROP COLUMN $column");
|
||||
$this->execute("ALTER TABLE $table RENAME COLUMN ${column}_b TO $column");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user