mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 12:24: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. unfortunatelly, with this we lose the hability 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
0d423ecddd
commit
fb44f3288d
1 changed files with 1 additions and 1 deletions
|
|
@ -59,7 +59,7 @@ class UpdateSyncedResource extends QueueableListener
|
|||
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
||||
} else {
|
||||
// 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 only synced ones.
|
||||
$centralModel = $event->model->getCentralModelName()::create($syncedAttributes);
|
||||
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue