Commit 523eb18d authored by Marc Egger's avatar Marc Egger
Browse files

form as file: rethink update procedure (make simpler, don't delete anything)

parent ac23dadf
Pipeline #4014 failed with stages
in 5 minutes and 39 seconds
......@@ -153,21 +153,20 @@ class DatabaseUpdate {
$this->dbUpdateStatements($old, $new);
if ($old !== false) {
if ($this->db->existTable('Form')) {
// If Form table exists, import all form files so everything is up to date.
// Note: Creates path and exports all forms first if the form directory does not exist.
FormAsFile::importAllForms($this->db, true);
}
$this->db->playSqlFile(__DIR__ . '/../../Sql/formEditor.sql');
FormAsFile::importAllForms($this->db, true); // Note: Creates path and exports all forms first if the form directory does not exist.
if ($old === false) {
// new installation: export native qfq forms + import existing user forms
FormAsFIle::exportAllForms($this->db, false);
FormAsFile::importAllForms($this->db);
// create Form table and export all system forms
$this->db->playSqlFile(__DIR__ . '/../../Sql/formEditor.sql');
FormAsFIle::exportAllForms($this->db);
} else {
// Existing installation: export forms + delete files which were removed since the import above
FormAsFIle::exportAllForms($this->db, true);
// If not, then create Form table and export all system forms
$this->db->playSqlFile(__DIR__ . '/../../Sql/formEditor.sql');
FormAsFIle::exportAllForms($this->db);
// import form files which existed before the new installation
FormAsFile::importAllForms($this->db, true);
}
Logger::logMessage(date('Y.m.d H:i:s ') . ": Updated from QFQ version '$old' to '$new'", Path::absoluteQfqLogFile());
......
......@@ -102,6 +102,17 @@ class SqlQuery {
return array($sql, [$feId]);
}
/**
* @param string $tableName
* @param array|null $columnsToSelect
* @return array
*/
public static function selectInformationSchemaByTableName(string $tableName, array $columnsToSelect = null): array
{
$sql = "SELECT" . self::columnListSelect($columnsToSelect) . "FROM information_schema.tables WHERE `table_name` = '$tableName' LIMIT 1;";
return array($sql, [$tableName]);
}
/**
* @param array|null $columns
* @return string
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment