Run migration in test, ready for MySQL

This commit is contained in:
Jeremy Benoist 2016-12-12 11:01:54 +01:00
parent 68cb89a516
commit a48b5d5a5a
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
3 changed files with 98 additions and 13 deletions

View file

@ -33,6 +33,12 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
$this->addSql('ALTER DATABASE '.$this->container->getParameter('database_name').' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
// convert field length for utf8mb4
// http://stackoverflow.com/a/31474509/569101
$this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE confirmation_token confirmation_token VARCHAR(180) NOT NULL;');
$this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE salt salt VARCHAR(180) NOT NULL;');
$this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE password password VARCHAR(180) NOT NULL;');
$this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');

View file

@ -36,7 +36,7 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
$this->skipIf(false !== $images, 'It seems that you already played this migration.');
$this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
$this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
}
/**
@ -44,6 +44,6 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
*/
public function down(Schema $schema)
{
$this->addSql('DELETE FROM "'.$this->getTable('craue_config_setting')."\" WHERE name = 'download_images_enabled';");
$this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';");
}
}

101
build.xml
View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="wallabag" default="build">
<target name="build" depends="clean,prepare,phpunit"/>
<target name="prepare-mysql" depends="clean,db_mysql,prepare"/>
<target name="prepare-sqlite" depends="clean,db_sqlite,prepare"/>
<target name="prepare-pgsql" depends="clean,db_pgsql,prepare"/>
<target name="prepare-mysql" depends="clean,prepare_mysql"/>
<target name="prepare-sqlite" depends="clean,prepare_sqlite"/>
<target name="prepare-pgsql" depends="clean,prepare_pgsql"/>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/var/cache"/>
@ -26,11 +26,6 @@
<arg value="doctrine:schema:create"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="cache:clear"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:fixtures:load"/>
@ -45,12 +40,40 @@
<arg value="${basedir}/app/config/tests/parameters_test.mysql.yml"/>
<arg value="${basedir}/app/config/parameters_test.yml"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="cache:clear"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:drop"/>
<arg value="--force"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:create"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:import"/>
<arg value="data/sql/mysql_base.sql"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:migrations:migrate"/>
<arg value="--no-interaction"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:fixtures:load"/>
<arg value="--no-interaction"/>
<arg value="--env=test"/>
</exec>
</target>
<target name="db_sqlite" description="Run test for SQLite">
@ -59,12 +82,40 @@
<arg value="${basedir}/app/config/tests/parameters_test.sqlite.yml"/>
<arg value="${basedir}/app/config/parameters_test.yml"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="cache:clear"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:drop"/>
<arg value="--force"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:create"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:import"/>
<arg value="data/sql/sqlite_base.sql"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:migrations:migrate"/>
<arg value="--no-interaction"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:fixtures:load"/>
<arg value="--no-interaction"/>
<arg value="--env=test"/>
</exec>
</target>
<target name="db_pgsql" description="Run test for PostgreSQL">
@ -73,12 +124,40 @@
<arg value="${basedir}/app/config/tests/parameters_test.pgsql.yml"/>
<arg value="${basedir}/app/config/parameters_test.yml"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="cache:clear"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:drop"/>
<arg value="--force"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:create"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:database:import"/>
<arg value="data/sql/pgsql_base.sql"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:migrations:migrate"/>
<arg value="--no-interaction"/>
<arg value="--env=test"/>
</exec>
<exec executable="php">
<arg value="${basedir}/bin/console"/>
<arg value="doctrine:fixtures:load"/>
<arg value="--no-interaction"/>
<arg value="--env=test"/>
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit + HTML Coverage">