*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
+ $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
- $this->skipIf($schema->getTable($this->getTable('oauth2_clients'))->hasColumn('user_id'), 'It seems that you already played this migration.');
+ $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
- $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD user_id INT(11) DEFAULT NULL');
- $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD CONSTRAINT FK_clients_user_clients FOREIGN KEY (user_id) REFERENCES '.$this->getTable('user').' (id) ON DELETE CASCADE');
+ $clientsTable->addColumn('user_id', 'integer');
+
+ $clientsTable->addForeignKeyConstraint(
+ $this->getTable('user'),
+ array('user_id'),
+ array('id'),
+ array('onDelete' => 'CASCADE')
+ );
}
/**
*/
public function down(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
-
$this->addSql('DELETE FROM "'.$this->getTable('craue_config_setting')."\" WHERE name = 'download_images_enabled';");
}
}
*/
public function up(Schema $schema)
{
- switch ($this->connection->getDatabasePlatform()->getName()) {
- case 'sqlite':
- $this->addSql('CREATE INDEX `created_at` ON `'.$this->getTable('entry').'` (`created_at` DESC)');
- break;
-
- case 'mysql':
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD INDEX created_at (created_at);');
- break;
-
- case 'postgresql':
- $this->addSql('CREATE INDEX created_at ON '.$this->getTable('entry').' (created_at DESC)');
- }
+ $entryTable = $schema->getTable($this->getTable('entry'));
+ $entryTable->addIndex(['created_at']);
}
/**
*/
public function up(Schema $schema)
{
- $this->skipIf($schema->getTable($this->getTable('config'))->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.');
+ $configTable = $schema->getTable($this->getTable('config'));
- $this->addSql('ALTER TABLE '.$this->getTable('config').' ADD action_mark_as_read INT DEFAULT 0');
+ $this->skipIf($configTable->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.');
+
+ $configTable->addColumn('action_mark_as_read', 'integer', [
+ 'default' => 0,
+ ]);
}
/**
*/
public function down(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
-
- $this->addSql('ALTER TABLE '.$this->getTable('config').' DROP action_mark_as_read');
+ $configTable = $schema->getTable($this->getTable('config'));
+ $userTable->dropColumn('action_mark_as_read');
}
}
*/
public function up(Schema $schema)
{
- $this->skipIf($schema->getTable($this->getTable('entry'))->hasColumn('http_status'), 'It seems that you already played this migration.');
+ $entryTable = $schema->getTable($this->getTable('entry'));
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status VARCHAR(3) DEFAULT NULL');
+ $this->skipIf($entryTable->hasColumn('http_status'), 'It seems that you already played this migration.');
+
+ $entryTable->addColumn('http_status', 'string', [
+ 'length' => 3,
+ 'notnull' => false,
+ ]);
}
/**
*/
public function down(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
-
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP http_status');
+ $userTable = $schema->getTable($this->getTable('entry'));
+ $userTable->dropColumn('http_status');
}
}
*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'This up migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
+ $userTable = $schema->getTable($this->getTable('user'));
- $this->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('expired'), 'It seems that you already played this migration.');
+ $this->skipIf(false === $userTable->hasColumn('expired'), 'It seems that you already played this migration.');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired');
+ $userTable->dropColumn('expired');
- $this->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
+ $this->skipIf(false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired');
+ $userTable->dropColumn('credentials_expired');
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD expired tinyint(1) NULL DEFAULT 0');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD credentials_expired tinyint(1) NULL DEFAULT 0');
+ $userTable = $schema->getTable($this->getTable('user'));
+ $userTable->addColumn('expired', 'smallint');
+ $userTable->addColumn('credentials_expired', 'smallint');
}
}