@@ -14,45 +14,32 @@ Upgrade ODM Version
14
14
Overview
15
15
--------
16
16
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.
23
20
24
21
How to Upgrade
25
22
--------------
26
23
27
24
Before you upgrade, perform the following actions:
28
25
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>`
32
29
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
34
31
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.
40
33
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
46
35
directory:
47
36
48
37
.. code-block:: bash
49
38
50
- npm install mongodb@ {+version+}
39
+ composer require mongodb/laravel-mongodb: {+version+}
51
40
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.
56
43
57
44
.. _laravel-breaking-changes:
58
45
@@ -73,33 +60,43 @@ planned upgrade version.
73
60
Version 4.x Breaking Changes
74
61
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75
62
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.
77
68
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``.
80
72
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.
83
75
84
- - Remove support for non-Laravel projects
76
+ - Removes support for non-Laravel projects.
85
77
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.
87
80
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()``.
89
83
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)``.
92
86
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()``.
94
89
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.
97
92
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.
100
96
101
- - Remove calls to not-supported methods of ``Query\Builder``: ``toSql``,
97
+ - Removes support for the ``Query\Builder``: ``toSql``,
102
98
``toRawSql``, ``whereColumn``, ``whereFullText``, ``groupByRaw``,
103
99
``orderByRaw``, ``unionAll``, ``union``, ``having``, ``havingRaw``,
104
100
``havingBetween``, ``whereIntegerInRaw``, ``orWhereIntegerInRaw``,
105
- ``whereIntegerNotInRaw``, ``orWhereIntegerNotInRaw``.
101
+ ``whereIntegerNotInRaw``, and ``orWhereIntegerNotInRaw`` methods. Ensure that you remove
102
+ all calls to these methods.
0 commit comments