Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active March 23, 2021 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/349370d0a67f90f185dd179f561705f0 to your computer and use it in GitHub Desktop.
Save hissy/349370d0a67f90f185dd179f561705f0 to your computer and use it in GitHub Desktop.
[concrete5][V8] Check all database migrations already run or missed

This script is related with migration error on upgrade from 8.5.2 or before.

concretecms/concretecms#8771

You can check if there're missing migrations on your concrete5 site before upgrade it.

How to run the script

  1. Download checkMigrations.php and upload it
  2. Run it with c5:exec command
concrete/bin/concrete5 c5:exec checkMigrations.php

Example results

No problem

Migrated: 165
Not Migrated: 0

All migrations are already run on your concrete5 site. Feel free to upgrade concrete5.

Found missing migrations

20190309000000
Migrated: 164
Not Migrated: 1

It means 20190309000000 never run on your concrete5 site. You should consider to rerun it before update core.

Reference

Command line interface (CLI) commands

<?php
use Concrete\Core\Updater\Migrations\Configuration;
/** @var \Symfony\Component\Console\Output\OutputInterface $output */
$configuration = new Configuration();
$migrated = 0;
$notMigrated = 0;
foreach ($configuration->getMigrations() as $migration) {
if ($migration->isMigrated()) {
$migrated++;
} else {
$output->writeln(sprintf('<comment>%s</comment>', $migration->getVersion()));
$notMigrated++;
}
}
$output->writeln(sprintf('<info>Migrated: %d</info>', $migrated));
if ($notMigrated) {
$output->writeln(sprintf('<error>Not Migrated: %d</error>', $notMigrated));
} else {
$output->writeln(sprintf('<info>Not Migrated: %d</info>', $notMigrated));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment