/** * @param Schema $schema */ public function up(Schema $schema) { $em = $this->container->get('doctrine')->getManager(); $uom = new UOM(); $uom->setCode('CBM')->setName('cubic metre'); $em->persist($uom); $em->flush(); $this->addSql("UPDATE shipment SET customer_id = 4 WHERE customer_id IS NULL;"); $this->addSql("ALTER TABLE `shipment_lineitem` DROP FOREIGN KEY `FK_76CF0DF982F83E2`;"); $this->addSql("ALTER TABLE `shipment_lineitem`\tDROP COLUMN `gross_weight_uom`;"); $this->addSql("ALTER TABLE `shipment_lineitem`\tCHANGE COLUMN `net_weight_uom` `weight_uom` INT(10) UNSIGNED NULL DEFAULT NULL AFTER `places_uom`;"); }
/** * @param Schema $schema */ public function up(Schema $schema) { $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); $em = $this->container->get('doctrine')->getManager(); $dataSet = ['CT' => 'Carton', 'PC' => 'Piece', 'UN' => 'Unit', 'MR' => 'Meter', 'GR' => 'Gram', 'KG' => 'Kilogram']; foreach ($dataSet as $k => $v) { $uom = new UOM(); $uom->setCode($k); $uom->setName($v); $em->persist($uom); } $em->flush(); $em->clear(); }