Migration::drop_on_deactivation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Abstract class for all Migrations
7
 *
8
 * @package PinkCrab\Perique\Migration\Plugin_Lifecycle
9
 * @author Glynn Quelch [email protected]
10
 * @since 0.0.1
11
 */
12
13
namespace PinkCrab\Perique\Migration;
14
15
use PinkCrab\DB_Migration\Database_Migration;
16
use PinkCrab\Table_Builder\Schema;
17
18
/**
19
 * Abstract class for all Migrations
20
 *
21
 * @method void schema(\PinkCrab\Table_Builder\Schema $schema)
22
 */
23
abstract class Migration extends Database_Migration {
24
25
	/**
26
	 * Creates an instance of the migration.
27
	 */
28
	public function __construct() {
29
		$this->table_name = $this->table_name();
30
		$this->schema     = new Schema( $this->table_name, array( $this, 'schema' ) );
31
		$this->seed_data  = $this->seed( array() );
32
	}
33
34
	/**
35
	 * Must return the table name for the migration.
36
	 *
37
	 * @return string
38
	 */
39
	abstract protected function table_name(): string;
40
41
	/**
42
	 * Is this table dropped on deactivation
43
	 *
44
	 * Defaults to false.
45
	 *
46
	 * @return bool
47
	 */
48
	public function drop_on_deactivation(): bool {
49
		return false;
50
	}
51
52
	/**
53
	 * Drop table on uninstall.
54
	 *
55
	 * Defaults to false.
56
	 *
57
	 * @return bool
58
	 */
59
	public function drop_on_uninstall(): bool {
60
		return false;
61
	}
62
63
	/**
64
	 * Should this migration be seeded on activation.
65
	 *
66
	 * Defaults to true.
67
	 *
68
	 * @return bool
69
	 */
70
	public function seed_on_inital_activation(): bool {
71
		return true;
72
	}
73
}
74