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 / employees / migration.php

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

65 lines 1.4 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_Employees_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( 'employees' );
19
20 if( $currentVersion < 1 ){
21 $this->version1();
22 $this->migrationService->saveVersion( 'employees', 1 );
23 }
24 }
25
26 public function version1()
27 {
28 if( $this->dbForge ){
29 $this->dbForge->add_field(
30 array(
31 'id' => array(
32 'type' => 'INT',
33 'null' => FALSE,
34 'unsigned' => TRUE,
35 'auto_increment' => TRUE
36 ),
37 'title' => array(
38 'type' => 'VARCHAR(255)',
39 'null' => FALSE,
40 ),
41 'description' => array(
42 'type' => 'TEXT',
43 'null' => TRUE,
44 ),
45 'show_order' => array(
46 'type' => 'INT',
47 'null' => FALSE,
48 'default' => 0,
49 ),
50 'status' => array(
51 'type' => 'VARCHAR(16)',
52 'null' => FALSE,
53 'default' => 'active',
54 ),
55 'user_id' => array(
56 'type' => 'INT',
57 'null' => TRUE,
58 ),
59 )
60 );
61 $this->dbForge->add_key('id', TRUE);
62 $this->dbForge->create_table('employees');
63 }
64 }
65 }