PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
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 / shifts / migration.php

migration.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/shifts/migration.php

111 lines 2.3 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_Shifts_Migration
3 {
4 public $dbForge, $migrationService;
5
6 public function __construct(
7 HC3_Hooks $hooks,
8 HC3_MigrationService $migrationService,
9 HC3_Database_DbForge $dbForge = NULL
10 )
11 {
12 $this->dbForge = $dbForge;
13 $this->migrationService = $migrationService;
14 }
15
16 public function up()
17 {
18 $currentVersion = $this->migrationService->getVersion( 'shifts' );
19
20 if( $currentVersion < 1 ){
21 $this->version1();
22 $this->migrationService->saveVersion( 'shifts', 1 );
23 }
24
25 if( $currentVersion < 2 ){
26 $this->version2();
27 $this->migrationService->saveVersion( 'shifts', 2 );
28 }
29 }
30
31 public function version1()
32 {
33 if( $this->dbForge ){
34 $this->dbForge->add_field(
35 array(
36 'id' => array(
37 'type' => 'INT',
38 'null' => FALSE,
39 'unsigned' => TRUE,
40 'auto_increment' => TRUE
41 ),
42
43 'starts_at' => array(
44 'type' => 'BIGINT',
45 'null' => FALSE,
46 ),
47 'ends_at' => array(
48 'type' => 'BIGINT',
49 'null' => FALSE,
50 ),
51
52 'break_starts_at' => array(
53 'type' => 'BIGINT',
54 'null' => TRUE,
55 ),
56 'break_ends_at' => array(
57 'type' => 'BIGINT',
58 'null' => TRUE,
59 ),
60
61 'status' => array(
62 'type' => 'VARCHAR(16)',
63 'null' => FALSE,
64 'default' => 'active',
65 ),
66 'calendar_id' => array(
67 'type' => 'INT',
68 'null' => FALSE,
69 ),
70 'employee_id' => array(
71 'type' => 'INT',
72 'null' => FALSE,
73 ),
74 )
75 );
76 $this->dbForge->add_key('id', TRUE);
77 $this->dbForge->create_table('shifts');
78 }
79 }
80
81 public function version2()
82 {
83 if( $this->dbForge ){
84 $this->dbForge->add_field(
85 array(
86 'id' => array(
87 'type' => 'INT',
88 'null' => FALSE,
89 'unsigned' => TRUE,
90 'auto_increment' => TRUE
91 ),
92 'parent_id' => array(
93 'type' => 'INT',
94 'null' => FALSE,
95 ),
96 'meta_key' => array(
97 'type' => 'VARCHAR(255)',
98 'null' => FALSE,
99 'default' => 'text'
100 ),
101 'meta_value' => array(
102 'type' => 'TEXT',
103 'null' => TRUE,
104 ),
105 )
106 );
107 $this->dbForge->add_key('id', TRUE);
108 $this->dbForge->create_table('shifts_meta');
109 }
110 }
111 }