From: adev Date: Thu, 2 Nov 2017 23:41:47 +0000 (+0100) Subject: Add an initial migration X-Git-Tag: 2.3.0~14^2~6 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=18fb777b89c6cca529979ab1202eb1af5458bd5d;p=github%2Fwallabag%2Fwallabag.git Add an initial migration --- diff --git a/.travis.yml b/.travis.yml index 42fbb966..0d716351 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,10 +72,6 @@ script: - travis_wait bash composer install -o --no-interaction --no-progress --prefer-dist - make prepare DB=$DB - - echo "travis_fold:start:migrations" - - php bin/console doctrine:migrations:migrate --no-interaction --env=test - - echo "travis_fold:end:migrations" - - echo "travis_fold:start:fixtures" - php bin/console doctrine:fixtures:load --no-interaction --env=test - echo "travis_fold:end:fixtures" diff --git a/Makefile b/Makefile index 9e44edc6..0686454f 100755 --- a/Makefile +++ b/Makefile @@ -30,18 +30,7 @@ ifdef DB endif -php bin/console doctrine:database:drop --force --env=test php bin/console doctrine:database:create --env=test -ifndef DB ## make test does not define DB - php bin/console doctrine:schema:create --env=test -endif -ifeq ($(DB), sqlite) - php bin/console doctrine:schema:create --env=test -endif -ifeq ($(DB), mysql) - php bin/console doctrine:database:import data/sql/mysql_base.sql --env=test -endif -ifeq ($(DB), pgsql) - psql -h localhost -d wallabag_test -U travis -f data/sql/pgsql_base.sql -endif + php bin/console doctrine:migrations:migrate --no-interaction --env=test fixtures: ## Load fixtures into database php bin/console doctrine:fixtures:load --no-interaction --env=test diff --git a/app/DoctrineMigrations/Version20160401000000.php b/app/DoctrineMigrations/Version20160401000000.php new file mode 100644 index 00000000..34d97d16 --- /dev/null +++ b/app/DoctrineMigrations/Version20160401000000.php @@ -0,0 +1,181 @@ +version->getConfiguration()->getNumberOfExecutedMigrations() > 0) { + $this->version->markMigrated(); + $this->skipIf(true, 'Database already initialized'); + } + + switch ($this->connection->getDatabasePlatform()->getName()) { + case 'sqlite': + $sql = <<addSql($query); + } + + break; + case 'mysql': + $sql = <<addSql($query); + } + break; + + case 'postgresql': + $sql = <<addSql($query); + } + break; + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + //TODO: drop tables + } +}