Fix some migrations, add new ones to keep track of migration number
parent
8b7f0ace3a
commit
0df87dde57
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
abstract class AbstractUpdatableMigration extends AbstractMigration {
|
||||
private $migrationNumber;
|
||||
|
||||
function __construct($migrationNumber) {
|
||||
$this->migrationNumber = $migrationNumber;
|
||||
}
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->innerUp($hesk_settings);
|
||||
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = " . intval($this->migrationNumber) . "
|
||||
WHERE `Key` = 'migrationNumber'");
|
||||
}
|
||||
|
||||
abstract function innerUp($hesk_settings);
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->innerDown($hesk_settings);
|
||||
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = " . (intval($this->migrationNumber) - 1) . "
|
||||
WHERE `Key` = 'migrationNumber'");
|
||||
}
|
||||
|
||||
abstract function innerDown($hesk_settings);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class LegacyUpdateMigration extends AbstractMigration {
|
||||
private $upVersion;
|
||||
private $downVersion;
|
||||
|
||||
public function __construct($upVersion, $downVersion) {
|
||||
$this->upVersion = $upVersion;
|
||||
$this->downVersion = $downVersion;
|
||||
}
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion($this->upVersion, $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion($this->downVersion, $hesk_settings);
|
||||
}
|
||||
}
|
@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
class UpdateMigration extends AbstractMigration {
|
||||
class UpdateMigration extends AbstractUpdatableMigration {
|
||||
private $upVersion;
|
||||
private $downVersion;
|
||||
|
||||
public function __construct($upVersion, $downVersion) {
|
||||
public function __construct($upVersion, $downVersion, $migrationNumber) {
|
||||
parent::__construct($migrationNumber);
|
||||
|
||||
$this->upVersion = $upVersion;
|
||||
$this->downVersion = $downVersion;
|
||||
}
|
||||
|
||||
function up($hesk_settings) {
|
||||
function innerUp($hesk_settings) {
|
||||
$this->updateVersion($this->upVersion, $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
function innerDown($hesk_settings) {
|
||||
$this->updateVersion($this->downVersion, $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace v320;
|
||||
|
||||
|
||||
class AddMigrationSetting extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`)
|
||||
VALUES ('migrationNumber', '94')");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'migrationNumber'");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue