Skip to content

Commit a245491

Browse files
authored
Merge pull request #7183 from beberlei/Upgrade-Improvements
Improve DBAL migration docs for object, array and json_array type removals.
2 parents 70081e7 + 1beca40 commit a245491

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

UPGRADE.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,22 @@ The following classes and constants have been deprecated:
573573

574574
Use JSON for storing unstructured data.
575575

576+
You can keep the old type behavior by copying (and adapting) the old type
577+
classes
578+
([Array](https://github.com/doctrine/dbal/blob/2.13.9/lib/Doctrine/DBAL/Types/ArrayType.php)
579+
and
580+
[Object](https://github.com/doctrine/dbal/blob/2.13.9/lib/Doctrine/DBAL/Types/ObjectType.php))
581+
into your own code- base and re-register them in the TypeRegistry:
582+
583+
```php
584+
use Doctrine\DBAL\Types\TypeFactory;
585+
use MyApp\Doctrine\Types\ArrayType;
586+
use MyApp\Doctrine\Types\ObjectType;
587+
588+
TypeRegistry::register('array', new ArrayType());
589+
TypeRegistry::register('object', new ObjectType());
590+
```
591+
576592
## Deprecated `Driver::getSchemaManager()`.
577593

578594
The `Driver::getSchemaManager()` method has been deprecated. Use `AbstractPlatform::createSchemaManager()` instead.
@@ -1329,9 +1345,49 @@ Please generate UUIDs on the application side (e.g. using [ramsey/uuid](https://
13291345

13301346
The `Doctrine\DBAL\Driver::getName()` has been removed.
13311347

1348+
## BC Break: `json_array` type removed
1349+
1350+
Removed `json_array` type and all associated hacks.
1351+
1352+
It is recommened to migrate to the `json` type while still being on the ORM 2
1353+
branch. You then need to migrate the database (using migrations or SchemaTool)
1354+
to update both the type and especially remove the `(Dc2Type:json_array)` column
1355+
comment, before you ugprade to DBAL 3.
1356+
1357+
If you cannot migrate the database or rely on this type, especially its
1358+
behavior with regard to NULL and empty values, you can copy (adapt) the
1359+
[JsonArrayType
1360+
class](https://github.com/doctrine/dbal/blob/2.13.9/lib/Doctrine/DBAL/Types/JsonArrayType.php)
1361+
into your own codebase and re-regsiter under the name:
1362+
1363+
```php
1364+
use Doctrine\DBAL\Types\TypeFactory;
1365+
use MyApp\Doctrine\Types\JsonArrayType;
1366+
1367+
TypeRegistry::register('json_array', new JsonArrayType());
1368+
```
1369+
1370+
Or if you want to opt into the newer type instead, with its slightly changed null behavior, you can
1371+
register that with:
1372+
1373+
```php
1374+
use Doctrine\DBAL\Types\TypeFactory;
1375+
use Doctrine\DBAL\Types\JsonType;
1376+
1377+
TypeRegistry::register('json_array', new JsonType());
1378+
```
1379+
1380+
In Symfony you can register this type with:
1381+
1382+
```yml
1383+
doctrine:
1384+
dbal:
1385+
types:
1386+
json_array: "Doctrine\\DBAL\\Types\\JsonType"
1387+
```
1388+
13321389
## BC BREAK Removed previously deprecated features
13331390
1334-
* Removed `json_array` type and all associated hacks.
13351391
* Removed `Connection::TRANSACTION_*` constants.
13361392
* Removed `AbstractPlatform::DATE_INTERVAL_UNIT_*` and `AbstractPlatform::TRIM_*` constants.
13371393
* Removed `AbstractPlatform::getSQLResultCasing()`, `::prefersSequences()` and `::supportsForeignKeyOnUpdate()` methods.

0 commit comments

Comments
 (0)