Migration generator fixes and station webhook name addition.

This commit is contained in:
Buster "Silver Eagle" Neece 2018-03-20 11:31:55 -05:00
parent 3adcdcf3a1
commit b016c09fea
8 changed files with 128 additions and 23 deletions

View File

@ -54,9 +54,14 @@ return function (\Slim\Container $di, $settings) {
'conn' => [
'driver' => 'pdo_mysql',
'charset' => 'utf8mb4',
'defaultTableOptions' => [
'charset' => 'utf8mb4',
'collate' => 'utf8mb4_unicode_ci',
],
'driverOptions' => [
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci',
],
'platform' => new \Doctrine\DBAL\Platforms\MariaDb1027Platform(),
]
];
@ -79,17 +84,6 @@ return function (\Slim\Container $di, $settings) {
// Fetch and store entity manager.
$config = new \Doctrine\ORM\Configuration;
// Handling for class names specified as platform types.
if (!empty($options['conn']['platform'])) {
$class_obj = new \ReflectionClass($options['conn']['platform']);
$options['conn']['platform'] = $class_obj->newInstance();
}
// Special handling for the utf8mb4 type.
if ($options['conn']['driver'] === 'pdo_mysql' && $options['conn']['charset'] === 'utf8mb4') {
$options['conn']['platform'] = new \App\Doctrine\Platform\MysqlUnicode;
}
$metadata_driver = $config->newDefaultAnnotationDriver($options['modelPath']);
$config->setMetadataDriverImpl($metadata_driver);

View File

@ -3,7 +3,7 @@ namespace Entity;
/**
* @Entity
* @Table(name="station_webhooks")
* @Table(name="station_webhooks", options={"charset"="utf8mb4", "collate"="utf8mb4_unicode_ci"})
*/
class StationWebhook
{
@ -31,7 +31,13 @@ class StationWebhook
protected $station;
/**
* @Column(name="name", type="string", length=100)
* @Column(name="name", type="string", length=100, nullable=true)
* @var string|null The nickname of the webhook connector.
*/
protected $name;
/**
* @Column(name="type", type="string", length=100)
* @var string The type of webhook connector to use.
*/
protected $type;
@ -78,6 +84,22 @@ class StationWebhook
return $this->station;
}
/**
* @return null|string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param null|string $name
*/
public function setName(?string $name): void
{
$this->name = $name;
}
/**
* @return string
*/

View File

@ -0,0 +1,28 @@
<?php declare(strict_types = 1);
namespace Migration;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180320052444 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('ALTER TABLE station_media_art ADD CONSTRAINT FK_35E0CAB2EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id)');
}
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('ALTER TABLE station_media_art DROP FOREIGN KEY FK_35E0CAB2EA9FDD75');
}
}

View File

@ -0,0 +1,28 @@
<?php declare(strict_types = 1);
namespace Migration;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180320061801 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('ALTER TABLE station_webhooks CHANGE name type VARCHAR(100) NOT NULL');
}
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('ALTER TABLE station_webhooks CHANGE type name VARCHAR(100) NOT NULL COLLATE utf8mb4_unicode_ci');
}
}

View File

@ -0,0 +1,28 @@
<?php declare(strict_types = 1);
namespace Migration;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180320070100 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('ALTER TABLE station_webhooks ADD name VARCHAR(100) DEFAULT NULL');
}
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('ALTER TABLE station_webhooks DROP name');
}
}

View File

@ -10,7 +10,8 @@
"azuracast/azuraforms": "dev-master",
"zendframework/zend-paginator": "^2.7",
"zendframework/zend-config": "^3.1.0",
"doctrine/orm": "~2.5",
"doctrine/orm": "~2.6",
"doctrine/dbal": "dev-master",
"doctrine/migrations": "^1.5",
"jdorn/sql-formatter": "^1.2",
"packaged/helpers": "^1.5",

21
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "c56825dc807e0230f4f614479cebe77c",
"content-hash": "7e537024f92a04af2a7b16b96c87a742",
"packages": [
{
"name": "azuracast/azuraforms",
@ -418,16 +418,16 @@
},
{
"name": "doctrine/dbal",
"version": "v2.6.3",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13"
"reference": "94afff5f0a45fb3f422e475c3882e4e5b8e9395c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/e3eed9b1facbb0ced3a0995244843a189e7d1b13",
"reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/94afff5f0a45fb3f422e475c3882e4e5b8e9395c",
"reference": "94afff5f0a45fb3f422e475c3882e4e5b8e9395c",
"shasum": ""
},
"require": {
@ -436,9 +436,11 @@
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^5.4.6",
"doctrine/coding-standard": "^3.0",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5",
"symfony/console": "2.*||^3.0"
"symfony/console": "^2.0.5||^3.0",
"symfony/phpunit-bridge": "^3.4.5|^4.0.5"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@ -449,7 +451,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
"dev-master": "2.7.x-dev"
}
},
"autoload": {
@ -487,7 +489,7 @@
"persistence",
"queryobject"
],
"time": "2017-11-19T13:38:54+00:00"
"time": "2018-03-17T09:07:34+00:00"
},
{
"name": "doctrine/inflector",
@ -5418,6 +5420,7 @@
"stability-flags": {
"roave/security-advisories": 20,
"azuracast/azuraforms": 20,
"doctrine/dbal": 20,
"james-heinrich/getid3": 20
},
"prefer-stable": true,

View File

@ -110,6 +110,7 @@ services:
user: 'azuracast'
working_dir: '/var/azuracast/www'
command: 'bash'
tty: true # Pretty colors
init: true
stations: