-
Notifications
You must be signed in to change notification settings - Fork 1
/
KMMigration.php
61 lines (48 loc) · 1.16 KB
/
KMMigration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @author kofimokome
*/
if ( ! class_exists( 'KMMigration' ) ) {
abstract class KMMigration {
protected $table_name;
protected $is_update = false;
protected $add_prefix = true;
protected $context;
public function __construct( KMMigrationManager $migration_manager, string $context ) {
$this->context = $context;
$migration_manager->migrations[] = $this;
}
/**
* @author kofimokome
* @since 1.0.0
*/
public function getTableName(): string {
global $wpdb;
if ( $this->add_prefix ) {
$env = ( new KMEnv( $this->context ) )->getEnv();
$table_name = $wpdb->prefix . trim( $env['TABLE_PREFIX'] ) . $this->table_name;
return $table_name;
}
return $this->table_name;
}
/**
* @author kofimokome
* @since 1.0.0
*/
public function isUpdate(): string {
return $this->is_update;
}
/**
* @since 1.0.0
* @author kofimokome
* The reverser of a migration
*/
abstract public function down( KMBlueprint $blueprint );
/**
* @since 1.0.0
* @author kofimokome
* The actions of a migration
*/
abstract public function up( KMBlueprint $blueprint );
}
}