private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') {
- $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" ADD uuid UUID DEFAULT NULL');
- } else {
- $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" ADD uuid LONGTEXT DEFAULT NULL');
- }
+ $entryTable = $schema->getTable($this->getTable('entry'));
- $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('share_public', '1', 'entry')");
+ $this->skipIf($entryTable->hasColumn('uuid'), 'It seems that you already played this migration.');
+
+ $entryTable->addColumn('uuid', 'guid', [
+ 'notnull' => false,
+ ]);
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')");
}
/**
*/
public function down(Schema $schema)
{
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
+ $entryTable = $schema->getTable($this->getTable('entry'));
+ $entryTable->dropColumn('uuid');
- $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" DROP uuid');
- $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'share_public'");
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'");
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- switch ($this->connection->getDatabasePlatform()->getName()) {
- case 'sqlite':
- $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext DEFAULT NULL');
- break;
-
- case 'mysql':
- $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL');
- break;
-
- case 'postgresql':
- $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name text DEFAULT NULL');
- }
+ $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
+ $this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.');
+
+ $clientsTable->addColumn('name', 'blob');
}
/**
*/
public function down(Schema $schema)
{
- $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
-
- $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' DROP COLUMN name');
+ $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
+ $clientsTable->dropColumn('name');
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_redis\', \'0\', \'import\')');
- $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')');
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
}
/**
*/
public function down(Schema $schema)
{
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';");
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';");
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql('ALTER TABLE "'.$this->getTable('config').'" ADD pocket_consumer_key VARCHAR(255) DEFAULT NULL');
- $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'pocket_consumer_key';");
+ $configTable = $schema->getTable($this->getTable('config'));
+
+ $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.');
+
+ $configTable->addColumn('pocket_consumer_key', 'string');
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';");
}
/**
*/
public function down(Schema $schema)
{
- $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
-
- $this->addSql('ALTER TABLE "'.$this->getTable('config').'" DROP pocket_consumer_key');
- $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
+ $configTable = $schema->getTable($this->getTable('config'));
+ $configTable->dropColumn('pocket_consumer_key');
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
$this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
$this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
-
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
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->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');
+ $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
+
+ $clientsTable->addColumn('user_id', 'integer');
+
+ $clientsTable->addForeignKeyConstraint(
+ $this->getTable('user'),
+ ['user_id'],
+ ['id'],
+ ['onDelete' => 'CASCADE']
+ );
}
/**
*/
public function down(Schema $schema)
{
-
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
+ $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
}
/**
*/
public function down(Schema $schema)
{
- $this->abortIf($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';");
+ $this->addSql('DELETE FROM "'.$this->getTable('craue_config_setting')."\" WHERE name = 'download_images_enabled';");
}
}
*/
private $container;
+ private $indexName = 'IDX_entry_created_at';
+
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
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'));
+ $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
+
+ $entryTable->addIndex(['created_at'], $this->indexName);
}
/**
*/
public function down(Schema $schema)
{
+ $entryTable = $schema->getTable($this->getTable('entry'));
+ $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
+ $entryTable->dropIndex($this->indexName);
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql('ALTER TABLE '.$this->getTable('config').' ADD action_mark_as_read INT DEFAULT 0');
+ $configTable = $schema->getTable($this->getTable('config'));
+
+ $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->abortIf($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');
}
}
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
- $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';");
- $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';");
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';");
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';");
}
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
- * Add http_status in `entry_table`
+ * Add http_status in `entry_table`.
*/
class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface
{
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status VARCHAR(3) DEFAULT NULL');
+ $entryTable = $schema->getTable($this->getTable('entry'));
+
+ $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->abortIf($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');
}
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
- * Add the restricted_access internal setting for articles with paywall
+ * Add the restricted_access internal setting for articles with paywall.
*/
class Version20161122144743 extends AbstractMigration implements ContainerAwareInterface
{
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
+ $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';");
+ $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';");
}
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
- * Methods and properties removed from `FOS\UserBundle\Model\User`
+ * Methods and properties removed from `FOS\UserBundle\Model\User`.
*
* - `$expired`
* - `$credentialsExpired`
private function getTable($tableName)
{
- return $this->container->getParameter('database_table_prefix') . $tableName;
+ return $this->container->getParameter('database_table_prefix').$tableName;
}
/**
*/
public function up(Schema $schema)
{
- $this->abortIf($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->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired');
+ $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
+
+ $userTable->dropColumn('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');
}
}