From b4dadcaa4672a314a40205368e798f523849b123 Mon Sep 17 00:00:00 2001 From: Denis Golubovskiy Date: Tue, 5 Dec 2017 11:33:21 +0200 Subject: [PATCH 1/2] MySQL test --- .env.dist | 2 +- .travis.yml | 11 +++++++---- docker-compose.yml | 2 +- src/Entity/Admin.php | 2 +- ...on20171204125843.php => Version20171205092959.php} | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) rename src/Migrations/{Version20171204125843.php => Version20171205092959.php} (81%) diff --git a/.env.dist b/.env.dist index 2769d82..a577543 100644 --- a/.env.dist +++ b/.env.dist @@ -13,5 +13,5 @@ APP_SECRET=5cc9fb6e96b248120f0362681d2c3c5d # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # Configure your db driver and server_version in config/packages/doctrine.yaml -DATABASE_URL=mysql://root@127.0.0.1:3306/test +DATABASE_URL=mysql://test:test@127.0.0.1:3306/test ###< doctrine/doctrine-bundle ### diff --git a/.travis.yml b/.travis.yml index edd75a0..0c7e79c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,17 @@ language: php -sudo: false +sudo: true php: - 7.1 -addons: - mariadb: '10.3' +services: + - docker + +before_install: + - sudo service mysql stop || sudo service mysql-5.6 stop || sudo stop mysql-5.6 || sudo stop mysql || echo "failed to stop mysql" + - sudo docker run -e MYSQL_DATABASE=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test -e MYSQL_ROOT_PASSWORD=testRoot -d -p 127.0.0.1:3306:3306 mysql:5.7 before_script: - - mysql -e 'CREATE DATABASE test;' - composer self-update - composer install --dev --prefer-dist --no-interaction diff --git a/docker-compose.yml b/docker-compose.yml index 88a6fa7..c31f256 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - db db: container_name: db - image: mariadb:10.3 + image: mysql:5.7 environment: MYSQL_DATABASE: test MYSQL_USER: test diff --git a/src/Entity/Admin.php b/src/Entity/Admin.php index 7845d18..8c7db94 100644 --- a/src/Entity/Admin.php +++ b/src/Entity/Admin.php @@ -38,7 +38,7 @@ class Admin /** * @var bool * - * @ORM\Column(name="status", type="boolean", nullable=false, options={"default" : "1"}) + * @ORM\Column(name="status", type="boolean", nullable=false, options={"unsigned": true, "default" : "1"}) */ private $status = true; diff --git a/src/Migrations/Version20171204125843.php b/src/Migrations/Version20171205092959.php similarity index 81% rename from src/Migrations/Version20171204125843.php rename to src/Migrations/Version20171205092959.php index 532d7e6..cef202a 100644 --- a/src/Migrations/Version20171204125843.php +++ b/src/Migrations/Version20171205092959.php @@ -8,14 +8,14 @@ /** * Auto-generated Migration: Please modify to your needs! */ -class Version20171204125843 extends AbstractMigration +class Version20171205092959 extends AbstractMigration { public function up(Schema $schema) { // this up() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - $this->addSql('CREATE TABLE admins (id INT UNSIGNED AUTO_INCREMENT NOT NULL, login VARCHAR(255) DEFAULT NULL, password VARCHAR(255) DEFAULT NULL, status TINYINT(1) DEFAULT \'1\' NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE admins (id INT UNSIGNED AUTO_INCREMENT NOT NULL, login VARCHAR(255) DEFAULT NULL, password VARCHAR(255) DEFAULT NULL, status TINYINT(1) UNSIGNED DEFAULT \'1\' NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); } public function down(Schema $schema) From c1f2bc73aaa0c421a00633f14f05363d71f9bc8f Mon Sep 17 00:00:00 2001 From: Denis Golubovskiy Date: Fri, 8 Dec 2017 13:52:13 +0200 Subject: [PATCH 2/2] Test creating migration on mysql --- .travis.yml | 6 +++-- src/Migrations/Version20171205092959.php | 28 ------------------------ 2 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 src/Migrations/Version20171205092959.php diff --git a/.travis.yml b/.travis.yml index 0c7e79c..dcb21e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,10 @@ before_script: script: - php bin/console doctrine:database:drop -n --force - php bin/console doctrine:database:create -n - - php bin/console doctrine:migrations:migrate -n + - php bin/console doctrine:schema:create -n - php bin/console doctrine:schema:update --dump-sql + - php bin/console doctrine:migrations:diff -n + - php bin/console doctrine:migrations:migrate -n - php bin/console doctrine:schema:validate -n cache: @@ -28,4 +30,4 @@ cache: notifications: email: - - bukashk0zzz@gmail.com \ No newline at end of file + - bukashk0zzz@gmail.com diff --git a/src/Migrations/Version20171205092959.php b/src/Migrations/Version20171205092959.php deleted file mode 100644 index cef202a..0000000 --- a/src/Migrations/Version20171205092959.php +++ /dev/null @@ -1,28 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('CREATE TABLE admins (id INT UNSIGNED AUTO_INCREMENT NOT NULL, login VARCHAR(255) DEFAULT NULL, password VARCHAR(255) DEFAULT NULL, status TINYINT(1) UNSIGNED DEFAULT \'1\' NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); - } - - public function down(Schema $schema) - { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('DROP TABLE admins'); - } -}