Example #1
0
 /**
  * Adds owner_id field
  *
  * @param Schema $schema
  */
 public static function addOwner(Schema $schema)
 {
     $table = $schema->getTable('orocrm_contactus_request');
     $table->addColumn('owner_id', 'integer', ['notnull' => false]);
     $table->addIndex(['owner_id'], 'IDX_342872E87E3C61F9', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['owner_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
Example #2
0
 /**
  * Add oro_activity_owner foreign keys.
  *
  * @param Schema $schema
  */
 protected static function addOroActivityOwnerForeignKeys(Schema $schema)
 {
     $table = $schema->getTable('oro_activity_owner');
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['user_id'], ['id'], ['onDelete' => null, 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['organization_id'], ['id'], ['onDelete' => null, 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_activity_list'), ['activity_id'], ['id'], ['onDelete' => 'CASCADE', 'onUpdate' => null]);
 }
Example #3
0
 /**
  * Adds organization_id field
  *
  * @param Schema $schema
  */
 public static function addOrganization(Schema $schema)
 {
     $table = $schema->getTable('oro_calendar');
     $table->addColumn('organization_id', 'integer', ['notnull' => false]);
     $table->addIndex(['organization_id'], 'IDX_1D1715132C8A3DE', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['organization_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
 /**
  * @param Schema $schema
  */
 public static function addOwnerFields(Schema $schema)
 {
     $table = $schema->getTable('test_activity');
     $table->addColumn('owner_id', 'integer', ['notnull' => false]);
     $table->addIndex(['owner_id']);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['owner_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
Example #5
0
 /**
  * @param Schema   $schema
  * @param QueryBag $queries
  * @param string   $tableName
  * @param string   $columnName
  * @param string   $type
  *
  * @throws \Exception
  */
 public function changePrimaryKeyType(Schema $schema, QueryBag $queries, $tableName, $columnName, $type)
 {
     $targetColumn = $schema->getTable($tableName)->getColumn($columnName);
     $type = Type::getType($type);
     if ($targetColumn->getType() === $type) {
         return;
     }
     /** @var ForeignKeyConstraint[] $foreignKeys */
     $foreignKeys = [];
     foreach ($schema->getTables() as $table) {
         /** @var ForeignKeyConstraint[] $tableForeignKeys */
         $tableForeignKeys = array_filter($table->getForeignKeys(), function (ForeignKeyConstraint $tableForeignKey) use($tableName, $columnName) {
             if ($tableForeignKey->getForeignTableName() !== $tableName) {
                 return false;
             }
             return $tableForeignKey->getForeignColumns() === [$columnName];
         });
         foreach ($tableForeignKeys as $tableForeignKey) {
             $foreignKeys[$tableForeignKey->getName()] = $tableForeignKey;
             $foreignKeyTableName = $tableForeignKey->getLocalTable()->getName();
             $foreignKeyColumnNames = $tableForeignKey->getLocalColumns();
             $queries->addPreQuery($this->platform->getDropForeignKeySQL($tableForeignKey, $foreignKeyTableName));
             $column = $schema->getTable($foreignKeyTableName)->getColumn(reset($foreignKeyColumnNames));
             if ($column instanceof ExtendColumn) {
                 $column->disableExtendOptions()->setType($type)->enableExtendOptions();
             } else {
                 $column->setType($type);
             }
         }
     }
     $targetColumn->setType($type);
     foreach ($foreignKeys as $foreignKey) {
         $queries->addPostQuery($this->platform->getCreateForeignKeySQL($foreignKey, $foreignKey->getLocalTable()));
     }
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('oro_reminder');
     $table->addColumn('sender_id', 'integer', ['notnull' => false]);
     $table->addIndex(['sender_id'], 'idx_2f4f9f57f624b39d', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['sender_id'], ['id'], ['onUpdate' => null, 'onDelete' => 'SET NULL']);
 }
Example #7
0
 public function down(Schema $schema)
 {
     // remove website creationmode and ismarkedfordeletion column
     $schema->getTable('website')->dropColumn('share');
     $schema->getTable('website')->dropColumn('creationmode');
     $schema->getTable('website')->dropColumn('ismarkedfordeletion');
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('orocrm_magento_cart');
     $table->getColumn('items_qty')->setType(Type::getType('float'));
     $table = $schema->getTable('orocrm_magento_order_items');
     $table->getColumn('qty')->setType(Type::getType('float'));
 }
Example #9
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     /** Generate table orocrm_case_comment **/
     $table = $schema->createTable('orocrm_case_comment');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('case_id', 'integer', ['notnull' => false]);
     $table->addColumn('updated_by_id', 'integer', ['notnull' => false]);
     $table->addColumn('owner_id', 'integer', ['notnull' => false]);
     $table->addColumn('contact_id', 'integer', ['notnull' => false]);
     $table->addColumn('message', 'text', []);
     $table->addColumn('public', 'boolean', ['default' => '0']);
     $table->addColumn('createdAt', 'datetime', []);
     $table->addColumn('updatedAt', 'datetime', ['notnull' => false]);
     $table->setPrimaryKey(['id']);
     $table->addIndex(['case_id'], 'IDX_604C70FBCF10D4F5', []);
     $table->addIndex(['contact_id'], 'IDX_604C70FBE7A1254A', []);
     $table->addIndex(['updated_by_id'], 'FK_604C70FB896DBBDE', []);
     $table->addIndex(['owner_id'], 'IDX_604C70FB7E3C61F9', []);
     /** End of generate table orocrm_case_comment **/
     /** Generate foreign keys for table orocrm_case_comment **/
     $table = $schema->getTable('orocrm_case_comment');
     $table->addForeignKeyConstraint($schema->getTable('orocrm_case'), ['case_id'], ['id'], ['onDelete' => 'CASCADE', 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['updated_by_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['owner_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('orocrm_contact'), ['contact_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
     /** End of generate foreign keys for table orocrm_case_comment **/
 }
 public function down(Schema $schema)
 {
     //start cc_show_instances modifications
     $show_instances_table = $schema->getTable('cc_show_instances');
     $show_instances_table->dropColumn('record');
     $show_instances_table->dropColumn('rebroadcast');
     $show_instances_table->dropColumn('instance_id');
     $show_instances_table->dropColumn('file_id');
     $show_instances_table->dropColumn('soundcloud_id');
     //end cc_show_instances modifications
     //start cc_show_days modifications
     $show_days_table = $schema->getTable('cc_show_days');
     $show_days_table->dropColumn('record');
     //end cc_show_days modifications
     //start cc_show modifications
     $show_table = $schema->getTable('cc_show');
     $show_table->dropColumn('url');
     //end cc_show modifications
     //start cc_schedule modifications
     $schedule_table = $schema->getTable('cc_schedule');
     $playlist_id_col = $schedule_table->getColumn('playlist_id');
     $playlist_id_col->setNotnull(true);
     //end cc_schedule modifications
     //drop cc_show_rebroadcast table
     $schema->dropTable('cc_show_rebroadcast');
     //end drop cc_show_rebroadcast table
 }
Example #11
0
 public static function addOwnerToAttachment(Schema $schema)
 {
     $table = $schema->getTable('oro_attachment');
     $table->addColumn('owner_user_id', 'integer', ['notnull' => false]);
     $table->addIndex(['owner_user_id'], 'IDX_FA0FE0812B18554A', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['owner_user_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
Example #12
0
 /**
  * @param Schema $schema
  */
 protected function modifyOrocrmMagentoCartTable(Schema $schema)
 {
     $table = $schema->getTable('orocrm_magento_cart');
     $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
     $table->addIndex(['data_channel_id'], 'IDX_96661A80BDC09B73', []);
     $table->addForeignKeyConstraint($schema->getTable('orocrm_channel'), ['data_channel_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null], 'FK_96661A80BDC09B73');
 }
Example #13
0
 /**
  * @param Schema $schema
  */
 protected function modifyOrocrmSalesSalesFunnelTable(Schema $schema)
 {
     $table = $schema->getTable('orocrm_sales_funnel');
     $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
     $table->addIndex(['data_channel_id'], 'IDX_E20C7344BDC09B73', []);
     $table->addForeignKeyConstraint($schema->getTable('orocrm_channel'), ['data_channel_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null], 'FK_E20C7344BDC09B73');
 }
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     // this up() migration is auto-generated, please modify it to your needs
     // dtb_category
     $t_dtb_category = $schema->getTable(self::DTB_CATEGORY);
     if ($t_dtb_category->hasColumn('category_name')) {
         $t_dtb_category->changeColumn('category_name', array('NotNull' => true));
     }
     if ($t_dtb_category->hasColumn('rank')) {
         $t_dtb_category->changeColumn('rank', array('NotNull' => true));
     }
     // dtb_class_category
     $t_dtb_class_category = $schema->getTable(self::DTB_CLASS_CATEGORY);
     if ($t_dtb_class_category->hasColumn('name')) {
         $t_dtb_class_category->changeColumn('name', array('NotNull' => true));
     }
     if ($t_dtb_class_category->hasColumn('rank')) {
         $t_dtb_class_category->changeColumn('rank', array('NotNull' => true));
     }
     // dtb_class_name
     $t_dtb_class_name = $schema->getTable(self::DTB_CLASS_NAME);
     if ($t_dtb_class_name->hasColumn('name')) {
         $t_dtb_class_name->changeColumn('name', array('NotNull' => true));
     }
     if ($t_dtb_class_name->hasColumn('rank')) {
         $t_dtb_class_name->changeColumn('rank', array('NotNull' => true));
     }
 }
 /**
  * Add oro_activity_list foreign keys.
  *
  * @param Schema $schema
  */
 protected function addOroActivityListForeignKeys(Schema $schema)
 {
     $table = $schema->getTable('oro_activity_list');
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['user_owner_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['user_editor_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['organization_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('oro_dashboard_widget_state');
     $table->dropColumn('options');
     $table = $schema->getTable('oro_dashboard_widget');
     $table->addColumn('options', 'array', ['comment' => '(DC2Type:array)', 'notnull' => false]);
 }
 /**
  * Generate table oro_reminder
  *
  * @param Schema $schema
  */
 protected function createReminderTable(Schema $schema)
 {
     /** Generate table oro_reminder **/
     $table = $schema->createTable('oro_reminder');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('recipient_id', 'integer', ['notnull' => false]);
     $table->addColumn('subject', 'string', ['length' => 255]);
     $table->addColumn('start_at', 'datetime', []);
     $table->addColumn('expire_at', 'datetime', []);
     $table->addColumn('method', 'string', ['length' => 255]);
     $table->addColumn('interval_number', 'integer', []);
     $table->addColumn('interval_unit', 'string', ['length' => 1]);
     $table->addColumn('state', 'string', ['length' => 32]);
     $table->addColumn('related_entity_id', 'integer', []);
     $table->addColumn('related_entity_classname', 'string', ['length' => 255]);
     $table->addColumn('created_at', 'datetime', []);
     $table->addColumn('updated_at', 'datetime', ['notnull' => false]);
     $table->addColumn('sent_at', 'datetime', ['notnull' => false]);
     $table->addColumn('failure_exception', 'array', ['notnull' => false, 'comment' => '(DC2Type:array)']);
     $table->addColumn('sender_id', 'integer', ['notnull' => false]);
     $table->setPrimaryKey(['id']);
     $table->addIndex(['recipient_id'], 'IDX_2F4F9F57E92F8F78', []);
     $table->addIndex(['state'], 'reminder_state_idx', []);
     $table->addIndex(['sender_id'], 'idx_2f4f9f57f624b39d', []);
     /** End of generate table oro_reminder **/
     /** Generate foreign keys for table oro_reminder **/
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['recipient_id'], ['id'], ['onDelete' => 'CASCADE', 'onUpdate' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['sender_id'], ['id'], ['onUpdate' => null, 'onDelete' => 'SET NULL']);
     /** End of generate foreign keys for table oro_reminder **/
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('orocrm_magento_customer_addr');
     $table->addColumn('related_contact_address_id', 'integer', ['notnull' => false]);
     $table->addUniqueIndex(['related_contact_address_id'], 'UNIQ_1E239D648137CB7B');
     $table->addForeignKeyConstraint($schema->getTable('orocrm_contact_address'), ['related_contact_address_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
 /**
  * Adds owner_id field
  *
  * @param Schema $schema
  */
 public static function addOwner(Schema $schema)
 {
     $table = $schema->getTable('oro_embedded_form');
     $table->addColumn('owner_id', 'integer', ['notnull' => false]);
     $table->addIndex(['owner_id'], 'IDX_F7A34C17E3C61F9', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['owner_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
 /**
  * @param Schema $schema
  */
 public static function enableActivityAssociations(Schema $schema)
 {
     $options = new OroOptions();
     $options->set('activity', 'immutable', false);
     $schema->getTable('orocrm_magento_cart')->addOption(OroOptions::KEY, $options);
     $schema->getTable('orocrm_magento_order')->addOption(OroOptions::KEY, $options);
 }
Example #21
0
 /**
  * @param Schema $schema
  */
 protected function modifycOrocrmContactusRequestTable(Schema $schema)
 {
     $table = $schema->getTable('orocrm_contactus_request');
     $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
     $table->addIndex(['data_channel_id'], 'IDX_342872E8BDC09B73', []);
     $table->addForeignKeyConstraint($schema->getTable('orocrm_channel'), ['data_channel_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null], 'FK_342872E8BDC09B73');
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('orocrm_account');
     $table->addColumn('referred_by_id', 'integer', ['notnull' => false]);
     $table->addIndex(['referred_by_id'], 'IDX_7166D371758C8114', []);
     $table->addForeignKeyConstraint($schema->getTable('orocrm_account'), ['referred_by_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null]);
 }
Example #23
0
 /**
  * Generate foreign keys for table oro_email
  *
  * @param Schema $schema
  */
 public static function addForeignKeys(Schema $schema)
 {
     $table = $schema->getTable('oro_email');
     $table->addForeignKeyConstraint($schema->getTable('oro_email_thread'), ['thread_id'], ['id'], ['onDelete' => null, 'onUpdate' => null]);
     $table = $schema->getTable('oro_email_thread');
     $table->addForeignKeyConstraint($schema->getTable('oro_email'), ['last_unseen_email_id'], ['id'], ['onDelete' => null, 'onUpdate' => null]);
 }
Example #24
0
 /**
  * Adds organization_id field
  *
  * @param Schema $schema
  */
 public static function addOrganizationFields(Schema $schema)
 {
     $table = $schema->getTable('oro_audit');
     $table->addColumn('organization_id', 'integer', ['notnull' => false]);
     $table->addIndex(['organization_id'], 'idx_oro_audit_organization_id', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['organization_id'], ['id'], ['onDelete' => 'SET NULL']);
 }
Example #25
0
 /**
  * @param Schema $schema
  *
  * @throws \Doctrine\DBAL\Schema\SchemaException
  */
 public static function addAttachmentRelation(Schema $schema)
 {
     $table = $schema->getTable('oro_email_attachment');
     $table->addColumn('file_id', 'integer', ['notnull' => false]);
     $table->addUniqueIndex(['file_id'], 'UNIQ_F4427F2393CB796C');
     $table->addForeignKeyConstraint($schema->getTable('oro_attachment_file'), ['file_id'], ['id'], ['onDelete' => 'SET NULL'], 'FK_F4427F2393CB796C');
 }
Example #26
0
 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     // removed field "enabled"
     // added fields "system", "created_at", "updated_at"
     $workflowDefinition = $schema->getTable('oro_workflow_definition');
     $workflowDefinition->dropIndex('oro_workflow_definition_enabled_idx');
     $workflowDefinition->dropColumn('enabled');
     $workflowDefinition->addColumn('system', 'boolean');
     $workflowDefinition->addColumn('created_at', 'datetime');
     $workflowDefinition->addColumn('updated_at', 'datetime');
     // added field "final"
     $workflowStep = $schema->getTable('oro_workflow_step');
     $workflowStep->addColumn('final', 'boolean', array());
     // removed field "closed"
     // added "ON DELETE SET NULL" to workflow step relation "currentStep"
     $workflowItem = $schema->getTable('oro_workflow_item');
     $workflowItem->dropColumn('closed');
     $workflowItem->removeForeignKey('FK_169789AED9BF9B19');
     $workflowItem->addForeignKeyConstraint($workflowStep, array('current_step_id'), array('id'), array('onDelete' => 'SET NULL', 'onUpdate' => null), 'FK_169789AED9BF9B19');
     // added "ON DELETE SET NULL" to workflow step relations "stepFrom" and "stepTo"
     $workflowTransitionLog = $schema->getTable('oro_workflow_transition_log');
     $workflowTransitionLog->removeForeignKey('FK_B3D57B30C8335FE4');
     $workflowTransitionLog->addForeignKeyConstraint($workflowStep, array('step_from_id'), array('id'), array('onDelete' => 'SET NULL', 'onUpdate' => null), 'FK_B3D57B30C8335FE4');
     $workflowTransitionLog->removeForeignKey('FK_B3D57B302C17BD9A');
     $workflowTransitionLog->addForeignKeyConstraint($workflowStep, array('step_to_id'), array('id'), array('onDelete' => 'SET NULL', 'onUpdate' => null), 'FK_B3D57B302C17BD9A');
 }
Example #27
0
 /**
  * Change oro_integration_channel table
  *
  * @param Schema $schema
  */
 public static function modifyChannelTable(Schema $schema)
 {
     $table = $schema->getTable('oro_integration_channel');
     $table->addColumn('default_user_owner_id', 'integer', ['notnull' => false]);
     $table->addIndex(['default_user_owner_id'], 'IDX_55B9B9C5A89019EA', []);
     $table->addForeignKeyConstraint($schema->getTable('oro_user'), ['default_user_owner_id'], ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null], 'FK_55B9B9C5A89019EA');
 }
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->fillActivityTables($queries);
     $this->fillActivityListTables($queries);
     // Remove orocrm_magento_cart_emails
     $table = $schema->getTable('orocrm_magento_cart_emails');
     $table->removeForeignKey('FK_11B0F84B1AD5CDBF');
     $table->removeForeignKey('FK_11B0F84BA832C1C9');
     $schema->dropTable('orocrm_magento_cart_emails');
     // Remove orocrm_magento_cart_calls
     $table = $schema->getTable('orocrm_magento_cart_calls');
     $table->removeForeignKey('FK_83A847751AD5CDBF');
     $table->removeForeignKey('FK_83A8477550A89B2C');
     $schema->dropTable('orocrm_magento_cart_calls');
     // Remove orocrm_magento_order_emails
     $table = $schema->getTable('orocrm_magento_order_emails');
     $table->removeForeignKey('FK_10E2A9508D9F6D38');
     $table->removeForeignKey('FK_10E2A950A832C1C9');
     $schema->dropTable('orocrm_magento_order_emails');
     // Remove orocrm_magento_order_calls
     $table = $schema->getTable('orocrm_magento_order_calls');
     $table->removeForeignKey('FK_A885A3450A89B2C');
     $table->removeForeignKey('FK_A885A348D9F6D38');
     $schema->dropTable('orocrm_magento_order_calls');
 }
 /**
  * Add oro_report foreign keys.
  *
  * @param Schema $schema
  */
 protected function addOroReportForeignKeys(Schema $schema)
 {
     $table = $schema->getTable('oro_report');
     $table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['organization_id'], ['id'], ['onUpdate' => null, 'onDelete' => 'SET NULL']);
     $table->addForeignKeyConstraint($schema->getTable('oro_report_type'), ['type'], ['name'], ['onUpdate' => null, 'onDelete' => null]);
     $table->addForeignKeyConstraint($schema->getTable('oro_business_unit'), ['business_unit_owner_id'], ['id'], ['onUpdate' => null, 'onDelete' => 'SET NULL']);
 }
Example #30
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $integrationTransport = $schema->getTable('oro_integration_transport');
     $integrationTransport->addColumn('admin_url', 'string', ['notnull' => false, 'length' => 255]);
     $cart = $schema->getTable('orocrm_magento_cart');
     $cart->addColumn('status_message', 'string', ['notnull' => false, 'length' => 255]);
 }