Upgrade Schema includes Data Types by default

- Change the label to Database Schema
- Update the description to say tables, columns and data types
- upgrade.php --schema
  - Includes data types by default
  - Remove --types from upgrade.php
- command line upgrade --interactive
  - Option 2 schema
  - Includes data types by default
This commit is contained in:
markjcrane
2025-11-18 20:19:04 -07:00
parent acbddb2a4d
commit 0ea256fce8
6 changed files with 119 additions and 171 deletions

View File

@@ -567,32 +567,32 @@ $text['label-optional_apps']['zh-cn'] = "可选应用程序";
$text['label-optional_apps']['ja-jp'] = "オプションのアプリ";
$text['label-optional_apps']['ko-kr'] = "선택적 앱";
$text['label-upgrade_schema']['en-us'] = "Schema";
$text['label-upgrade_schema']['en-gb'] = "Schema";
$text['label-upgrade_schema']['ar-eg'] = "مخطط";
$text['label-upgrade_schema']['de-at'] = "Schema";
$text['label-upgrade_schema']['de-ch'] = "Schema";
$text['label-upgrade_schema']['de-de'] = "Schema";
$text['label-upgrade_schema']['el-gr'] = "Σχήμα";
$text['label-upgrade_schema']['es-cl'] = "Esquema";
$text['label-upgrade_schema']['es-mx'] = "Esquema";
$text['label-upgrade_schema']['fr-ca'] = "Schéma";
$text['label-upgrade_schema']['fr-fr'] = "Schéma";
$text['label-upgrade_schema']['he-il'] = "סכֵימָה";
$text['label-upgrade_schema']['it-it'] = "Schema";
$text['label-upgrade_schema']['ka-ge'] = "სქემა";
$text['label-upgrade_schema']['nl-nl'] = "Schema";
$text['label-upgrade_schema']['pl-pl'] = "Schemat";
$text['label-upgrade_schema']['pt-br'] = "Esquema";
$text['label-upgrade_schema']['pt-pt'] = "Esquema";
$text['label-upgrade_schema']['ro-ro'] = "Schemă";
$text['label-upgrade_schema']['ru-ru'] = "Схема";
$text['label-upgrade_schema']['sv-se'] = "Schema";
$text['label-upgrade_schema']['uk-ua'] = "Схема";
$text['label-upgrade_schema']['tr-tr'] = "Şema";
$text['label-upgrade_schema']['zh-cn'] = "架构";
$text['label-upgrade_schema']['ja-jp'] = "スキーマ";
$text['label-upgrade_schema']['ko-kr'] = "개요";
$text['label-upgrade_schema']['en-us'] = "Database Schema";
$text['label-upgrade_schema']['en-gb'] = "Database Schema";
$text['label-upgrade_schema']['ar-eg'] = "مخطط قاعدة البيانات";
$text['label-upgrade_schema']['de-at'] = "Datenbankschema";
$text['label-upgrade_schema']['de-ch'] = "Datenbankschema";
$text['label-upgrade_schema']['de-de'] = "Datenbankschema";
$text['label-upgrade_schema']['el-gr'] = "Σχήμα βάσης δεδομένων";
$text['label-upgrade_schema']['es-cl'] = "Esquema de base de datos";
$text['label-upgrade_schema']['es-mx'] = "Esquema de base de datos";
$text['label-upgrade_schema']['fr-ca'] = "Schéma de base de données";
$text['label-upgrade_schema']['fr-fr'] = "Schéma de base de données";
$text['label-upgrade_schema']['he-il'] = "схемת מסד הנתונים";
$text['label-upgrade_schema']['it-it'] = "Schema del database";
$text['label-upgrade_schema']['ka-ge'] = "მონაცემთა ბაზის სქემა";
$text['label-upgrade_schema']['nl-nl'] = "Databaseschema";
$text['label-upgrade_schema']['pl-pl'] = "Schemat bazy danych";
$text['label-upgrade_schema']['pt-br'] = "Esquema do banco de dados";
$text['label-upgrade_schema']['pt-pt'] = "Esquema da base de dados";
$text['label-upgrade_schema']['ro-ro'] = "Schema bazei de date";
$text['label-upgrade_schema']['ru-ru'] = "Схема базы данных";
$text['label-upgrade_schema']['sv-se'] = "Databasschema";
$text['label-upgrade_schema']['uk-ua'] = "Схема бази даних";
$text['label-upgrade_schema']['tr-tr'] = "Veritabanı şeması";
$text['label-upgrade_schema']['zh-cn'] = "数据库架构";
$text['label-upgrade_schema']['ja-jp'] = "データベーススキーマ";
$text['label-upgrade_schema']['ko-kr'] = "데이터베이스 스키마";
$text['label-upgrade_permissions']['en-us'] = "Group Permissions";
$text['label-upgrade_permissions']['en-gb'] = "Group Permissions";
@@ -1269,32 +1269,32 @@ $text['description-update_all_source_files']['zh-cn'] = "更新所有源文件
$text['description-update_all_source_files']['ja-jp'] = "すべてのソースファイルを更新します。";
$text['description-update_all_source_files']['ko-kr'] = "모든 소스 파일을 업데이트합니다.";
$text['description-upgrade_schema']['en-us'] = "Check the table and field structure.";
$text['description-upgrade_schema']['en-gb'] = "Check the table and field structure.";
$text['description-upgrade_schema']['ar-eg'] = "تحقق من هيكل الجدول والحقول.";
$text['description-upgrade_schema']['de-at'] = "Überprüfen Sie die Tabellen- und Feldstruktur.";
$text['description-upgrade_schema']['de-ch'] = "Überprüfen Sie die Tabellen- und Feldstruktur.";
$text['description-upgrade_schema']['de-de'] = "Überprüfen Sie die Tabellen- und Feldstruktur.";
$text['description-upgrade_schema']['el-gr'] = "Ελέγξτε τη δομή του πίνακα και των πεδίων.";
$text['description-upgrade_schema']['es-cl'] = "Verifique la estructura de la tabla y los campos.";
$text['description-upgrade_schema']['es-mx'] = "Verifique la estructura de la tabla y los campos.";
$text['description-upgrade_schema']['fr-ca'] = "Vérifiez la structure du tableau et des champs.";
$text['description-upgrade_schema']['fr-fr'] = "Vérifiez la structure du tableau et des champs.";
$text['description-upgrade_schema']['he-il'] = "تحقق מבני הטבלה והשדות.";
$text['description-upgrade_schema']['it-it'] = "Controlla la struttura della tabella e dei campi.";
$text['description-upgrade_schema']['ka-ge'] = "შეამოწმეთ ცხრილის და ველებსტрукტურა.";
$text['description-upgrade_schema']['nl-nl'] = "Controleer de tabel- en veldstructuur.";
$text['description-upgrade_schema']['pl-pl'] = "Sprawdź strukturę tabeli i pól.";
$text['description-upgrade_schema']['pt-br'] = "Verifique a estrutura da tabela e dos campos.";
$text['description-upgrade_schema']['pt-pt'] = "Verifique a estrutura da tabela e dos campos.";
$text['description-upgrade_schema']['ro-ro'] = "Verificați structura tabelei și a câmpurilor.";
$text['description-upgrade_schema']['ru-ru'] = "Проверьте структуру таблицы и полей.";
$text['description-upgrade_schema']['sv-se'] = "Kontrollera tabellens och fälten struktur.";
$text['description-upgrade_schema']['uk-ua'] = "Перевірте структуру таблиці та полів.";
$text['description-upgrade_schema']['tr-tr'] = "Tablo ve alan yapısını kontrol edin.";
$text['description-upgrade_schema']['zh-cn'] = "检查表和字段结构";
$text['description-upgrade_schema']['ja-jp'] = "テーブルとフィールドの構造を確認してください。";
$text['description-upgrade_schema']['ko-kr'] = "테이블 및 필드 구조를 확인하세요.";;
$text['description-upgrade_schema']['en-us'] = "Update the tables, columns, and data types.";
$text['description-upgrade_schema']['en-gb'] = "Update the tables, columns, and data types.";
$text['description-upgrade_schema']['ar-eg'] = "تحديث الجداول والأعمدة وأنواع البيانات.";
$text['description-upgrade_schema']['de-at'] = "Aktualisieren Sie die Tabellen, Spalten und Datentypen.";
$text['description-upgrade_schema']['de-ch'] = "Aktualisieren Sie die Tabellen, Spalten und Datentypen.";
$text['description-upgrade_schema']['de-de'] = "Aktualisieren Sie die Tabellen, Spalten und Datentypen.";
$text['description-upgrade_schema']['el-gr'] = "Ενημερώστε τους πίνακες, τις στήλες και τους τύπους δεδομένων.";
$text['description-upgrade_schema']['es-cl'] = "Actualice las tablas, columnas y tipos de datos.";
$text['description-upgrade_schema']['es-mx'] = "Actualice las tablas, columnas y tipos de datos.";
$text['description-upgrade_schema']['fr-ca'] = "Mettez à jour les tables, colonnes et types de données.";
$text['description-upgrade_schema']['fr-fr'] = "Mettez à jour les tables, colonnes et types de données.";
$text['description-upgrade_schema']['he-il'] = "עדכן את הטבלאות והстעורים وأنטייפי данных.";
$text['description-upgrade_schema']['it-it'] = "Aggiorna le tabelle, le colonne e i tipi di dati.";
$text['description-upgrade_schema']['ka-ge'] = "განახლეთ ცხრილებს, ველებს და მონაცემთა ტიპებს.";
$text['description-upgrade_schema']['nl-nl'] = "Update de tabellen, kolommen en gegevenstypen.";
$text['description-upgrade_schema']['pl-pl'] = "Zaktualizuj tabele, kolumny i typy danych.";
$text['description-upgrade_schema']['pt-br'] = "Atualize as tabelas, colunas e tipos de dados.";
$text['description-upgrade_schema']['pt-pt'] = "Atualize as tabelas, colunas e tipos de dados.";
$text['description-upgrade_schema']['ro-ro'] = "Actualizați tabelele, coloanele și tipurile de date.";
$text['description-upgrade_schema']['ru-ru'] = "Обновите таблицы, столбцы и типы данных.";
$text['description-upgrade_schema']['sv-se'] = "Uppdatera tabellerna, kolumnerna och datatyperna.";
$text['description-upgrade_schema']['uk-ua'] = "Оновіть таблиці, стовпці та типи даних.";
$text['description-upgrade_schema']['tr-tr'] = "Tabloları, sütunları ve veri türlerini güncelleyin.";
$text['description-upgrade_schema']['zh-cn'] = "更新表、列和数据类型";
$text['description-upgrade_schema']['ja-jp'] = "テーブル、カラム、およびデータ型を更新してください。";
$text['description-upgrade_schema']['ko-kr'] = "테이블, 열 및 데이터 유형을 업데이트하세요.";
$text['description-upgrade_permissions']['en-us'] = "Restore default group permissions.";
$text['description-upgrade_permissions']['en-gb'] = "Restore default group permissions.";

