@@ -165,6 +165,7 @@ public function applyUpdates(): bool
165165 $ this ->applyUpdates400Alpha2 ();
166166 $ this ->applyUpdates400Alpha3 ();
167167 $ this ->applyUpdates400Beta2 ();
168+ $ this ->applyUpdates405 ();
168169
169170 // Optimize the tables
170171 $ this ->optimizeTables ();
@@ -860,6 +861,67 @@ private function applyUpdates400Beta2(): void
860861 }
861862 }
862863
864+ private function applyUpdates405 (): void
865+ {
866+ if (version_compare ($ this ->version , '4.0.5 ' , '< ' )) {
867+ switch (Database::getType ()) {
868+ case 'mysqli ' :
869+ $ this ->queries [] = sprintf (
870+ 'ALTER TABLE %sfaqforms CHANGE input_label input_label VARCHAR(500) NOT NULL ' ,
871+ Database::getTablePrefix ()
872+ );
873+ break ;
874+ case 'pgsql ' :
875+ $ this ->queries [] = sprintf (
876+ 'ALTER TABLE %sfaqforms ALTER COLUMN input_label TYPE VARCHAR(500) ' ,
877+ Database::getTablePrefix ()
878+ );
879+ $ this ->queries [] = sprintf (
880+ 'ALTER TABLE %sfaqforms ALTER COLUMN input_label SET NOT NULL ' ,
881+ Database::getTablePrefix ()
882+ );
883+ break ;
884+ case 'sqlite3 ' :
885+ $ this ->queries [] = sprintf (
886+ 'ALTER TABLE %sfaqforms RENAME TO %sfaqforms_old ' ,
887+ Database::getTablePrefix (),
888+ Database::getTablePrefix ()
889+ );
890+ $ this ->queries [] = sprintf (
891+ 'CREATE TABLE %sfaqforms (
892+ form_id INTEGER NOT NULL,
893+ input_id INTEGER NOT NULL,
894+ input_type VARCHAR(1000) NOT NULL,
895+ input_label VARCHAR(500) NOT NULL,
896+ input_active INTEGER NOT NULL,
897+ input_required INTEGER NOT NULL,
898+ input_lang VARCHAR(11) NOT NULL
899+ ) ' ,
900+ Database::getTablePrefix ()
901+ );
902+ $ this ->queries [] = sprintf (
903+ 'INSERT INTO %sfaqforms
904+ SELECT
905+ form_id, input_id, input_type, input_label, input_active, input_required, input_lang
906+ FROM %sfaqforms_old ' ,
907+ Database::getTablePrefix (),
908+ Database::getTablePrefix ()
909+ );
910+ $ this ->queries [] = sprintf (
911+ 'DROP TABLE %sfaqforms_old; ' ,
912+ Database::getTablePrefix ()
913+ );
914+ break ;
915+ case 'sqlsrv ' :
916+ $ this ->queries [] = sprintf (
917+ 'ALTER TABLE %sfaqforms ALTER COLUMN input_label NVARCHAR(500) NOT NULL ' ,
918+ Database::getTablePrefix ()
919+ );
920+ break ;
921+ }
922+ }
923+ }
924+
863925 private function updateVersion (): void
864926 {
865927 $ this ->configuration ->update (['main.currentApiVersion ' => System::getApiVersion ()]);
0 commit comments