PluginProbe
ShiftController Employee Shift Scheduling / trunk
ShiftController Employee Shift Scheduling vtrunk
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / shifttypes / migration.php

migration.php in ShiftController Employee Shift Scheduling trunk, at sh4/shifttypes/migration.php

69 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class SH4_ShiftTypes_Migration
3 {
4 public $dbForge;
5 public $migrationService;
6
7 public function __construct(
8 HC3_Hooks $hooks,
9 HC3_MigrationService $migrationService,
10 ?HC3_Database_DbForge $dbForge = NULL
11 )
12 {
13 $this->dbForge = $dbForge;
14 $this->migrationService = $migrationService;
15 }
16
17 public function up()
18 {
19 $currentVersion = $this->migrationService->getVersion( 'shifttypes' );
20
21 if( $currentVersion < 1 ){
22 $this->version1();
23 $this->migrationService->saveVersion( 'shifttypes', 1 );
24 }
25 }
26
27 public function version1()
28 {
29 if( $this->dbForge ){
30 $this->dbForge->add_field(
31 array(
32 'id' => array(
33 'type' => 'INT',
34 'null' => FALSE,
35 'unsigned' => TRUE,
36 'auto_increment' => TRUE
37 ),
38 'title' => array(
39 'type' => 'VARCHAR(255)',
40 'null' => FALSE,
41 ),
42 'starts_at' => array(
43 'type' => 'INT',
44 'null' => FALSE,
45 ),
46 'ends_at' => array(
47 'type' => 'INT',
48 'null' => FALSE,
49 ),
50 'break_starts_at' => array(
51 'type' => 'INT',
52 'null' => TRUE,
53 ),
54 'break_ends_at' => array(
55 'type' => 'INT',
56 'null' => TRUE,
57 ),
58 'range' => array(
59 'type' => 'VARCHAR(16)',
60 'null' => FALSE,
61 'default' => SH4_ShiftTypes_Model::RANGE_HOURS,
62 ),
63 )
64 );
65 $this->dbForge->add_key('id', TRUE);
66 $this->dbForge->create_table('shifttypes');
67 }
68 }
69 }