View File

@@ -149,9 +149,6 @@
//load an array of the database schema and compare it with the active database
if (!empty($action["upgrade_schema"]) && permission_exists("upgrade_schema")) {
$obj = new schema(['database' => $database]);
if (isset($action["data_types"]) && $action["data_types"] == 'true') {
$obj->data_types = true;
}
$_SESSION["response"]["schema"] = $obj->schema("html");
message::add($text['message-upgrade_schema'], null, $message_timeout);
}
@@ -369,29 +366,16 @@
if (permission_exists("upgrade_schema")) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr onclick=\"document.getElementById('do_schema').checked = !document.getElementById('do_schema').checked; (!document.getElementById('do_schema').checked ? $('#do_data_types').prop('checked', false) : null); $('#tr_data_types').slideToggle('fast');\">\n";
echo "<tr onclick=\"document.getElementById('do_schema').checked = !document.getElementById('do_schema').checked;\">\n";
echo " <td width='30%' class='vncellreq' style='vertical-align: middle;'>\n";
echo " <div style='".$step_container_style."'><span style='".$step_number_style."'>".$step."</span></div>";
echo " <div class='mt-1'>".$text['label-upgrade_schema']."</div>\n";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
echo " <input type='checkbox' name='action[upgrade_schema]' id='do_schema' value='1' onclick=\"event.stopPropagation(); $('#tr_data_types').slideToggle('fast'); (!document.getElementById('do_schema').checked ? $('#do_data_types').prop('checked', false) : null);\"> &nbsp;".$text['description-upgrade_schema']."\n";
echo " <input type='checkbox' name='action[upgrade_schema]' id='do_schema' value='1' onclick=\"event.stopPropagation();\"> &nbsp;".$text['description-upgrade_schema']."\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<div id='tr_data_types' style='display: none;'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr onclick=\"document.getElementById('do_data_types').checked = !document.getElementById('do_data_types').checked;\">\n";
echo " <td width='30%' class='vncell' style='vertical-align: middle;'>\n";
echo " ".$text['label-upgrade_data_types'];
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
echo " <input type='checkbox' name='action[data_types]' id='do_data_types' value='true' onclick=\"event.stopPropagation();\"> &nbsp;".$text['description-upgrade_data_types']."\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
$step++;
}

