/** * Modify entity config to exclude currency and currency_precision fields * * @param Schema $schema * @param QueryBag $queries */ public static function updateConfigs(Schema $schema, QueryBag $queries) { $table = $schema->getTable('oro_organization'); $table->dropColumn('currency'); $table->dropColumn('currency_precision'); if ($schema->hasTable('oro_entity_config_index_value') && $schema->hasTable('oro_entity_config_field')) { $queries->addPostQuery('DELETE FROM oro_entity_config_index_value WHERE entity_id IS NULL AND field_id IN( SELECT oecf.id FROM oro_entity_config_field AS oecf WHERE (oecf.field_name = \'precision\' OR oecf.field_name = \'currency\') AND oecf.entity_id = ( SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = \'Oro\\\\Bundle\\\\OrganizationBundle\\\\Entity\\\\Organization\' ) ); DELETE FROM oro_entity_config_field WHERE field_name IN (\'precision\', \'currency\') AND entity_id IN ( SELECT id FROM oro_entity_config WHERE class_name = \'Oro\\\\Bundle\\\\OrganizationBundle\\\\Entity\\\\Organization\' )'); } }
public function testCreateTable() { $schema = new Schema(); $this->assertFalse($schema->hasTable("foo")); $table = $schema->createTable("foo"); $this->assertType('Doctrine\\DBAL\\Schema\\Table', $table); $this->assertEquals("foo", $table->getName()); $this->assertTrue($schema->hasTable("foo")); }
/** * Modify entity config to exclude currency and currency_precision fields * * @param Schema $schema * @param QueryBag $queries */ public static function updateConfigs(Schema $schema, QueryBag $queries) { $table = $schema->getTable('oro_organization'); $table->dropColumn('currency'); $table->dropColumn('currency_precision'); if ($schema->hasTable('oro_entity_config_index_value') && $schema->hasTable('oro_entity_config_field')) { $queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_index_value ' . 'WHERE entity_id IS NULL AND field_id IN (' . 'SELECT oecf.id FROM oro_entity_config_field AS oecf ' . 'WHERE oecf.field_name IN (:field_names) ' . 'AND oecf.entity_id = (' . 'SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = :class_name' . '))', ['field_names' => ['precision', 'currency'], 'class_name' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'], ['field_names' => Connection::PARAM_STR_ARRAY, 'class_name' => Type::STRING])); $queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_field ' . 'WHERE field_name IN (:field_names) ' . 'AND entity_id IN (' . 'SELECT id FROM oro_entity_config WHERE class_name = :class_name' . ')', ['field_names' => ['precision', 'currency'], 'class_name' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'], ['field_names' => Connection::PARAM_STR_ARRAY, 'class_name' => Type::STRING])); } }
/** * Tests the postGenerateSchema() method. */ public function testPostGenerateSchema() { $provider = $this->getProvider(['tl_files' => ['TABLE_FIELDS' => ['path' => "`path` varchar(1022) NOT NULL default ''"]]]); $schema = new Schema(); $event = new GenerateSchemaEventArgs($this->getMock('Doctrine\\ORM\\EntityManagerInterface'), $schema); $this->assertFalse($schema->hasTable('tl_files')); $listener = new DoctrineSchemaListener($provider); $listener->postGenerateSchema($event); $this->assertTrue($schema->hasTable('tl_files')); $this->assertTrue($schema->getTable('tl_files')->hasColumn('path')); }
/** * {@inheritdoc} */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { // The table may already be deleted in a previous // RemoveNamespacedAssets#acceptTable call. Removing Foreign keys that // point to nowhere. if (!$this->schema->hasTable($fkConstraint->getForeignTableName())) { $localTable->removeForeignKey($fkConstraint->getName()); return; } $foreignTable = $this->schema->getTable($fkConstraint->getForeignTableName()); if (!$foreignTable->isInDefaultNamespace($this->schema->getName())) { $localTable->removeForeignKey($fkConstraint->getName()); } }
/** * @return \Doctrine\DBAL\Schema\Table|null */ public static function configureSchema(Schema $schema) { if ($schema->hasTable(static::TABLE)) { return null; } return static::configureTable(); }
/** * {@inheritdoc} */ public function up(Schema $schema, QueryBag $queries) { $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName('Oro\\Bundle\\EmailBundle\\Entity\\Email', ExtendHelper::buildAssociationName('OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer', ActivityScope::ASSOCIATION_KIND), 'OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer'); if (!$schema->hasTable($relationTableName)) { $this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_sales_b2bcustomer'); } }
/** * @param Schema $schema */ public function up(Schema $schema) { // this up() migration is auto-generated, please modify it to your needs if (!$schema->hasTable(self::NAME)) { return true; } $app = \Eccube\Application::getInstance(); $em = $app["orm.em"]; $CsvType = new CsvType(); $CsvType->setId(1); $CsvType->setName('商品CSV'); $CsvType->setRank(3); $em->persist($CsvType); $CsvType = new CsvType(); $CsvType->setId(2); $CsvType->setName('会員CSV'); $CsvType->setRank(4); $em->persist($CsvType); $CsvType = new CsvType(); $CsvType->setId(3); $CsvType->setName('受注CSV'); $CsvType->setRank(1); $em->persist($CsvType); $CsvType = new CsvType(); $CsvType->setId(4); $CsvType->setName('配送CSV'); $CsvType->setRank(2); $em->persist($CsvType); $CsvType = new CsvType(); $CsvType->setId(5); $CsvType->setName('カテゴリCSV'); $CsvType->setRank(5); $em->persist($CsvType); $em->flush(); }
/** * @param Schema $schema * * @throws SkipMigrationException * @throws \Doctrine\DBAL\Schema\SchemaException */ public function preUp(Schema $schema) { if ($schema->hasTable($this->prefix . 'sms_messages')) { throw new SkipMigrationException('Schema includes this migration'); } $this->keys = ['sms_messages' => ['idx' => ['category' => $this->generatePropertyName('sms_messages', 'idx', ['category_id'])], 'fk' => ['category' => $this->generatePropertyName('sms_messages', 'fk', ['category_id'])]], 'sms_message_stats' => ['idx' => ['sms' => $this->generatePropertyName('sms_message_stats', 'idx', ['sms_id']), 'lead' => $this->generatePropertyName('sms_message_stats', 'idx', ['lead_id']), 'list' => $this->generatePropertyName('sms_message_stats', 'idx', ['list_id']), 'ip' => $this->generatePropertyName('sms_message_stats', 'idx', ['ip_id'])], 'fk' => ['sms' => $this->generatePropertyName('sms_message_stats', 'fk', ['sms_id']), 'lead' => $this->generatePropertyName('sms_message_stats', 'fk', ['lead_id']), 'list' => $this->generatePropertyName('sms_message_stats', 'fk', ['list_id']), 'ip' => $this->generatePropertyName('sms_message_stats', 'fk', ['ip_id'])]], 'sms_message_list_xref' => ['idx' => ['sms' => $this->generatePropertyName('sms_message_list_xref', 'idx', ['sms_id']), 'leadlist' => $this->generatePropertyName('sms_message_list_xref', 'idx', ['leadlist_id'])], 'fk' => ['sms' => $this->generatePropertyName('sms_message_list_xref', 'fk', ['sms_id']), 'leadlist' => $this->generatePropertyName('sms_message_list_xref', 'fk', ['leadlist_id'])]]]; }
/** * @param Schema $schema * @param string $table * @throws \Doctrine\DBAL\Schema\SchemaException */ public static function addToSchema(Schema $schema, $table) { if ($schema->hasTable($table)) { $table = $schema->getTable($table); } else { $table = $schema->createTable($table); } if (!$table->hasColumn('event_id')) { $id = $table->addColumn('event_id', 'integer', ['unsigned' => true]); $id->setAutoincrement(true); $table->setPrimaryKey(['event_id']); } if (!$table->hasColumn('aggregate_id')) { $table->addColumn('aggregate_id', 'string', ['length' => 50]); } if (!$table->hasColumn('version')) { $table->addColumn('version', 'integer'); } if (!$table->hasColumn('type')) { $table->addColumn('type', 'string', ['length' => 100]); } if (!$table->hasColumn('payload')) { $table->addColumn('payload', 'text'); } if (!$table->hasColumn('recorded_on')) { $table->addColumn('recorded_on', 'string', ['length' => 50]); } $table->addUniqueIndex(['aggregate_id', 'version']); }
/** * @param Schema $schema * * @return \Doctrine\DBAL\Schema\Table */ public function configureSchema(Schema $schema) { if ($schema->hasTable($this->tableName)) { return null; } return $this->configureTable(); }
/** * {@inheritdoc} */ public function up(Schema $schema, QueryBag $queries) { if ($schema->hasTable('oro_process_definition')) { $queries->addQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_process_definition WHERE name = :name', ['name' => 'email_auto_response'])); $queries->addQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_process_trigger WHERE definition_name = :name', ['name' => 'email_auto_response'])); } }
/** * @param Schema $schema * * @throws SkipMigrationException * @throws \Doctrine\DBAL\Schema\SchemaException */ public function preUp(Schema $schema) { if ($schema->hasTable($this->prefix . 'push_notifications')) { throw new SkipMigrationException('Schema includes this migration'); } $this->keys = array('push_notifications' => array('idx' => array('category' => $this->generatePropertyName('push_notifications', 'idx', array('category_id'))), 'fk' => array('category' => $this->generatePropertyName('push_notifications', 'fk', array('category_id')))), 'push_notification_stats' => array('idx' => array('notification' => $this->generatePropertyName('push_notification_stats', 'idx', array('notification_id')), 'lead' => $this->generatePropertyName('push_notification_stats', 'idx', array('lead_id')), 'list' => $this->generatePropertyName('push_notification_stats', 'idx', array('list_id')), 'ip' => $this->generatePropertyName('push_notification_stats', 'idx', array('ip_id'))), 'fk' => array('notification' => $this->generatePropertyName('push_notification_stats', 'fk', array('notification_id')), 'lead' => $this->generatePropertyName('push_notification_stats', 'fk', array('lead_id')), 'list' => $this->generatePropertyName('push_notification_stats', 'fk', array('list_id')), 'ip' => $this->generatePropertyName('push_notification_stats', 'fk', array('ip_id')))), 'push_ids' => array('idx' => array('lead' => $this->generatePropertyName('push_ids', 'idx', array('lead_id'))), 'fk' => array('lead' => $this->generatePropertyName('push_ids', 'fk', array('lead_id')))), 'push_notification_list_xref' => array('idx' => array('notification' => $this->generatePropertyName('push_notification_list_xref', 'idx', array('notification_id')), 'leadlist' => $this->generatePropertyName('push_notification_list_xref', 'idx', array('leadlist_id'))), 'fk' => array('notification' => $this->generatePropertyName('push_notification_list_xref', 'fk', array('notification_id')), 'leadlist' => $this->generatePropertyName('push_notification_list_xref', 'fk', array('leadlist_id'))))); }
/** * Attributes table was not used in the code anymore so can be removed * * @param Schema $schema */ public function up(Schema $schema) { $prefixedTableName = $this->getTablePrefix() . 'attribute'; if ($schema->hasTable($prefixedTableName)) { $schema->dropTable($prefixedTableName); } }
/** * @param Schema $schema */ protected function oroCrmCreateTaskTable(Schema $schema) { if ($schema->hasTable($this->taskTableName)) { $schema->dropTable($this->taskTableName); } $table = $schema->createTable($this->taskTableName); $table->addColumn('id', 'integer', ['autoincrement' => true]); $table->addColumn('subject', 'string', ['notnull' => false, 'length' => 255]); $table->addColumn('description', 'string', ['notnull' => false, 'length' => 255]); $table->addColumn('due_date', 'datetime'); $table->addColumn('task_priority_name', 'string', ['notnull' => false, 'length' => 32]); $table->addColumn('owner_id', 'integer', ['notnull' => false]); $table->addColumn('related_account_id', 'integer', ['notnull' => false]); $table->addColumn('related_contact_id', 'integer', ['notnull' => false]); $table->addColumn('reporter_id', 'integer', ['notnull' => false]); $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]); $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]); $table->addColumn('createdAt', 'datetime'); $table->addColumn('updatedAt', 'datetime', ['notnull' => false]); $table->setPrimaryKey(['id']); $table->addIndex(['task_priority_name'], 'IDX_814DEE3FD34C1E8E', []); $table->addIndex(['owner_id'], 'IDX_814DEE3F7E3C61F9', []); $table->addIndex(['related_account_id'], 'IDX_814DEE3FE774F01D', []); $table->addIndex(['related_contact_id'], 'IDX_814DEE3FD6204081', []); $table->addIndex(['reporter_id'], 'IDX_814DEE3FE1CFE6F5', []); $table->addIndex(['due_date'], 'task_due_date_idx'); $table->addUniqueIndex(['workflow_item_id'], 'UNIQ_814DEE3F1023C4EE'); $table->addIndex(['workflow_step_id'], 'IDX_814DEE3F71FE882C', []); $this->oroCrmCreateTaskTableForeignKeys($schema); }
/** * {@inheritdoc} */ public function up(Schema $schema, QueryBag $queries) { if (!$schema->hasTable('oro_process_trigger')) { return; } $queries->addQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_process_trigger WHERE definition_name = :name', ['name' => 'convert_mailbox_email_to_case'])); }
/** * @param Schema $schema */ public function down(Schema $schema) { // this down() migration is auto-generated, please modify it to your needs if (!$schema->hasTable(self::NAME)) { return true; } $schema->dropTable(self::NAME); }
/** * @param Schema $schema * * @throws SkipMigrationException * @throws \Doctrine\DBAL\Schema\SchemaException */ public function preUp(Schema $schema) { if ($schema->hasTable($this->prefix . 'lead_utmtags')) { throw new SkipMigrationException('Schema includes this migration'); } $this->leadIdIdx = $this->generatePropertyName('lead_utmtags', 'idx', array('lead_id')); $this->leadIdFk = $this->generatePropertyName('lead_utmtags', 'fk', array('lead_id')); }
/** * @inheritdoc */ public function up(Schema $schema, QueryBag $queries) { if ($schema->hasTable('oro_activity_list')) { $table = $schema->getTable('oro_activity_list'); $table->dropIndex('tmp_al_related_activity_class'); $table->dropIndex('tmp_al_related_activity_id'); } }
/** * @param Schema $schema * * @throws SkipMigrationException * @throws \Doctrine\DBAL\Schema\SchemaException */ public function preUp(Schema $schema) { if ($schema->hasTable($this->prefix . 'channel_url_trackables')) { throw new SkipMigrationException('Schema includes this migration'); } $this->redirectIdx = $this->generatePropertyName($this->prefix . 'channel_url_trackables', 'idx', array('redirect_id')); $this->redirectFk = $this->generatePropertyName($this->prefix . 'channel_url_trackables', 'fk', array('redirect_id')); }
/** * @param Schema $schema * * @throws SkipMigrationException * @throws \Doctrine\DBAL\Schema\SchemaException */ public function preUp(Schema $schema) { if ($schema->hasTable($this->prefix . 'lead_donotcontact')) { throw new SkipMigrationException('Schema includes this migration'); } $this->leadIdIdx = $this->generatePropertyName($this->prefix . 'lead_donotcontact', 'idx', ['lead_id']); $this->leadIdFk = $this->generatePropertyName($this->prefix . 'lead_donotcontact', 'fk', ['lead_id']); }
/** * @param Schema $schema * * @throws SkipMigrationException * @throws \Doctrine\DBAL\Schema\SchemaException */ public function preUp(Schema $schema) { // Test to see if this migration has already been applied if ($schema->hasTable($this->prefix . 'monitoring_leads')) { throw new SkipMigrationException('Schema includes this migration'); } $this->keys = array('monitoring_leads' => array('idx' => array('monitor' => $this->generatePropertyName('monitoring_leads', 'idx', array('monitor_id')), 'lead' => $this->generatePropertyName('monitoring_leads', 'idx', array('lead_id'))), 'fk' => array('monitor' => $this->generatePropertyName('monitoring_leads', 'fk', array('monitor_id')), 'lead' => $this->generatePropertyName('monitoring_leads', 'fk', array('lead_id')))), 'monitoring' => array('idx' => array('category' => $this->generatePropertyName('monitoring', 'idx', array('category_id'))), 'fk' => array('category' => $this->generatePropertyName('monitoring', 'fk', array('category_id')))), 'monitor_post_count' => array('idx' => array('monitor' => $this->generatePropertyName('monitor_post_count', 'idx', array('monitor_id'))), 'fk' => array('monitor' => $this->generatePropertyName('monitor_post_count', 'fk', array('monitor_id'))))); }
/** * @param Schema $schema */ public function up(Schema $schema) { $tablesToDrop = ['LastNotification', 'Event', 'Session', 'PrintingJobConfiguration', 'PrintingJob']; foreach ($tablesToDrop as $table) { if ($schema->hasTable($table)) { $schema->dropTable($table); } } }
public static function removeRoleOwner(Schema $schema, QueryBag $queries) { $table = $schema->getTable('oro_access_role'); if ($table->hasColumn('business_unit_owner_id')) { $queries->addQuery(new UpdateRoleOwnerQuery()); if ($table->hasForeignKey('FK_673F65E759294170')) { $table->removeForeignKey('FK_673F65E759294170'); } if ($table->hasIndex('IDX_F82840BC59294170')) { $table->dropIndex('IDX_F82840BC59294170'); } $table->dropColumn('business_unit_owner_id'); if ($schema->hasTable('oro_entity_config_index_value') && $schema->hasTable('oro_entity_config_field')) { $queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_index_value ' . 'WHERE entity_id IS NULL AND field_id IN (' . 'SELECT oecf.id FROM oro_entity_config_field AS oecf ' . 'WHERE oecf.field_name = :field_name ' . 'AND oecf.entity_id IN (' . 'SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = :class_name' . '))', ['field_name' => 'owner', 'class_name' => 'Oro\\Bundle\\UserBundle\\Entity\\Role'], ['field_name' => 'string', 'class_name' => 'string'])); $queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_field ' . 'WHERE field_name = :field_name ' . 'AND entity_id IN (' . 'SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = :class_name' . ')', ['field_name' => 'owner', 'class_name' => 'Oro\\Bundle\\UserBundle\\Entity\\Role'], ['field_name' => 'string', 'class_name' => 'string'])); } } }
/** * @param Schema $schema */ public function up(Schema $schema) { $tablesToDrop = array("LastNotification", "Event", "Session", "PrintingJobConfiguration", "PrintingJob"); foreach ($tablesToDrop as $table) { if ($schema->hasTable($table)) { $schema->dropTable($table); } } }
/** * @param Schema $schema */ public function up(Schema $schema) { $tableName = 'dtb_session'; if ($schema->hasTable($tableName)) { return; } $pdoSessionHandler = new PdoSessionHandler($this->connection->getWrappedConnection(), array('db_table' => $tableName)); $pdoSessionHandler->createTable(); }
/** * @inheritdoc */ public function up(Schema $schema, QueryBag $queries) { if ($schema->hasTable('oro_activity_list')) { $table = $schema->getTable('oro_activity_list'); $table->addIndex(['related_activity_class'], 'tmp_al_related_activity_class'); $table->addIndex(['related_activity_id'], 'tmp_al_related_activity_id'); $queries->addQuery(new UpdateDateActivityListQuery()); } }
protected function getInstalledVersion(Schema $schema) { if ($schema->hasTable('fusio_meta')) { $version = $this->connection->fetchColumn('SELECT version FROM fusio_meta ORDER BY installDate DESC, id DESC LIMIT 1'); if (!empty($version)) { return $version; } } return null; }
/** * Migrate up. * * @param Schema $schema */ public function up(Schema $schema) { if (!$schema->hasTable('orm_avisota_message_content')) { return; } $table = $schema->getTable('orm_avisota_message_content'); if ($table->hasColumn('eventIdWithTimestamp')) { $this->migrateFromStringToArray('eventIdWithTimestamp'); } }
/** * @param Schema $schema */ public function up(Schema $schema) { if ($schema->hasTable('c_student_publication')) { $this->addSql('ALTER TABLE c_student_publication ADD url_correction VARCHAR(255) DEFAULT NULL'); $this->addSql('ALTER TABLE c_student_publication ADD title_correction VARCHAR(255) DEFAULT NULL'); if (!$schema->getTable('c_student_publication')->hasColumn('document_id')) { $this->addSql('ALTER TABLE c_student_publication ADD document_id INT NOT NULL'); } } }