2017-05-10 08:46:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Application\Migrations;
|
|
|
|
|
2023-08-05 17:35:09 +00:00
|
|
|
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
2017-05-10 08:46:32 +00:00
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
2024-02-19 00:30:12 +00:00
|
|
|
use Wallabag\Doctrine\WallabagMigration;
|
2017-05-10 08:46:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Changed length for username, username_canonical, email and email_canonical fields in wallabag_user table.
|
|
|
|
*/
|
2018-06-14 11:43:09 +00:00
|
|
|
class Version20170510082609 extends WallabagMigration
|
2017-05-10 08:46:32 +00:00
|
|
|
{
|
|
|
|
private $fields = [
|
|
|
|
'username',
|
|
|
|
'username_canonical',
|
|
|
|
'email',
|
|
|
|
'email_canonical',
|
|
|
|
];
|
|
|
|
|
2022-12-14 13:36:29 +00:00
|
|
|
public function up(Schema $schema): void
|
2017-05-10 08:46:32 +00:00
|
|
|
{
|
2024-02-18 22:47:34 +00:00
|
|
|
if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
|
|
|
|
$this->write('This migration only apply to MySQL');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2017-05-10 08:46:32 +00:00
|
|
|
|
|
|
|
foreach ($this->fields as $field) {
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
|
2017-05-10 08:46:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 13:36:29 +00:00
|
|
|
public function down(Schema $schema): void
|
2017-05-10 08:46:32 +00:00
|
|
|
{
|
2024-02-18 22:47:34 +00:00
|
|
|
if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
|
|
|
|
$this->write('This migration only apply to MySQL');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2017-05-10 08:46:32 +00:00
|
|
|
|
|
|
|
foreach ($this->fields as $field) {
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
|
2017-05-10 08:46:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|