| 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 |
|