From 06fbe197b4af6ef920fdbc113fb98a1cf797cc09 Mon Sep 17 00:00:00 2001 From: Denis Golubovskiy Date: Fri, 8 Dec 2017 13:53:15 +0200 Subject: [PATCH 1/2] mariadb migration create test --- .travis.yml | 6 +++-- src/Entity/Admin.php | 2 +- src/Migrations/Version20171204125843.php | 28 ------------------------ 3 files changed, 5 insertions(+), 31 deletions(-) delete mode 100644 src/Migrations/Version20171204125843.php diff --git a/.travis.yml b/.travis.yml index edd75a0..1d1ba47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,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: @@ -25,4 +27,4 @@ cache: notifications: email: - - bukashk0zzz@gmail.com \ No newline at end of file + - bukashk0zzz@gmail.com 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/Version20171204125843.php deleted file mode 100644 index 532d7e6..0000000 --- a/src/Migrations/Version20171204125843.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) 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'); - } -} From 6989f8b00f7abb807b3a3f78237875babe5ff2c7 Mon Sep 17 00:00:00 2001 From: Denis Golubovskiy Date: Mon, 11 Dec 2017 09:53:24 +0200 Subject: [PATCH 2/2] Test add new field --- .travis.yml | 5 +- AdminEdited.php | 133 +++++++++++++++++++++++++++++++++++++++++++ src/Entity/Admin.php | 2 +- 3 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 AdminEdited.php diff --git a/.travis.yml b/.travis.yml index 1d1ba47..bc6dacc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ php: - 7.1 addons: - mariadb: '10.3' + mariadb: '10.2' before_script: - mysql -e 'CREATE DATABASE test;' @@ -17,6 +17,9 @@ script: - php bin/console doctrine:database:create -n - php bin/console doctrine:schema:create -n - php bin/console doctrine:schema:update --dump-sql + - php bin/console doctrine:schema:validate -n + - rm src/Entity/Admin.php + - mv AdminEdited.php src/Entity/Admin.php - php bin/console doctrine:migrations:diff -n - php bin/console doctrine:migrations:migrate -n - php bin/console doctrine:schema:validate -n diff --git a/AdminEdited.php b/AdminEdited.php new file mode 100644 index 0000000..c84be4b --- /dev/null +++ b/AdminEdited.php @@ -0,0 +1,133 @@ +id; + } + + /** + * Set login + * + * @param string $login + * + * @return Admin + */ + public function setLogin(string $login): Admin + { + $this->login = $login; + + return $this; + } + + /** + * Get login + * + * @return string + */ + public function getLogin(): string + { + return $this->login; + } + + /** + * Set password + * + * @param string $password + * + * @return Admin + */ + public function setPassword(string $password): Admin + { + $this->password = $password; + + return $this; + } + + /** + * Get password + * + * @return string + */ + public function getPassword(): string + { + return $this->password; + } + + /** + * Set status + * + * @param bool $status + * + * @return Admin + */ + public function setStatus(bool $status): Admin + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return bool + */ + public function getStatus(): bool + { + return $this->status; + } +} diff --git a/src/Entity/Admin.php b/src/Entity/Admin.php index 8c7db94..7845d18 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={"unsigned": true, "default" : "1"}) + * @ORM\Column(name="status", type="boolean", nullable=false, options={"default" : "1"}) */ private $status = true;