Moving migrations and scripts

This commit is contained in:
gamonoid
2017-09-04 06:59:14 +02:00
parent 737b392d0a
commit ed36ae0672
15 changed files with 58 additions and 97 deletions

5
migrations/list.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
$migrationList = [];
$migrationList[] = 'v20170702_190500_add_attendance_image';
$migrationList[] = 'v20170310_190401_add_timesheet_changes';
$migrationList[] = 'v20161116_190001_unique_index_cron_name';

View File

@@ -0,0 +1,25 @@
<?php
namespace Classes\Migration;
class v20161116_190001_unique_index_cron_name extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
Alter table Crons add unique key `KEY_Crons_name` (`name`);
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
Alter table Crons drop key `KEY_Crons_name`;
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Classes\Migration;
use Model\Setting;
class v20170310_190401_add_timesheet_changes extends AbstractMigration{
public function up(){
$setting = new Setting();
$setting->Load("name = ?", array('System: Time-sheet Entry Start and End time Required'));
if(empty($setting->id)){
$setting->name = 'System: Time-sheet Entry Start and End time Required';
$setting->value = 1;
$setting->description = 'Select 0 if you only need to store the time spend in time sheets';
$setting->meta = '["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]';
$setting->Save();
}
}
public function down(){
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Classes\Migration;
class v20170702_190500_add_attendance_image extends AbstractMigration{
public function up(){
$setting = new Setting();
$setting->Load("name = ?", array('Attendance: Photo Attendance'));
if(empty($setting->id)){
$setting->name = 'Attendance: Photo Attendance';
$setting->value = 0;
$setting->description = 'Require submitting a photo using web cam when marking attendance';
$setting->meta = '["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]';
$setting->Save();
}
$sql = <<<'SQL'
Alter table Attendance add column `image_in` longtext default null;
SQL;
return $this->executeQuery($sql);
$sql = <<<'SQL'
Alter table Attendance add column `image_out` longtext default null;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
Alter table Attendance drop column `image_in`;
SQL;
return $this->executeQuery($sql);
$sql = <<<'SQL'
Alter table Attendance drop column `image_out`;
SQL;
return $this->executeQuery($sql);
}
}