Skip to content

Commit

Permalink
minor Sylius#10666 Test doctrine migrations up & down (loic425)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.6-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.4
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.4 or 1.5 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set
-->

In CI, we test migration up during installation, but we never test down migrations.
This new Travis test checks doctrine migration up & down.

Commits
-------

d72c1c4 Test doctrine migrations up & down
  • Loading branch information
pamil authored Sep 26, 2019
2 parents 7ad5074 + d72c1c4 commit 02809f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions app/migrations/Version20170711151342.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\Migrations\Exception\SkipMigration;

class Version20170711151342 extends AbstractMigration
{
Expand All @@ -25,9 +24,7 @@ public function up(Schema $schema): void

// Check if foreign key with correct name exists. If so, this indicates all other foreign keys are correct as well
foreach ($schema->getTable('sylius_admin_api_access_token')->getForeignKeys() as $key) {
if ($key->getName() === 'FK_2AA4915D19EB6921') {
throw new SkipMigration('Database has correct index name');
}
$this->skipIf($key->getName() === 'FK_2AA4915D19EB6921', 'Database has correct index name');
}

$this->addSql('ALTER TABLE sylius_admin_api_access_token DROP FOREIGN KEY FK_7D83AA7F19EB6921');
Expand Down
1 change: 1 addition & 0 deletions etc/travis/suites/application/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ commands=(
test-behat-without-javascript
test-behat-with-javascript
test-behat-with-cli
test-doctrine-migrations
)

for command in ${commands[@]}; do
Expand Down
7 changes: 7 additions & 0 deletions etc/travis/suites/application/script/test-doctrine-migrations
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../../bash/common.lib.sh"

print_header "Testing (Doctrine Migrations)" "Sylius"
run_command "bin/console doctrine:migrations:migrate first --no-interaction"
run_command "bin/console doctrine:migrations:migrate latest --no-interaction"

0 comments on commit 02809f6

Please sign in to comment.