From 333105b852e96d5eaa76e46a8e19fcf79d32ab6f Mon Sep 17 00:00:00 2001
From: Patrick Barroca <pbarroca@afi-sa.fr>
Date: Wed, 17 Mar 2021 16:05:06 +0100
Subject: [PATCH] hotline #130362 : fix session_activity.date_limite_debut
 nullability

---
 VERSIONS_HOTLINE/130362             |  1 +
 cosmogramme/sql/patch/patch_405.php |  6 ++++++
 tests/db/UpgradeDBTest.php          | 15 +++++++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 VERSIONS_HOTLINE/130362
 create mode 100644 cosmogramme/sql/patch/patch_405.php

diff --git a/VERSIONS_HOTLINE/130362 b/VERSIONS_HOTLINE/130362
new file mode 100644
index 00000000000..41a923b3ed1
--- /dev/null
+++ b/VERSIONS_HOTLINE/130362
@@ -0,0 +1 @@
+ - ticket #130362 : Activités : Correction d'une erreur lorsque la date de début d'inscription n'était pas renseignée.
\ No newline at end of file
diff --git a/cosmogramme/sql/patch/patch_405.php b/cosmogramme/sql/patch/patch_405.php
new file mode 100644
index 00000000000..9253c42e78f
--- /dev/null
+++ b/cosmogramme/sql/patch/patch_405.php
@@ -0,0 +1,6 @@
+<?php
+$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
+
+try {
+  $adapter->query('ALTER TABLE `session_activity` CHANGE `date_limite_debut` `date_limite_debut` date null');
+} catch(Exception $e) {}
diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php
index c87944fd38b..a8f33109dcc 100644
--- a/tests/db/UpgradeDBTest.php
+++ b/tests/db/UpgradeDBTest.php
@@ -3707,4 +3707,19 @@ class UpgradeDB_404_Test extends UpgradeDBTestCase {
   public function sessionActivityShouldContainsColumnDateLimiteFinAsDate() {
     $this->assertFieldType('session_activity', 'date_limite_fin', 'date');
   }
+}
+
+
+
+
+class UpgradeDB_405_Test extends UpgradeDBTestCase {
+  public function prepare() {
+    $this->silentQuery('ALTER TABLE `session_activity` CHANGE `date_limite_debut` `date_limite_debut` date NOT NULL');
+  }
+
+
+  /** @test */
+  public function sessionActivityDateLimiteDebutShouldBeNullable() {
+    $this->assertFieldNullable('session_activity', 'date_limite_debut');
+  }
 }
\ No newline at end of file
-- 
GitLab