Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No migration pretend mode #1108

Merged
merged 1 commit into from
Jul 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions app/controllers/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public function migrationsPending()
$migrator = new Migrator($repository, $this->capsule->getDatabaseManager(), $files);
$dirs = [APP_ROOT . 'database/migrations'];
$this->appendModuleMigrations($dirs);
$migrationFiles = $migrator->run($dirs, Array('pretend' => true));
//$migrationFiles = $migrator->run($dirs, Array('pretend' => true));
$migrationFilenames = Array();

foreach ($migrationFiles as $mf) {
$migrationFilenames[] = basename($mf);
}
// foreach ($migrationFiles as $mf) {
// $migrationFilenames[] = basename($mf);
// }


$obj = new View();
Expand All @@ -52,8 +52,7 @@ public function migrationsPending()
} catch (\Exception $e) {
$obj = new View();
$obj->view('json', array('msg' => Array(
'error' => true,
'error_message' => $e->getMessage(),
'error' => $e->getMessage(),
'error_trace' => $e->getTrace()
)));
}
Expand Down Expand Up @@ -87,20 +86,16 @@ public function migrate()
} catch (\PDOException $exception) {
$obj->view('json', [
'msg' => [
'error' => true,
'error_message' => $exception->getMessage(),
'error' => $exception->getMessage(),
'notes' => $migrator->getNotes()
]
]);
}
} catch (\Exception $e) {
$obj = new View();
$obj->view('json', [
'msg' => [
'error' => true,
'error_message' => $e->getMessage(),
'error' => $e->getMessage(),
'error_trace' => $e->getTrace()
]
]);
}
}
Expand Down
61 changes: 13 additions & 48 deletions app/views/system/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="container">
<div class="row">
<div id="mr-migrations" class="col-lg-12 loading">
<h1><span id="database-update-count">(n/a)</span> <span data-i18n="database.migrations.pending">Database Update(s) Pending</span>
</h1>
<h1>Upgrade Database</h1>
<h3>Click the update button to begin database upgrade.</h3>
</div>
</div>

Expand Down Expand Up @@ -40,16 +40,14 @@
</div> <!-- /container -->

<script>


$(document).on('appReady', function (e, lang) {
var tbody = $('.table-console tbody');

function log(message, level) {
function log (message, level) {
level = level || 'info';
tbody.append('<tr><td class="log-level-' + level + '">' + message + '</td></tr>');
}

function disclose () {
var logDiv = $('#database-upgrade-log');
var disclosureEl = logDiv.find('.disclosure');
Expand Down Expand Up @@ -80,11 +78,11 @@ function done () {
$btn.find('#db-upgrade-label').html('Update');
}

log('started update: ' + new Date());
tbody.empty();
log('Started update: ' + new Date());

$.getJSON(appUrl + '/database/migrate', function (data) {
done();
tbody.empty();

if (data.notes) {
for (var i = 0; i < data.notes.length; i++) {
Expand All @@ -104,51 +102,18 @@ function done () {

if (data.error_trace) {
log('stack trace follows:', 'error');
data.error_trace.forEach(function(stackItem) {
log('in ' + stackItem.file + ':' + stackItem.line + ' ' + stackItem.class + stackItem.type + stackItem.function + '.' , 'error');
data.error_trace.forEach(function (stackItem) {
log('in ' + stackItem.file + ':' + stackItem.line + ' ' + stackItem.class + stackItem.type + stackItem.function + '.', 'error');
});
}
}

}).fail(function (jqXHR, textStatus, error) {
done();
})
});

$.getJSON(appUrl + '/database/migrationsPending', function (data) {
$('.table-console tbody').empty();
$('.loading').removeClass('loading');

if (data.error) {
disclose();
log(data.error_message, 'error');

if (data.error_trace) {
log('stack trace follows:', 'error');
data.error_trace.forEach(function(stackItem) {
var li = $('<li>in ' + stackItem.file + ':' + stackItem.line + ' ' + stackItem.class + stackItem.type + stackItem.function + '</li>');
log('in ' + stackItem.file + ':' + stackItem.line + ' ' + stackItem.class + stackItem.type + stackItem.function + '.' , 'error');
});
}
}

$('#database-update-count').text(data['files_pending'].length);

// if (data['files_pending'].length) {
// for (var i = 0; i < data['files_pending'].length; i++) {
// tbody.append('<tr><td>' + data['files_pending'][i] + '</td></tr>');
// }
// }
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
$('#mr-db table tr td')
.empty()
.addClass('text-danger')
.text(i18n.t('errors.loading', {error: err}));
}).fail(function (jqXHR, textStatus, error) {
log(error, 'error');
done();
})
});
})
;
});
</script>
<?php
$this->view('partials/foot');