From de8e7b2f054f6a7268733fff5c419944c2a4fe8a Mon Sep 17 00:00:00 2001
From: Maxime Leclercq <m.leclercq@monsieurbiz.com>
Date: Tue, 30 Jul 2024 11:32:35 +0200
Subject: [PATCH 1/3] fix: avoid SQL error if we try to delete shop user

---
 src/Migrations/Version20240730093001.php      | 46 +++++++++++++++++++
 .../config/doctrine/OrderHistoryEvent.orm.xml |  4 +-
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 src/Migrations/Version20240730093001.php

diff --git a/src/Migrations/Version20240730093001.php b/src/Migrations/Version20240730093001.php
new file mode 100644
index 0000000..a4b4482
--- /dev/null
+++ b/src/Migrations/Version20240730093001.php
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * This file is part of Monsieur Biz' Order History plugin for Sylius.
+ *
+ * (c) Monsieur Biz <sylius@monsieurbiz.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace MonsieurBiz\SyliusOrderHistoryPlugin\Migrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20240730093001 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('ALTER TABLE monsieurbiz_order_history_event DROP FOREIGN KEY FK_9EA44E026352511C');
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event DROP FOREIGN KEY FK_9EA44E02A45D93BF');
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event ADD CONSTRAINT FK_9EA44E026352511C FOREIGN KEY (admin_user_id) REFERENCES sylius_admin_user (id) ON DELETE SET NULL');
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event ADD CONSTRAINT FK_9EA44E02A45D93BF FOREIGN KEY (shop_user_id) REFERENCES sylius_shop_user (id) ON DELETE CASCADE');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event DROP FOREIGN KEY FK_9EA44E02A45D93BF');
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event DROP FOREIGN KEY FK_9EA44E026352511C');
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event ADD CONSTRAINT FK_9EA44E02A45D93BF FOREIGN KEY (shop_user_id) REFERENCES sylius_shop_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
+        $this->addSql('ALTER TABLE monsieurbiz_order_history_event ADD CONSTRAINT FK_9EA44E026352511C FOREIGN KEY (admin_user_id) REFERENCES sylius_admin_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
+    }
+}
diff --git a/src/Resources/config/doctrine/OrderHistoryEvent.orm.xml b/src/Resources/config/doctrine/OrderHistoryEvent.orm.xml
index a137877..85bc6f1 100644
--- a/src/Resources/config/doctrine/OrderHistoryEvent.orm.xml
+++ b/src/Resources/config/doctrine/OrderHistoryEvent.orm.xml
@@ -32,11 +32,11 @@
         </field>
 
         <many-to-one field="shopUser" target-entity="Sylius\Component\Core\Model\ShopUserInterface">
-            <join-column name="shop_user_id" />
+            <join-column name="shop_user_id" on-delete="CASCADE" />
         </many-to-one>
 
         <many-to-one field="adminUser" target-entity="Sylius\Component\Core\Model\AdminUserInterface">
-            <join-column name="admin_user_id" />
+            <join-column name="admin_user_id" on-delete="SET NULL" />
         </many-to-one>
 
     </mapped-superclass>

From 77204690fafdb5679cc032d7f28392c77f3fe078 Mon Sep 17 00:00:00 2001
From: Maxime Leclercq <m.leclercq@monsieurbiz.com>
Date: Tue, 30 Jul 2024 11:51:58 +0200
Subject: [PATCH 2/3] chore: drop php 8.0 in security test because sf6 doesnt
 patch this

---
 .github/workflows/security.yaml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml
index afeeae8..078e379 100644
--- a/.github/workflows/security.yaml
+++ b/.github/workflows/security.yaml
@@ -5,18 +5,18 @@ on:
     pull_request:
 
 jobs:
-    
+
     security:
-        
+
         name: Security check (PHP ${{ matrix.php }})
-        
+
         runs-on: ubuntu-latest
-        
+
         strategy:
             fail-fast: false
             matrix:
-                php: ['8.0', '8.1']
-        
+                php: ['8.1']
+
         steps:
             - uses: actions/checkout@v3
 

From ba8103a1bb1d8009d16747acc879270e02ca6136 Mon Sep 17 00:00:00 2001
From: Maxime Leclercq <m.leclercq@monsieurbiz.com>
Date: Tue, 30 Jul 2024 11:52:38 +0200
Subject: [PATCH 3/3] fix(setup): remove compose files from sylius standard to
 use our file

---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index 254b87c..9ad4203 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,8 @@ setup_application:
 ${APP_DIR}/docker-compose.yaml:
 	rm -f ${APP_DIR}/docker-compose.yml
 	rm -f ${APP_DIR}/docker-compose.yaml
+	rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker
+	rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker
 	ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
 .PHONY: ${APP_DIR}/docker-compose.yaml