3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Migrations\AbstractMigration
;
6 use Doctrine\DBAL\Schema\Schema
;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface
;
8 use Symfony\Component\DependencyInjection\ContainerInterface
;
11 * Removed locked, credentials_expire_at and expires_at.
13 class Version20161128131503
extends AbstractMigration
implements ContainerAwareInterface
16 'locked' => 'smallint',
17 'credentials_expire_at' => 'datetime',
18 'expires_at' => 'datetime',
22 * @var ContainerInterface
26 public function setContainer(ContainerInterface
$container = null)
28 $this->container
= $container;
32 * @param Schema $schema
34 public function up(Schema
$schema)
36 $userTable = $schema->getTable($this->getTable('user'));
38 foreach ($this->fields
as $field => $type) {
39 $this->skipIf(!$userTable->hasColumn($field), 'It seems that you already played this migration.');
40 $userTable->dropColumn($field);
45 * @param Schema $schema
47 public function down(Schema
$schema)
49 $userTable = $schema->getTable($this->getTable('user'));
51 foreach ($this->fields
as $field => $type) {
52 $this->skipIf($userTable->hasColumn($field), 'It seems that you already played this migration.');
53 $userTable->addColumn($field, $type, ['notnull' => false]);
57 private function getTable($tableName)
59 return $this->container
->getParameter('database_table_prefix') . $tableName;