2020-11-19 04:09:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zotlabs\Update;
|
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
class _1244
|
|
|
|
{
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
public function run()
|
|
|
|
{
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
q("START TRANSACTION");
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
|
|
|
|
$r1 = q("ALTER TABLE xchan ADD xchan_created timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' ");
|
|
|
|
$r2 = q("create index \"xchan_created_idx\" on xchan (\"xchan_created\")");
|
|
|
|
|
|
|
|
$r = ($r1 && $r2);
|
|
|
|
} else {
|
|
|
|
$r = q("ALTER TABLE `xchan` ADD `xchan_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' ,
|
2020-11-19 04:09:05 +00:00
|
|
|
ADD INDEX `xchan_created` (`xchan_created`)");
|
2021-12-02 23:02:31 +00:00
|
|
|
}
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
if ($r) {
|
|
|
|
q("COMMIT");
|
|
|
|
return UPDATE_SUCCESS;
|
|
|
|
}
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
q("ROLLBACK");
|
|
|
|
return UPDATE_FAILED;
|
|
|
|
}
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
public function verify()
|
|
|
|
{
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
$columns = db_columns('xchan');
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
if (in_array('xchan_created', $columns)) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-19 04:09:05 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-11-19 04:09:05 +00:00
|
|
|
}
|