View File

@@ -204,8 +204,7 @@
echo " -v --version Show the version.\n";
echo " -n --main Update the main application.\n";
echo " -o --optional Update the optional applications.\n";
echo " -s --schema Check the table and field structure.\n";
echo " -t --types Updates field data types as needed.\n";
echo " -s --schema Update the database tables, columns and data types.\n";
echo " -d --defaults Restore application defaults.\n";
echo " -m --menu [default|list] Restore menu default or show the menu list\n";
echo " -p --permissions Restore default file and group permissions.\n";
@@ -222,7 +221,7 @@
echo software::version()."\n";
}
//upgrade schema and/or data_types
//upgrade the schema and data_types
if ($upgrade_type == 'schema' or $upgrade_type == '-s' or $upgrade_type == '--schema') {
//send a message to the console
if ($display_type === 'text') {
@@ -230,9 +229,6 @@
}
//get the database schema put it into an array then compare and update the database as needed.
if (isset($argv[2]) && $argv[2] == 'data_types') {
$schema->data_types = true;
}
$response = $schema->schema($format ?? '');
if ($display_type === 'text') {
foreach(explode("\n", $response) as $row) {
@@ -241,22 +237,6 @@
}
}
//upgrade schema and/or data_types
if ($upgrade_type == 'data_types' or $upgrade_type == '-t' or $upgrade_type == '--types') {
//send a message to the console
if ($display_type === 'text') {
echo "[ Update ] Table, field structure and data types.\n";
}
//get the database schema put it into an array then compare and update the database as needed.
$schema->data_types = true;
$response = $schema->schema($format ?? '');
if ($display_type === 'text') {
foreach(explode("\n", $response) as $row) {
echo " ".trim($row)."\n";
}
}
}
//run all application defaults - add missing defaults
if ($upgrade_type == 'defaults' or $upgrade_type == '-d' or $upgrade_type == '--defaults') {

View File

@@ -77,9 +77,7 @@ function show_upgrade_menu() {
['1', $text['label-upgrade_source'], $text['description-update_all_source_files']],
['1a', $text['label-main_software'], $text['description-main_software']],
['1b', $text['label-optional_applications'], $text['description-optional_applications']],
['2', $text['label-database'], $text['description-upgrade_schema']],
['2a', $text['label-schema'], $text['description-upgrade_schema']],
['2b', $text['label-upgrade_data_types'], $text['description-upgrade_data_types']],
['2', $text['label-upgrade_schema'], $text['description-upgrade_schema']],
['3', $text['label-upgrade_apps'], $text['description-upgrade_apps']],
['4', $text['label-upgrade_menu'], $text['description-upgrade_menu']],
['5', $text['label-upgrade_permissions'], $text['description-upgrade_permissions']],
@@ -129,14 +127,8 @@ function show_upgrade_menu() {
do_upgrade_auto_loader();
break;
case 2:
do_upgrade_schema(true);
break;
case '2a':
do_upgrade_schema();
break;
case '2b':
do_upgrade_schema(true);
break;
case 3:
do_upgrade_auto_loader();
do_upgrade_domains();
@@ -163,7 +155,7 @@ function show_upgrade_menu() {
case 'a':
do_upgrade_code();
do_upgrade_auto_loader();
do_upgrade_schema(true);
do_upgrade_schema();
do_upgrade_domains();
do_upgrade_menu();
do_upgrade_permissions();
@@ -352,14 +344,11 @@ function do_upgrade_domains() {
/**
* Upgrades the database schema to the latest version.
*
* @param bool $data_types Whether or not to include data types in the upgrade process. Defaults to false.
*
* @return void
*/
function do_upgrade_schema(bool $data_types = false) {
function do_upgrade_schema() {
//get the database schema put it into an array then compare and update the database as needed.
$obj = new schema();
$obj->data_types = $data_types;
echo $obj->schema('text');
}

View File

@@ -60,9 +60,6 @@
//get the database schema put it into an array then compare and update the database as needed.
$obj = new schema(['database' => $database]);
if (isset($argv[1]) && $argv[1] == 'data_types') {
$obj->data_types = true;
}
echo $obj->schema($format);
//formatting for html