Compare commits

..

No commits in common. "83e1ae3204b3f6103544dda13b3ec1bc5f8953c0" and "45029e0a4c1d12f18acadcdda1edd533e2bc8925" have entirely different histories.

4 changed files with 2 additions and 57 deletions

View file

@ -1,43 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240626182031 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TEMPORARY TABLE __temp__order_item AS SELECT id, food_order_id, name, extras, menu_item_id FROM order_item');
$this->addSql('DROP TABLE order_item');
$this->addSql('CREATE TABLE order_item (id BLOB NOT NULL, food_order_id BLOB DEFAULT NULL, name VARCHAR(255) NOT NULL, extras VARCHAR(255) DEFAULT NULL, menu_item_id BLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_52EA1F09A5D24A7A FOREIGN KEY (food_order_id) REFERENCES food_order (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_52EA1F099AB44FE0 FOREIGN KEY (menu_item_id) REFERENCES menu_item (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO order_item (id, food_order_id, name, extras, menu_item_id) SELECT id, food_order_id, name, extras, menu_item_id FROM __temp__order_item');
$this->addSql('DROP TABLE __temp__order_item');
$this->addSql('CREATE INDEX IDX_52EA1F099AB44FE0 ON order_item (menu_item_id)');
$this->addSql('CREATE INDEX IDX_52EA1F09A5D24A7A ON order_item (food_order_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TEMPORARY TABLE __temp__order_item AS SELECT id, name, extras, food_order_id, menu_item_id FROM order_item');
$this->addSql('DROP TABLE order_item');
$this->addSql('CREATE TABLE order_item (id BLOB NOT NULL, name VARCHAR(255) NOT NULL, extras VARCHAR(255) DEFAULT NULL, food_order_id BLOB DEFAULT NULL, menu_item_id BLOB DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_52EA1F09A5D24A7A FOREIGN KEY (food_order_id) REFERENCES food_order (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_52EA1F099AB44FE0 FOREIGN KEY (menu_item_id) REFERENCES menu_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO order_item (id, name, extras, food_order_id, menu_item_id) SELECT id, name, extras, food_order_id, menu_item_id FROM __temp__order_item');
$this->addSql('DROP TABLE __temp__order_item');
$this->addSql('CREATE INDEX IDX_52EA1F09A5D24A7A ON order_item (food_order_id)');
$this->addSql('CREATE INDEX IDX_52EA1F099AB44FE0 ON order_item (menu_item_id)');
}
}

View file

@ -76,7 +76,6 @@ final class OrderItemController extends AbstractController
$newOrderItem->setFoodOrder($orderItem->getFoodOrder());
$newOrderItem->setName($orderItem->getName());
$newOrderItem->setExtras($orderItem->getExtras());
$newOrderItem->setMenuItem($orderItem->getMenuItem());
$entityManager->persist($newOrderItem);
$entityManager->flush();

View file

@ -28,7 +28,7 @@ class OrderItem
private FoodOrder|null $foodOrder = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
#[ORM\JoinColumn(nullable: true)]
private MenuItem|null $menuItem = null;
public function getId(): Ulid|null

View file

@ -4,7 +4,6 @@ namespace App\Tests\Controller;
use App\Entity\FoodOrder;
use App\Entity\FoodVendor;
use App\Entity\MenuItem;
use App\Entity\OrderItem;
use App\Tests\DbWebTest;
use Override;
@ -15,7 +14,6 @@ final class OrderItemControllerTest extends DbWebTest
{
public FoodVendor $vendor;
public FoodOrder $order;
public Menuitem $menuItem;
private string $path = '/order/item/';
#[Override]
@ -30,12 +28,6 @@ final class OrderItemControllerTest extends DbWebTest
$this->order->setFoodVendor($this->vendor);
$this->manager->persist($this->order);
$this->menuItem = new MenuItem;
$this->menuItem->setName('Testing');
$this->menuItem->setFoodVendor($this->vendor);
$this->manager->persist($this->menuItem);
$this->manager->flush();
}
@ -61,10 +53,8 @@ final class OrderItemControllerTest extends DbWebTest
public function testRemove(): void
{
$fixture = new OrderItem;
$fixture->setName('Testing');
$fixture->setName('Value');
$fixture->setExtras('Value');
$fixture->setMenuItem($this->menuItem);
$fixture->setFoodOrder($this->order);
$this->manager->persist($fixture);
@ -82,7 +72,6 @@ final class OrderItemControllerTest extends DbWebTest
$orderItem->setName('My Title');
$orderItem->setExtras('My Title');
$orderItem->setFoodOrder($this->order);
$orderItem->setMenuItem($this->menuItem);
$this->manager->persist($orderItem);
$this->manager->flush();