|
5 | 5 | require_admin_or_401();
|
6 | 6 |
|
7 | 7 | require_once(__DIR__."/../includes/header.php");
|
| 8 | +require_once(__DIR__."/../includes/migrations.php"); |
8 | 9 |
|
9 | 10 | LangUtil::setPageId("debug");
|
10 | 11 |
|
|
16 | 17 | font-weight: bold;
|
17 | 18 | color: red;
|
18 | 19 | }
|
| 20 | + |
| 21 | + .migration_table th:first-of-type { |
| 22 | + text-align: center; |
| 23 | + } |
| 24 | + |
| 25 | + .migration_table th:first-of-type { |
| 26 | + text-align: right; |
| 27 | + } |
| 28 | + |
| 29 | + .migration_table tr td:first-of-type { |
| 30 | + text-align: right; |
| 31 | + } |
| 32 | + |
| 33 | + .migration_table { |
| 34 | + margin: 1rem 2rem; |
| 35 | + } |
| 36 | + |
| 37 | + .migration_table td { |
| 38 | + padding: 0.2rem 0.5rem; |
| 39 | + } |
19 | 40 | </style>
|
20 | 41 |
|
21 | 42 | <h2><?php echo LangUtil::$pageTerms['DEBUG_UTILITIES']; ?></h2>
|
|
54 | 75 |
|
55 | 76 | <h3><?php echo LangUtil::$pageTerms['DATABASE_UTILITIES']; ?></h3>
|
56 | 77 |
|
57 |
| -<h4><?php echo LangUtil::$pageTerms['LEGACY_LAB_DATABASE_MIGRATIONS']; ?></h4> |
| 78 | +<h4>Database Migrations</h4> |
58 | 79 |
|
59 | 80 | <p>
|
60 | 81 | <span class="red-danger"><?php echo LangUtil::$pageTerms['WARNING']; ?></span><br/>
|
61 | 82 | <?php echo LangUtil::$pageTerms['MIGRATION_WARNING']; ?><br/>
|
62 | 83 | <?php echo LangUtil::$pageTerms['MIGRATION_DESCRIPTION']; ?>
|
63 | 84 | </p>
|
64 | 85 |
|
65 |
| -<form action="/debug/debug_apply_migration.php" method="GET"> |
66 |
| - <label for="migration-lab-select"><?php echo LangUtil::$pageTerms['LAB_DATABASE']; ?>:</label> |
67 |
| - <select id="migration-lab-select" name="lab"> |
68 |
| - <option value=""><?php echo LangUtil::$pageTerms['SELECT_LAB']; ?></option> |
69 |
| - <?php |
70 |
| - $lab_configs = get_lab_configs(); |
71 |
| - foreach($lab_configs as $lab) { |
72 |
| - $display_name = $lab->name . " (" . $lab->dbName . ")"; |
73 |
| - echo("<option value=\"".$lab->dbName."\">$display_name</option>\n"); |
| 86 | +<?php |
| 87 | + $selected_database = $_GET["selected_database"]; |
| 88 | +?> |
| 89 | + |
| 90 | +<form action="debug.php" method="GET"> |
| 91 | +<label for="migration-lab-select"><?php echo LangUtil::$pageTerms['LAB_DATABASE']; ?>:</label> |
| 92 | +<select id="migration-lab-select" name="selected_database"> |
| 93 | + <option value="">Select a database</option> |
| 94 | + <option value="blis_revamp" <?php echo($selected_database == "blis_revamp" ? "selected" : ""); ?> >blis_revamp</option> |
| 95 | +<?php |
| 96 | + $lab_configs = get_lab_configs(); |
| 97 | + foreach($lab_configs as $lab) { |
| 98 | + $display_name = $lab->name . " (" . $lab->dbName . ")"; |
| 99 | + $selected = ($lab->dbName == $selected_database) ? "selected" : ""; |
| 100 | + echo("<option value=\"".$lab->dbName."\" $selected>$display_name</option>\n"); |
| 101 | + } |
| 102 | +?> |
| 103 | +</select> |
| 104 | +<input type="submit"> |
| 105 | +</form> |
| 106 | + |
| 107 | +<?php |
| 108 | + $dbtype = $selected_database == "blis_revamp" ? "revamp" : "lab"; |
| 109 | + if ("$selected_database" != "") { |
| 110 | + $migrator = new LabDatabaseMigrator($selected_database, $dbtype); |
| 111 | + $available = array_reverse($migrator->get_available_migrations()); |
| 112 | + $applied = array_reverse($migrator->get_applied_migrations()); |
| 113 | +?> |
| 114 | + <table class="migration_table"> |
| 115 | + <tr> |
| 116 | + <th>Migration Name</th> |
| 117 | + </tr> |
| 118 | +<?php |
| 119 | + foreach($available as $name) { |
| 120 | + $is_applied = in_array($name, $applied); |
| 121 | + |
| 122 | + if (!$is_applied) { |
| 123 | +?> |
| 124 | + <tr> |
| 125 | + <td><?php echo($name); ?></td> |
| 126 | + <td><a href="debug/debug_apply_v2_migration.php?database=<?php echo($selected_database); ?>&migration=<?php echo($name); ?>">Apply</a></td> |
| 127 | + <td><a href="debug/debug_apply_v2_migration.php?database=<?php echo($selected_database); ?>&migration=<?php echo($name); ?>&skip=true">Skip</a></td> |
| 128 | + </tr> |
| 129 | +<?php |
| 130 | + } else { |
| 131 | +?> |
| 132 | + <tr> |
| 133 | + <td><?php echo($name); ?></td> |
| 134 | + <td><a href="debug/debug_apply_v2_migration.php?database=<?php echo($selected_database); ?>&migration=<?php echo($name); ?>&delete=true">Delete</a></td> |
| 135 | + <td></td> |
| 136 | + </tr> |
| 137 | +<?php |
| 138 | + } |
74 | 139 | }
|
75 |
| - ?> |
76 |
| - </select> |
| 140 | +?> |
| 141 | + </table> |
| 142 | +<?php |
| 143 | + } |
| 144 | +?> |
77 | 145 |
|
78 |
| - <br/> |
| 146 | +<h4><?php echo LangUtil::$pageTerms['LEGACY_LAB_DATABASE_MIGRATIONS']; ?></h4> |
79 | 147 |
|
| 148 | +<form action="/debug/debug_apply_migration.php" method="GET"> |
| 149 | + <input type="hidden" name="lab" value="<?php echo($selected_database); ?>"/> |
80 | 150 | <label for="migration-select"><?php echo LangUtil::$pageTerms['SQL_MIGRATION']; ?>:</label>
|
81 | 151 | <select id="migration-select" name="migration">
|
82 | 152 | <option value=""><?php echo LangUtil::$pageTerms['SELECT_MIGRATION']; ?></option>
|
|
0 commit comments