Skip to content

Commit 7a91a43

Browse files
committed
DOCSP-35933: Upgrade guide
1 parent 249535c commit 7a91a43

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

docs/upgrade.txt

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,32 @@ Upgrade ODM Version
1414
Overview
1515
--------
1616

17-
On this page, you can learn how to upgrade {+odm-short+} to a new version. This page also
18-
includes the changes you must make to your application to upgrade your ODM version
19-
without losing functionality, if applicable.
20-
21-
The PHP library uses `semantic versioning <https://semver.org/>`__. Upgrading
22-
to a new major version may require changes to your application.
17+
On this page, you can learn how to upgrade {+odm-short+} to a new major version.
18+
This page also includes the changes you must make to your application to upgrade
19+
your object-document mapper (ODM) version without losing functionality, if applicable.
2320

2421
How to Upgrade
2522
--------------
2623

2724
Before you upgrade, perform the following actions:
2825

29-
- Ensure the new driver version is compatible with the {+mdb-server+} version
30-
your application connects to and the version of Node.js that your
31-
application runs on. See the :ref:`<node-compatibility>`
26+
- Ensure the new ODM version is compatible with the {+mdb-server+} version
27+
your application connects to and the version of Laravel that your
28+
application runs on. See the :ref:`<laravel-compatibility>`
3229
page for this information.
33-
- Address any breaking changes between the version of the driver
30+
- Address any breaking changes between the version of {+odm-short+} that
3431
your application currently uses and your planned upgrade version in the
35-
:ref:`<node-breaking-changes>` section of this guide. To learn
36-
more about the {+mdb-server+} release compatibility changes, see the
37-
:ref:`<node-server-support-changes>` section.
38-
39-
.. tip::
32+
:ref:`<laravel-breaking-changes>` section of this guide.
4033

41-
You can minimize the amount of changes that you need to make to your
42-
application when upgrading driver versions by using the
43-
:ref:`{+stable-api+} <nodejs-stable-api>`.
44-
45-
To upgrade your driver version, run the following command in your application's
34+
To upgrade your ODM version, run the following command in your application's
4635
directory:
4736

4837
.. code-block:: bash
4938

50-
npm install mongodb@{+version+}
39+
composer require mongodb/laravel-mongodb:{+version+}
5140

52-
To upgrade to a different version of the driver, replace the information after the
53-
``@`` symbol with your preferred version number. For more information about the
54-
``npm install`` command, see the `npm-install <https://docs.npmjs.com/cli/v10/commands/npm-install?v=true>`__
55-
npm documentation.
41+
To upgrade to a different version of the ODM, replace the information after
42+
``laravel-mongodb:`` with your preferred version number.
5643

5744
.. _laravel-breaking-changes:
5845

@@ -73,33 +60,43 @@ planned upgrade version.
7360
Version 4.x Breaking Changes
7461
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7562

76-
- Laravel 10.x is required
63+
This ODM version introduces the following breaking changes:
64+
65+
- Minimum Laravel version is now 10.0. For instructions on upgrading your Laravel version,
66+
see the `Upgrade Guide <https://laravel.com/docs/10.x/upgrade>`__ in the Laravel
67+
documentation.
7768

78-
- Change dependency name in your composer.json to ``"mongodb/laravel-mongodb": "^4.0"``
79-
and run ``composer update``
69+
- Dependency name is now ``"mongodb/laravel-mongodb"``. Ensure that the dependency
70+
name in your ``composer.json`` file is ``"mongodb/laravel-mongodb": "^4.0"``. Then, run
71+
``composer update``.
8072

81-
- Change namespace from ``Jenssegers\Mongodb\`` to ``MongoDB\Laravel\``
82-
in your models and config
73+
- Namespace is now ``MongoDB\Laravel\``. Ensure that you change the namespace from ``Jenssegers\Mongodb\``
74+
to ``MongoDB\Laravel\`` in your models and config files.
8375

84-
- Remove support for non-Laravel projects
76+
- Removes support for non-Laravel projects.
8577

86-
- Replace ``$dates`` with ``$casts`` in your models
78+
- Removes support for the ``$dates`` property. Ensure that you change all instances of ``$dates``
79+
to ``$casts`` in your model files.
8780

88-
- Call ``$model->save()`` after ``$model->unset('field')`` to persist the change
81+
- ``Model::unset($field)`` does not persist the change. Ensure that you follow all calls to
82+
``Model::unset($field)`` with ``Model::save()``.
8983

90-
- Replace calls to ``Query\Builder::whereAll($column, $values)`` with
91-
``Query\Builder::where($column, 'all', $values)``
84+
- Removes the ``Query\Builder::whereAll($column, $values)`` method. Ensure that you replace all calls
85+
to ``Query\Builder::whereAll($column, $values)`` with ``Query\Builder::where($column, 'all', $values)``.
9286

93-
- ``Query\Builder::delete()`` doesn't accept ``limit()`` other than ``1`` or ``null``.
87+
- ``Query\Builder::delete()`` can only delete one or all documents. Ensure that you only pass a value
88+
of ``1`` or ``null`` to ``limit()``.
9489

95-
- ``whereDate``, ``whereDay``, ``whereMonth``, ``whereYear``, ``whereTime``
96-
now use MongoDB operators on date fields
90+
- ``whereDate()``, ``whereDay()``, ``whereMonth()``, ``whereYear()``, and ``whereTime()`` methods
91+
now use MongoDB operators on date fields.
9792

98-
- Replace ``Illuminate\Database\Eloquent\MassPrunable`` with ``MongoDB\Laravel\Eloquent\MassPrunable``
99-
in your models
93+
- Adds the ``MongoDB\Laravel\Eloquent\MassPrunable`` trait. Ensure that you replace all instances of
94+
``Illuminate\Database\Eloquent\MassPrunable`` with ``MongoDB\Laravel\Eloquent\MassPrunable``
95+
in your models.
10096

101-
- Remove calls to not-supported methods of ``Query\Builder``: ``toSql``,
97+
- Removes support for the ``Query\Builder``: ``toSql``,
10298
``toRawSql``, ``whereColumn``, ``whereFullText``, ``groupByRaw``,
10399
``orderByRaw``, ``unionAll``, ``union``, ``having``, ``havingRaw``,
104100
``havingBetween``, ``whereIntegerInRaw``, ``orWhereIntegerInRaw``,
105-
``whereIntegerNotInRaw``, ``orWhereIntegerNotInRaw``.
101+
``whereIntegerNotInRaw``, and ``orWhereIntegerNotInRaw`` methods. Ensure that you remove
102+
all calls to these methods.

0 commit comments

Comments
 (0)