streams/Code/Update/_1248.php

44 lines
861 B
PHP
Raw Normal View History

2021-04-11 06:39:04 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Update;
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
class _1248
{
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
public function run()
{
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
q("START TRANSACTION");
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q("ALTER TABLE atoken ADD atoken_guid NOT NULL DEFAULT '' ");
$r2 = q("create index \"atoken_guid\" on xchan (\"atoken_guid\")");
$r = ($r1 && $r2);
} else {
$r = q("ALTER TABLE `atoken` ADD `atoken_guid` char(191) NOT NULL DEFAULT '' ,
2021-04-11 06:39:04 +00:00
ADD INDEX `atoken_guid` (`atoken_guid`)");
2021-12-02 23:02:31 +00:00
}
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
}
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
q("ROLLBACK");
return UPDATE_FAILED;
}
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
public function verify()
{
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
$columns = db_columns('atoken');
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
if (in_array('atoken_guid', $columns)) {
return true;
}
2021-04-11 06:39:04 +00:00
2021-12-02 23:02:31 +00:00
return false;
}
2021-04-11 06:39:04 +00:00
}