From 7c01fd98b3bdd0f2bfeef0c559e3eddb7a10514b Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Tue, 28 Jan 2014 15:45:00 +0100
Subject: [PATCH] Fix: use allowed database types

---
 .../install/mysql/migration/3.5.0-3.6.0.sql   | 27 ++++++++++---------
 .../install/mysql/tables/llx_facture_rec.sql  | 10 +++----
 .../mysql/tables/llx_opensurvey_sondage.sql   |  8 +++---
 3 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
index 4e0b0192d79..36a8f985452 100755
--- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
+++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
@@ -18,15 +18,18 @@
 -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user      WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
 
 ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL;
-ALTER TABLE  llx_opensurvey_sondage ADD COLUMN allow_comments TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 1 AFTER  canedit ;
--- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN survey_link_visible ;
-ALTER TABLE  llx_opensurvey_sondage DROP INDEX  idx_id_sondage_admin ;
--- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN id_sondage_admin ;
--- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN canedit ;
-ALTER TABLE  llx_opensurvey_sondage ADD COLUMN allow_spy TINYINT( 1 ) UNSIGNED NOT NULL AFTER  allow_comments ;
--- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN origin ;
-ALTER TABLE  llx_opensurvey_sondage ADD COLUMN fk_user_creat INT( 11 ) UNSIGNED NOT NULL AFTER  nom_admin ;
-ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN mailsonde  mailsonde TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT  '0';
-ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN titre  titre TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
-ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN date_fin  date_fin DATETIME NOT NULL;
-ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN format  format VARCHAR( 2 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
\ No newline at end of file
+
+ALTER TABLE  llx_opensurvey_sondage ADD COLUMN allow_comments tinyint NOT NULL DEFAULT 1 AFTER canedit;
+-- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN survey_link_visible;
+-- ALTER TABLE  llx_opensurvey_sondage DROP INDEX idx_id_sondage_admin;
+-- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN id_sondage_admin;
+-- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN canedit;
+ALTER TABLE  llx_opensurvey_sondage ADD COLUMN allow_spy tinyint NOT NULL DEFAULT 1 AFTER allow_comments;
+-- ALTER TABLE  llx_opensurvey_sondage DROP COLUMN origin;
+ALTER TABLE  llx_opensurvey_sondage ADD COLUMN fk_user_creat integer NOT NULL AFTER nom_admin;
+ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN mailsonde mailsonde tinyint NOT NULL DEFAULT 0;
+ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN titre titre TEXT NOT NULL;
+ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN date_fin date_fin DATETIME NOT NULL;
+ALTER TABLE  llx_opensurvey_sondage CHANGE COLUMN format format VARCHAR(2) NOT NULL;
+
+ALTER TABLE llx_facture_rec.sql MODIFY COLUMN usenewprice INTEGER DEFAULT 0;
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql
index 0a935a3623d..947a65fa5ff 100644
--- a/htdocs/install/mysql/tables/llx_facture_rec.sql
+++ b/htdocs/install/mysql/tables/llx_facture_rec.sql
@@ -46,11 +46,11 @@ create table llx_facture_rec
   note_private       text,
   note_public        text,
 
-  usenewprice        integer,
+  usenewprice        integer DEFAULT 0,
   frequency          integer,
   unit_frequency     varchar(2) DEFAULT 'd',
-  date_when          datetime DEFAULT NULL,
-  date_last_gen      datetime DEFAULT NULL,
-  nb_gen_done        integer DEFAULT NULL,
-  nb_gen_max         integer DEFAULT NULL
+  date_when          datetime DEFAULT NULL,		-- date for next gen (when an invoice is generated, this field must be updated with next date)
+  date_last_gen      datetime DEFAULT NULL,		-- date for last gen (date with last successfull generation of invoice)
+  nb_gen_done        integer DEFAULT NULL,		-- nb of generation done (when an invoice is generated, this field must incremented)
+  nb_gen_max         integer DEFAULT NULL		-- maximum number of generation
 )ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql
index a8ee5031dc5..d8c3d74571c 100644
--- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql
+++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql
@@ -20,13 +20,13 @@ CREATE TABLE llx_opensurvey_sondage (
        commentaires text,
        mail_admin VARCHAR(128),
        nom_admin VARCHAR(64),
-	   fk_user_creat INT(11) UNSIGNED NOT NULL,
+	   fk_user_creat integer NOT NULL,
        titre TEXT NOT NULL,
        date_fin DATETIME NOT NULL,
        format VARCHAR(2) NOT NULL,
-       mailsonde TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
-       allow_comments TINYINT(1) unsigned NOT NULL DEFAULT 1,
-	   allow_spy TINYINT(1) unsigned NOT NULL DEFAULT 1,
+       mailsonde tinyint NOT NULL DEFAULT 0,
+       allow_comments tinyint NOT NULL DEFAULT 1,
+	   allow_spy tinyint NOT NULL DEFAULT 1,
        tms TIMESTAMP,
 	   sujet TEXT
 ) ENGINE=InnoDB;
\ No newline at end of file
-- 
GitLab