streams/Code/Update/_1243.php

46 lines
1 KiB
PHP
Raw Normal View History

2020-09-18 22:34:53 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Update;
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
class _1243
{
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
public function run()
{
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
q("START TRANSACTION");
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q("ALTER TABLE profile ADD pronouns text NOT NULL DEFAULT '' ");
$r2 = q("ALTER TABLE xprof ADD xprof_pronouns text NOT NULL DEFAULT '' ");
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
$r = ($r1 && $r2);
} else {
$r1 = q("ALTER TABLE `profile` ADD `pronouns` char(191) NOT NULL DEFAULT '' ");
$r2 = q("ALTER TABLE `xprof` ADD `xprof_pronouns` char(191) NOT NULL DEFAULT '' ");
$r = ($r1 && $r2);
}
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
}
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
q("ROLLBACK");
return UPDATE_FAILED;
}
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
public function verify()
{
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
$columns = db_columns('profile');
$columns2 = db_columns('xprof');
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
if (in_array('pronouns', $columns) && in_array('xprof_pronouns', $columns2)) {
return true;
}
2020-09-18 22:34:53 +00:00
2021-12-02 23:02:31 +00:00
return false;
}
2020-09-18 22:34:53 +00:00
}