I have two entities:
- Person, which has workspace_id column
- PersonRevision, which does not have workspace_id column
In a migration I have this:
$persons = Person::all();
foreach ($persons as $person) {
$revision = new PersonRevision;
$revision->fill($person->getAttributes());
$revision->save();
}
PersonRevision does not have workspace_id
in fillable
property. But for some reason I got an error: column "workspace_id" of relation "person_revisions" does not exist
.
Besides, if I run the migration second time (by just typing php artisan migrate
second time) it works fine.
What could be the reason? I know I can manually list attributes which need to be filled, or use array_except
but this is inconvenient and does not answer why that happens.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire