From c4c78bfe9bbfa9defb58e9a6223c9faa680dca34 Mon Sep 17 00:00:00 2001 From: Michal Kleiner Date: Mon, 29 Mar 2021 11:53:00 +1300 Subject: [PATCH] Skip migration when BaseObject or BaseTerm contain any data --- src/Dev/AT4xMigrationTask.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Dev/AT4xMigrationTask.php b/src/Dev/AT4xMigrationTask.php index 4d236a4..5575ae3 100644 --- a/src/Dev/AT4xMigrationTask.php +++ b/src/Dev/AT4xMigrationTask.php @@ -60,8 +60,11 @@ public function run($request) $baseObjectsCount = DB::query(sprintf('SELECT COUNT(1) FROM "%s"', $baseObjectTable))->value(); $baseTermsCount = DB::query(sprintf('SELECT COUNT(1) FROM "%s"', $baseTermTable))->value(); - // Skip migration if all tables have the same number of records - if (($termsCount === $baseObjectsCount) && ($termsCount == $baseTermsCount)) { + // Skip migration when BaseObject or BaseTerm have any data in them + if ($baseObjectsCount || $baseTermsCount) { + DB::get_schema()->alterationMessage("BaseObject or BaseTerm table already contains data, skipping the migration.", 'notice'); + DB::get_schema()->alterationMessage('If you want disable the migration completely and hide this message, set AT4xMigrationTask::enable_v4_migration to false.', 'notice'); + return; }