Skip to content
Open
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
7 changes: 3 additions & 4 deletions src/DB/Data/ArrayDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Diff\DiffOp\DiffOpAdd;
use Diff\DiffOp\DiffOpRemove;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;


class ArrayDiff {
Expand Down Expand Up @@ -53,10 +54,8 @@ public function tag($table) {
// unset the fields to ignore
$params = ParamsFactory::get();
if (isset($params->fieldsToIgnore[$table])) {
foreach ($params->fieldsToIgnore[$table] as $fieldToIgnore) {
unset($entry1[$fieldToIgnore]);
unset($entry2[$fieldToIgnore]);
}
$entry1 = Arr::except($entry1, $params->fieldsToIgnore[$table]);
$entry2 = Arr::except($entry2, $params->fieldsToIgnore[$table]);
}

$differ = new MapDiffer();
Expand Down
19 changes: 17 additions & 2 deletions src/DB/Data/DBData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use DBDiff\Diff\SetDBCollation;
use DBDiff\Exceptions\DataException;
use DBDiff\Logger;
use Illuminate\Support\Str;


class DBData {
Expand All @@ -24,8 +25,22 @@ function getDiff() {
$targetTables = $this->manager->getTables('target');

if (isset($params->tablesToIgnore)) {
$sourceTables = array_diff($sourceTables, $params->tablesToIgnore);
$targetTables = array_diff($targetTables, $params->tablesToIgnore);
$sourceTables = array_values(array_filter(
$sourceTables,
function ($tbl) use ($params) {
foreach ($params->tablesToIgnore as $patt)
if (Str::is($patt, $tbl)) return false;
return true;
},
));
$targetTables = array_values(array_filter(
$targetTables,
function ($tbl) use ($params) {
foreach ($params->tablesToIgnore as $patt)
if (Str::is($patt, $tbl)) return false;
return true;
},
));
}

$commonTables = array_intersect($sourceTables, $targetTables);
Expand Down
20 changes: 17 additions & 3 deletions src/DB/Schema/DBSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use DBDiff\Diff\DropTable;
use DBDiff\Diff\AddTable;
use DBDiff\Diff\AlterTable;

use Illuminate\Support\Str;


class DBSchema {
Expand Down Expand Up @@ -44,8 +44,22 @@ function getDiff() {
$targetTables = $this->manager->getTables('target');

if (isset($params->tablesToIgnore)) {
$sourceTables = array_diff($sourceTables, $params->tablesToIgnore);
$targetTables = array_diff($targetTables, $params->tablesToIgnore);
$sourceTables = array_values(array_filter(
$sourceTables,
function ($tbl) use ($params) {
foreach ($params->tablesToIgnore as $patt)
if (Str::is($patt, $tbl)) return false;
return true;
},
));
$targetTables = array_values(array_filter(
$targetTables,
function ($tbl) use ($params) {
foreach ($params->tablesToIgnore as $patt)
if (Str::is($patt, $tbl)) return false;
return true;
},
));
}

$addedTables = array_diff($sourceTables, $targetTables);
Expand Down