Skip to content

Commit

Permalink
Exclude fields added to BaseObject or BaseTerm that are not on Taxono…
Browse files Browse the repository at this point in the history
…myTerm
  • Loading branch information
michalkleiner committed Mar 15, 2021
1 parent 254f447 commit 4227498
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Dev/AT4xMigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public function run($request)
}

$versionedFields = array_keys(Config::inst()->get(Versioned::class, 'db_for_versions_table'));
$termTableFields = array_keys($schema->databaseFields(TaxonomyTerm::class, false));

DB::get_conn()->withTransaction(function () use ($schema, $termTable, $versionedFields) {
DB::get_conn()->withTransaction(function () use ($schema, $termTable, $termTableFields, $versionedFields) {

// cater for standard versioning db table suffiixes
$dbTableSuffixes = [
Expand All @@ -79,9 +80,10 @@ public function run($request)
foreach ($dbTableSuffixes as $dbTableSuffix) {
foreach ([BaseObject::class, BaseTerm::class] as $model) {

// get db table with suffix and all uninherited db fields
// get db table with suffix and all uninherited db fields, remove fields not shared with TaxonomyTerm
$dbTable = $schema->tableName($model) . $dbTableSuffix;
$dbFields = array_keys($schema->databaseFields($model, false));
$dbFields = array_intersect($dbFields, $termTableFields);

// add special versioning fields
if ($dbTableSuffix === '_Versions') {
Expand Down

0 comments on commit 4227498

Please sign in to comment.