mirror of https://github.com/itflow-org/itflow
Merge pull request #372 from wrongecho/diff
Show diff between current DB structure and the latest DB structure
This commit is contained in:
commit
4efdfe4cfe
|
|
@ -8,9 +8,9 @@ $latest_version = exec("gitrev-parse origin/master");
|
||||||
$current_version = exec("git rev-parse HEAD");
|
$current_version = exec("git rev-parse HEAD");
|
||||||
|
|
||||||
if($current_version == $latest_version){
|
if($current_version == $latest_version){
|
||||||
$update_message = "No Updates available";
|
$update_message = "No Updates available";
|
||||||
}else{
|
}else{
|
||||||
$update_message = "New Updates are Available [$latest_version]";
|
$update_message = "New Updates are Available [$latest_version]";
|
||||||
}
|
}
|
||||||
|
|
||||||
$git_log = shell_exec("git log master..origin/master --pretty=format:'<tr><td>%h</td><td>%ar</td><td>%s</td></tr>'");
|
$git_log = shell_exec("git log master..origin/master --pretty=format:'<tr><td>%h</td><td>%ar</td><td>%s</td></tr>'");
|
||||||
|
|
@ -18,45 +18,70 @@ $git_log = shell_exec("git log master..origin/master --pretty=format:'<tr><td>%h
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="card card-dark">
|
<div class="card card-dark">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title"><i class="fas fa-fw fa-arrow-alt-circle-up"></i> Update</h3>
|
<h3 class="card-title"><i class="fas fa-fw fa-arrow-alt-circle-up"></i> Update</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<center>
|
<center>
|
||||||
<?php if(!empty($git_log)){ ?>
|
<?php if(!empty($git_log)){ ?>
|
||||||
<a class="btn btn-primary btn-lg my-4" href="post.php?update"><i class="fas fa-fw fa-4x fa-arrow-alt-circle-up mb-1"></i><h5>Update App</h5></a>
|
<a class="btn btn-primary btn-lg my-4" href="post.php?update"><i class="fas fa-fw fa-4x fa-arrow-alt-circle-up mb-1"></i><h5>Update App</h5></a>
|
||||||
<?php
|
<?php
|
||||||
}else{
|
}else{
|
||||||
?>
|
?>
|
||||||
<a class="btn btn-dark btn-lg my-4" href="post.php?update_db"><i class="fas fa-fw fa-4x fa-arrow-alt-circle-up mb-1"></i><h5>Update Database</h5></a>
|
<a class="btn btn-dark btn-lg my-4" href="post.php?update_db"><i class="fas fa-fw fa-4x fa-arrow-alt-circle-up mb-1"></i><h5>Update Database</h5></a>
|
||||||
<h3 class="text-success"><i class="fas fa-check-square"></i> Latest version</h3>
|
<h3 class="text-success"><i class="fas fa-check-square"></i> Latest version</h3>
|
||||||
<small class="text-secondary"><?php echo $current_version; ?></small>
|
<small class="text-secondary"><?php echo $current_version; ?></small>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if(!empty($git_log)){
|
||||||
|
?>
|
||||||
|
<table class="table ">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Commit</th>
|
||||||
|
<th>When</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
echo $git_log;
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display a diff between the current DB structure and the latest DB structure, *NIX only
|
||||||
|
if((strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')){
|
||||||
|
|
||||||
|
// Get DB structure as it is
|
||||||
|
exec("mysqldump --user=$dbusername --password=$dbpassword --skip-extended-insert -d --no-data $database | sed 's/ AUTO_INCREMENT=[0-9]*//g' | egrep -v 'MariaDB dump|Host:|Server version|Dump completed' > /tmp/current-structure.sql");
|
||||||
|
|
||||||
|
// Get the new structure from db.sql
|
||||||
|
exec("egrep -v 'MariaDB dump|Host:|Server version|Dump completed' db.sql > /tmp/new-structure.sql");
|
||||||
|
|
||||||
|
// Compare
|
||||||
|
exec("diff /tmp/current-structure.sql /tmp/new-structure.sql > /tmp/diff.txt");
|
||||||
|
$diff = file_get_contents("/tmp/diff.txt");
|
||||||
|
|
||||||
|
// Display, if there is a difference
|
||||||
|
if(!empty($diff)){
|
||||||
|
echo "<br><br><h2>Diff between your database structure and db.sql</h2>";
|
||||||
|
echo "<div style=\"white-space: pre-line\"> $diff </div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
<?php
|
|
||||||
if(!empty($git_log)){
|
|
||||||
?>
|
|
||||||
<table class="table ">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Commit</th>
|
|
||||||
<th>When</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
echo $git_log;
|
|
||||||
?>
|
?>
|
||||||
</tbody>
|
|
||||||
</table>
|
</div>
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php include("footer.php");
|
<?php
|
||||||
|
|
||||||
|
include("footer.php");
|
||||||
Loading…
Reference in New Issue