streams/Code/Update/_1232.php

32 lines
700 B
PHP
Raw Normal View History

2019-04-16 06:03:16 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Update;
2019-04-16 06:03:16 +00:00
2021-12-02 23:02:31 +00:00
class _1232
{
2019-04-16 06:03:16 +00:00
2021-12-02 23:02:31 +00:00
public function run()
{
2019-04-16 06:03:16 +00:00
2021-12-02 23:02:31 +00:00
q("START TRANSACTION");
2019-04-16 06:03:16 +00:00
2021-12-02 23:02:31 +00:00
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q("ALTER TABLE photo ADD expires timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' ");
$r2 = q("create index \"photo_expires_idx\" on photo (\"expires\")");
$r = ($r1 && $r2);
} else {
$r = q("ALTER TABLE `photo` ADD `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' ,
2019-04-16 06:03:16 +00:00
ADD INDEX `expires` (`expires`)");
2021-12-02 23:02:31 +00:00
}
2019-04-16 06:03:16 +00:00
2021-12-02 23:02:31 +00:00
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
}
2019-04-16 06:03:16 +00:00
2021-12-02 23:02:31 +00:00
q("ROLLBACK");
return UPDATE_FAILED;
}
2019-04-16 06:03:16 +00:00
}