Skip to content

Commit 7712c28

Browse files
committed
JM tech review 3
1 parent 9e5983a commit 7712c28

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

docs/eloquent-models/model-class.txt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,16 @@ multiple schemas, you can update the value of the ``SCHEMA_VERSION``
358358
constant in subsequent model classes.
359359

360360
When creating your model, you can define the ``migrateSchema()`` method
361-
to specify a migration to the current schema version upon saving a
361+
to specify a migration to the current schema version upon retrieving a
362362
model. In this method, you can specify the changes to make to an older
363363
model to update it to match the current schema version.
364364

365+
When you save a model that does not have a schema version
366+
specified, Laravel assumes that it follows the latest schema version.
367+
When you retrieve a model that does not contain the ``schema_version``
368+
field, Laravel assumes that its schema version is ``0`` and performs the
369+
migration.
370+
365371
Schema Versioning Example
366372
~~~~~~~~~~~~~~~~~~~~~~~~~
367373

@@ -387,15 +393,16 @@ You can define the new model class with the following behavior:
387393
:emphasize-lines: 10,12,20
388394
:dedent:
389395

390-
When you save or retrieve a model that does not have a schema version
391-
specified, Laravel assumes that it follows the latest schema version.
396+
In the ``"WASP-39 b"`` document in the following code, the
397+
``schema_version`` field value is less than ``2``. When you retrieve the
398+
document, Laravel adds the ``galaxy`` field and updates the schema
399+
version to the current version, ``2``.
392400

393-
When you save or retrieve a model in which the ``schema_version`` field
394-
value is less than ``2``, Laravel adds the ``galaxy``
395-
field and updates the schema version to the current version (``2``).
401+
The ``"Saturn"`` document does not contain the ``schema_version`` field,
402+
so Laravel assigns it the current schema version upon saving.
396403

397-
The following code inserts two instances of the ``Planet`` model, then
398-
retrieves the models from the collection to demonstrate the changes:
404+
Finally, the code retrieves the models from the collection to
405+
demonstrate the changes:
399406

400407
.. io-code-block::
401408
:copyable: true

0 commit comments

Comments
 (0)