From 70f5f157675915b1fb2c6957543d836c7810e86d Mon Sep 17 00:00:00 2001
From: Bastien Le Querrec <blq@laquadrature.net>
Date: Mon, 9 Nov 2020 20:34:38 +0100
Subject: [PATCH] add migration to add default values

b92f0d08eaeeacdcc993f3575a6f167c66469531 added default values to pass
strict SQL mode, but migrations were missing.

Had to use raw SQL queries because phinx does not support our structure.
---
 .../20201109174049_add_default_values.php     | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 db/migrations/20201109174049_add_default_values.php

diff --git a/db/migrations/20201109174049_add_default_values.php b/db/migrations/20201109174049_add_default_values.php
new file mode 100644
index 0000000..98ee9c8
--- /dev/null
+++ b/db/migrations/20201109174049_add_default_values.php
@@ -0,0 +1,30 @@
+<?php
+
+use Phinx\Migration\AbstractMigration;
+
+class AddDefaultValues extends AbstractMigration
+{
+    public function up()
+    {
+        $this->adapter->execute("ALTER TABLE contreparties ALTER datec SET DEFAULT '0000-00-00 00:00:00';");
+        $this->adapter->execute("ALTER TABLE contreparties ALTER commentaire SET DEFAULT '';");
+
+        $this->adapter->execute("ALTER TABLE dons ALTER datec SET DEFAULT '0000-00-00 00:00:00';");
+        $this->adapter->execute("ALTER TABLE dons ALTER cadeau SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER abo SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER taille SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER public SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER pdf SET DEFAULT \"\";");
+        $this->adapter->execute("ALTER TABLE dons ALTER decimale SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER datee SET DEFAULT '0000-00-00 00:00:00';");
+        $this->adapter->execute("ALTER TABLE dons ALTER pi_x SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER pi_y SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE dons ALTER hash SET DEFAULT \"\";");
+        $this->adapter->execute("ALTER TABLE dons ALTER taille_h SET DEFAULT '0';");
+
+        $this->adapter->execute("ALTER TABLE users ALTER total SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE users ALTER cumul SET DEFAULT '0';");
+        $this->adapter->execute("ALTER TABLE users ALTER pseudo SET DEFAULT \"\";");
+        $this->adapter->execute("ALTER TABLE users ALTER commentaire SET DEFAULT \"\";");
+    }
+}
-- 
GitLab