mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-21 16:38:37 -06:00
Added doctrine migrations and remove platform specific code from entities
This commit is contained in:
parent
7c42835cc1
commit
7d49c1760c
@ -33,7 +33,8 @@
|
||||
"monolog/monolog": "^1.21",
|
||||
"theorchard/monolog-cascade": "^0.4",
|
||||
"endroid/qrcode": "^1.7",
|
||||
"mikehaertl/phpwkhtmltopdf": "^2.2"
|
||||
"mikehaertl/phpwkhtmltopdf": "^2.2",
|
||||
"doctrine/migrations": "^1.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.0",
|
||||
|
39
data/migrations/Version20160819142757.php
Normal file
39
data/migrations/Version20160819142757.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace ShlinkMigrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20160819142757 extends AbstractMigration
|
||||
{
|
||||
const MYSQL = 'mysql';
|
||||
const SQLITE = 'sqlite';
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$db = $this->connection->getDatabasePlatform()->getName();
|
||||
$table = $schema->getTable('short_urls');
|
||||
$column = $table->getColumn('short_code');
|
||||
|
||||
if ($db === self::MYSQL) {
|
||||
$column->setPlatformOption('collation', 'utf8_bin');
|
||||
} elseif ($db === self::SQLITE) {
|
||||
$column->setPlatformOption('collation', 'BINARY');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$db = $this->connection->getDatabasePlatform()->getName();
|
||||
}
|
||||
}
|
4
migrations.yml
Normal file
4
migrations.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: ShlinkMigrations
|
||||
migrations_namespace: ShlinkMigrations
|
||||
table_name: migrations
|
||||
migrations_directory: data/migrations
|
@ -28,8 +28,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* type="string",
|
||||
* nullable=false,
|
||||
* length=10,
|
||||
* unique=true,
|
||||
* options={"collation": "utf8_bin"}
|
||||
* unique=true
|
||||
* )
|
||||
*/
|
||||
protected $shortCode;
|
||||
|
Loading…
Reference in New Issue
Block a user