Skip to content

Commit

Permalink
Test doctrine migrations up & down
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Sep 10, 2019
1 parent 70ed4df commit d72c1c4
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 d72c1c4

Please sign in to comment.