Skip to content

Commit

Permalink
Merge pull request #2679 from HB9HIL/migration_from_db_in_debug
Browse files Browse the repository at this point in the history
Show latest Migration in Database in the Debug View
  • Loading branch information
magicbug authored Nov 12, 2023
2 parents 8380514 + c55c3bb commit 9f3d6d8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions application/controllers/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public function index()
{
$this->load->helper('file');

$this->load->model('MigrationVersion');

$data['migration_version'] = $this->MigrationVersion->getMigrationVersion();

// Test writing to backup folder
$backup_folder = $this->is_really_writable('backup');
$data['backup_folder'] = $backup_folder;
Expand Down
20 changes: 20 additions & 0 deletions application/models/MigrationVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class MigrationVersion extends CI_Model {

function getMigrationVersion() {
$this->db->select_max('version');
$query = $this->db->get('migrations');
$migration_version = $query->row();

if ($query->num_rows() == 1) {
$migration_version = $query->row()->version;
return $migration_version;
} else {
return null;
}
}

}

?>
5 changes: 5 additions & 0 deletions application/views/debug/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<td>Base URL</td>
<td><span id="baseUrl"><a href="<?php echo $this->config->item('base_url')?>" target="_blank"><?php echo $this->config->item('base_url'); ?></a></span> <span data-toggle="tooltip" data-original-title="<?php echo lang('copy_to_clipboard'); ?>" onclick='copyURL("<?php echo $this->config->item('base_url'); ?>")'><i class="copy-icon fas fa-copy"></span></td>
</tr>
<tr>
<td>Migration</td>
<td><?php echo (isset($migration_version) ? $migration_version : "<span class='badge badge-danger'>There is something wrong with your Migration in Database!</span>"); ?></td>
</tr>

</table>
</div>
</div>
Expand Down

0 comments on commit 9f3d6d8

Please sign in to comment.