mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:14:04 +00:00
Syncing resources fails when table structures differ
When syncing resources, this line $centralModel = $event->model->getCentralModelName()::create($event->model->getAttributes()); fails in two situations: 1. when there are column(s) in tenant table that are not in central table. 2. when there is already a row in central table with same id as the id generated while creating the model on tenant table(With ID i mean primary key which my differ from Global ID column). With this change, only syncedAttributes will be used while creating the model on central table. unfortunately, with this we lose the ability to populate the row with default values and all required columns must be on $syncedAttributes, but is the only way I could get it to work.
This commit is contained in:
parent
1a5300ab4f
commit
0d423ecddd
1 changed files with 1 additions and 1 deletions
|
|
@ -60,7 +60,7 @@ class UpdateSyncedResource extends QueueableListener
|
||||||
} else {
|
} else {
|
||||||
// If the resource doesn't exist at all in the central DB,we create
|
// If the resource doesn't exist at all in the central DB,we create
|
||||||
// the record with all attributes, not just the synced ones.
|
// the record with all attributes, not just the synced ones.
|
||||||
$centralModel = $event->model->getCentralModelName()::create($event->model->getAttributes());
|
$centralModel = $event->model->getCentralModelName()::create($syncedAttributes);
|
||||||
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue