Merge pull request #374 from acelaya/feature/migrations-v2

Feature/migrations v2
This commit is contained in:
Alejandro Celaya 2019-03-09 18:54:51 +01:00 committed by GitHub
commit 1a1868c7f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 29 deletions

View File

@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
#### Added
* [#153](https://github.com/shlinkio/shlink/issues/153) Updated to [doctrine/migrations](https://github.com/doctrine/migrations) version 2.0.0
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* *Nothing*
## 1.16.2 - 2019-03-05
#### Added

View File

@ -20,7 +20,7 @@
"cakephp/chronos": "^1.2",
"cocur/slugify": "^3.0",
"doctrine/cache": "^1.6",
"doctrine/migrations": "^1.4",
"doctrine/migrations": "^2.0",
"doctrine/orm": "^2.5",
"endroid/qr-code": "^1.7",
"firebase/php-jwt": "^4.0",

View File

@ -3,21 +3,24 @@ declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160819142757 extends AbstractMigration
{
const MYSQL = 'mysql';
const SQLITE = 'sqlite';
private const MYSQL = 'mysql';
private const SQLITE = 'sqlite';
/**
* @param Schema $schema
* @throws DBALException
* @throws SchemaException
*/
public function up(Schema $schema)
public function up(Schema $schema): void
{
$db = $this->connection->getDatabasePlatform()->getName();
$table = $schema->getTable('short_urls');
@ -31,9 +34,9 @@ class Version20160819142757 extends AbstractMigration
}
/**
* @param Schema $schema
* @throws DBALException
*/
public function down(Schema $schema)
public function down(Schema $schema): void
{
$db = $this->connection->getDatabasePlatform()->getName();
}

View File

@ -3,19 +3,16 @@ declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160820191203 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
public function up(Schema $schema): void
{
// Check if the tables already exist
$tables = $schema->getTables();
@ -29,7 +26,7 @@ class Version20160820191203 extends AbstractMigration
$this->createShortUrlsInTagsTable($schema);
}
protected function createTagsTable(Schema $schema)
private function createTagsTable(Schema $schema): void
{
$table = $schema->createTable('tags');
$table->addColumn('id', Type::BIGINT, [
@ -46,7 +43,7 @@ class Version20160820191203 extends AbstractMigration
$table->setPrimaryKey(['id']);
}
protected function createShortUrlsInTagsTable(Schema $schema)
private function createShortUrlsInTagsTable(Schema $schema): void
{
$table = $schema->createTable('short_urls_in_tags');
$table->addColumn('short_url_id', Type::BIGINT, [
@ -70,10 +67,7 @@ class Version20160820191203 extends AbstractMigration
$table->setPrimaryKey(['short_url_id', 'tag_id']);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
public function down(Schema $schema): void
{
$schema->dropTable('short_urls_in_tags');
$schema->dropTable('tags');

View File

@ -3,10 +3,10 @@ declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
@ -14,10 +14,9 @@ use Doctrine\DBAL\Types\Type;
class Version20171021093246 extends AbstractMigration
{
/**
* @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema)
public function up(Schema $schema): void
{
$shortUrls = $schema->getTable('short_urls');
if ($shortUrls->hasColumn('valid_since')) {
@ -33,10 +32,9 @@ class Version20171021093246 extends AbstractMigration
}
/**
* @param Schema $schema
* @throws SchemaException
*/
public function down(Schema $schema)
public function down(Schema $schema): void
{
$shortUrls = $schema->getTable('short_urls');
if (! $shortUrls->hasColumn('valid_since')) {

View File

@ -3,10 +3,10 @@ declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
@ -14,10 +14,9 @@ use Doctrine\DBAL\Types\Type;
class Version20171022064541 extends AbstractMigration
{
/**
* @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema)
public function up(Schema $schema): void
{
$shortUrls = $schema->getTable('short_urls');
if ($shortUrls->hasColumn('max_visits')) {
@ -31,10 +30,9 @@ class Version20171022064541 extends AbstractMigration
}
/**
* @param Schema $schema
* @throws SchemaException
*/
public function down(Schema $schema)
public function down(Schema $schema): void
{
$shortUrls = $schema->getTable('short_urls');
if (! $shortUrls->hasColumn('max_visits')) {