PluginProbe
seQura / trunk
seQura vtrunk
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
sequra / src / Repositories / interface-table-migration-repository.php

interface-table-migration-repository.php in seQura trunk, at src/Repositories/interface-table-migration-repository.php

93 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Define methods migrate data between tables without downtime.
4 *
5 * @package SeQura/WC
6 * @subpackage SeQura/WC/Repositories
7 */
8
9 namespace SeQura\WC\Repositories;
10
11 use SeQura\WC\Dto\Table_Index;
12
13 /**
14 * Define methods migrate data between tables without downtime.
15 */
16 interface Interface_Table_Migration_Repository {
17
18 /**
19 * Add an index to the table. Use with caution, only if the amount of data is small.
20 *
21 * @param Table_Index $index The index.
22 * @return bool True if the index was added or already exists, false otherwise.
23 */
24 public function add_index( $index );
25
26 /**
27 * Check if the index exists.
28 *
29 * @param Table_Index $index The index to check.
30 * @return bool True if the index exists, false otherwise.
31 */
32 public function index_exists( $index );
33
34 /**
35 * Get a list of indexes that are required for the table.
36 *
37 * @return Table_Index[] The list of indexes.
38 */
39 public function get_required_indexes();
40
41 /**
42 * Get the name that is set to the original table during the migration.
43 *
44 * @return string The name of the old table.
45 */
46 public function get_legacy_table_name();
47
48 /**
49 * Check if the migration process is complete.
50 *
51 * @return bool True if the migration process is complete, false otherwise.
52 */
53 public function is_migration_complete();
54
55 /**
56 * Execute the migration process.
57 */
58 public function migrate_next_row();
59
60 /**
61 * Make sure that the required tables for the migration are created.
62 *
63 * @throws Throwable If cannot prepare tables for migration.
64 */
65 public function prepare_tables_for_migration();
66
67 /**
68 * Evaluates if the legacy table should be removed and if so, removes it.
69 *
70 * @return bool True if the legacy table was removed or did not exist, false otherwise.
71 */
72 public function maybe_remove_legacy_table();
73
74 /**
75 * Create the table if it doesn't exist.
76 *
77 * @throws Throwable If the table could not be created.
78 */
79 public function create_table();
80
81 /**
82 * Check if table exists in the database.
83 *
84 * @param boolean $legacy If true, check for legacy table.
85 */
86 public function table_exists( $legacy = false ): bool;
87
88 /**
89 * Returns full table name.
90 */
91 public function get_table_name(): string;
92 }
93