Skip to content

Commit

Permalink
Migrations 3.0 (#858)
Browse files Browse the repository at this point in the history
* use multiple migrations directories and namespaces

* update more commands

* increase version

* allow custom sorting

* executor

* remove start migration

* value object comparison for versions

* adapted execute command

* do not load from sub namespaces

* format migration state

* start adapting tests

* stricter execution result

* create MigratorConfigurationFactory

* extract factory interface

* fix event dispatcher

* use configuration loaders, drop inheritance

* add config loader tests

* config tests

* executor tests

* command tests

* up to date command

* migrations repo tests

* metadata tests

* alias resolver tests

* factory test

* cs and tests

* interface

* autocommit listener

* migration plan calculator tests

* simplify code for migration plan calculator

* more tests

* rollup test

* restore file builder

* test schema diff

* stub schema provider

* dump schema test

* generate test

* diff command

* dix deps

* execute command

* migrate command

* remove outdated tests

* simplify class

* Update documentation

* more changes

* add event arg test

* static analysis

* moved new-migrations and unavailable migrations to the plan calculator

* green tests

* fix most of the phpstan stuff

* update xsd validator for 3.0

* phpstan

* add constructor provided migrations

* add missing range feature

* fix some failing tests

* missing factory method

* add config loader

* first/last tests

* di test

* move migrator option to command

* migrator tests

* phpstan and tests

* restore down migration behaviour

* stof code review suggestions

* use datetime immutable

* mark value objects as final

* single queries are run in debug mode

* ensure proper typecasting

* skip migration version table in the schema dumps

* allow to filter tables in a dump

* prepare upgrading document

* version it is a string

* fix too large column size

* change output levels

* fixed a lot of stuff from code review

* move generateVersionNumber out of config class

* rename MigratorConfigurationFactory

* rename Factory

* cs

* add version equals method

* rename interfaces

* more readable executed at code

* ensure lowercase column names

* document migrator interface

* code reviews by @greg0ire

* alphabetical sorting of loaders

* change argument order of ConnectionHelperLoader

* rename PhpFileLoader

* remove param default

* mark getDirectoryRelativeToFile as final

* rename UnableToLoadResource

* mark ConfigurationLoader as internal

* split table storage documentation

* MigrationNotAvailable::forVersion

* update composer lock

* handle possible regex errors

* diff command tests fixed after rebase

* upgrade

* run cs on php 7.2

* windows tests

* filesystem sorting is not relevant in the finder

* migration plan execution is immutable

* warn to not use registerMigrationInstance

* regex finder accepts any class naming

* do not allow invalid config keys

* array loader is a hard dependency for the other loaders

* no invalid keys are allowed

* refer to https://github.com/Roave/BackwardCompatibilityCheck instead of having a long list

* classgenerator test

* rename AliasResolver into DefaultAliasResolver

* rename AbstractCommand into DoctrineCommand

* removed cs rules for outdated classes

* renamed ConfigurationHelperInterface into ConfigurationHelper

* renamed ConnectionLoaderInterface into ConnectionLoader

* removed cs rules for outdated classes

* renamed ParameterFormatter into InlineParameterFormatter

* renamed FileBuilderInterface into ConcatenationFileBuilder

* renamed ExecutorInterface into Executor

* ensure there is always some metadata configuration set

* renamed Migrator into DbalMigrator

* add typehint on version class

* fixed typo in MetadataStorageConfiguration class

* re sort imports after class renaming
  • Loading branch information
goetas authored and alcaeus committed Nov 30, 2019
1 parent 229462c commit d74785f
Show file tree
Hide file tree
Showing 287 changed files with 8,558 additions and 12,124 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:

- stage: Test
env: COVERAGE
php: 7.2
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
Expand All @@ -44,10 +45,12 @@ jobs:

- stage: Code Quality
env: CODING_STANDARDS
php: 7.2
install: travis_retry composer install --prefer-dist
script: ./vendor/bin/phpcs

- stage: Code Quality
env: STATIC_ANALYSIS
php: 7.2
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpstan analyse
70 changes: 70 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
# Upgrade to 3.0

- The "version" is the FQCN of the migration class (existing entries in the migrations table will be automatically updated).
- `MigrationsEventArgs` and `MigrationsVersionEventArgs` expose different API,
please refer to the [Code BC breaks](#code-bc-breaks) section.

## Console
- Console output changed. The commands use a different output style. If you were relying on specific output,
please update your scripts.
Console output is not covered by the BC promise, so please try not to rely on specific a output.
Different levels of verbosity are available now (`-v`, `-vv` and `-vvv` ).

## Migrations table

- The migrations table now has a new column named `execution_time`.


## Configuration files

*migrations.php Before*
```php
<?php

return [
'name' => 'My Project Migrations',
'migrations_namespace' => 'MyProject\Migrations',
'table_name' => 'doctrine_migration_versions',
'column_name' => 'version',
'column_length' => 14,
'executed_at_column_name' => 'executed_at',
'migrations_directory' => '/data/doctrine/migrations-docs-example/lib/MyProject/Migrations',
'all_or_nothing' => true,
'check_database_platform' => true,
];
```
*migrations.php After*

```php
<?php

return [
'name' => 'My Project Migrations',

'table_storage' => [
'table_name' => 'doctrine_migration_versions',
'version_column_name' => 'version',
'version_column_length' => 1024,
'executed_at_column_name' => 'executed_at',
'execution_time_column_name' => 'execution_time',
],

'migrations_paths' => [
'MyProject\Migrations' => '/data/doctrine/migrations/lib/MyProject/Migrations',
'MyProject\Component\Migrations' => './Component/MyProject/Migrations',
],

'all_or_nothing' => true,
'check_database_platform' => true,
];
```

Files in XML, YAML or JSON also changed in a similar way. Please refer to the official documentation for more details.

## Code BC breaks

Most of the code is protected by the `@internal` declaration and in a very rare cases you might have dealt with the
internals of this library.
You can use [Roave/BackwardCompatibilityCheck](https://github.com/Roave/BackwardCompatibilityCheck) and get a list of
changed elements.

# Upgrade to 2.0

## BC Break: Moved `Doctrine\DBAL\Migrations` to `Doctrine\Migrations`
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
"doctrine/coding-standard": "^6.0",
"doctrine/orm": "^2.6",
"jdorn/sql-formatter": "^1.1",
"mikey179/vfsstream": "^1.6",
"phpstan/phpstan": "^0.10",
"phpstan/phpstan-deprecation-rules": "^0.10",
"phpstan/phpstan-phpunit": "^0.10",
"phpstan/phpstan-strict-rules": "^0.10",
"mikey179/vfsStream": "^1.6",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpstan/phpstan-symfony": "^0.11.6",
"phpunit/phpunit": "^7.0",
"symfony/process": "^3.4||^4.0||^5.0",
"symfony/yaml": "^3.4||^4.0||^5.0"
Expand All @@ -51,7 +52,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "3.0.x-dev"
}
},
"bin": [
Expand Down
Loading

0 comments on commit d74785f

Please sign in to comment.