mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove int width from db schema (MySQL 8) (#11725)
* Remove width from db schema * Update to address DEFAULT_GENERATED validation, and push new schema * Only remove width from integer types * Build from fresh db Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@ -2238,7 +2238,7 @@ function dump_db_schema($connection = null)
|
||||
foreach (DB::connection($connection)->select(DB::raw("SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, EXTRA FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '$db_name' AND TABLE_NAME='$table'")) as $data) {
|
||||
$def = [
|
||||
'Field' => $data->COLUMN_NAME,
|
||||
'Type' => $data->COLUMN_TYPE,
|
||||
'Type' => preg_replace('/int\([0-9]+\)/', 'int', $data->COLUMN_TYPE),
|
||||
'Null' => $data->IS_NULLABLE === 'YES',
|
||||
'Extra' => str_replace('current_timestamp()', 'CURRENT_TIMESTAMP', $data->EXTRA),
|
||||
];
|
||||
@ -2247,6 +2247,10 @@ function dump_db_schema($connection = null)
|
||||
$default = trim($data->COLUMN_DEFAULT, "'");
|
||||
$def['Default'] = str_replace('current_timestamp()', 'CURRENT_TIMESTAMP', $default);
|
||||
}
|
||||
// MySQL 8 fix, remove DEFAULT_GENERATED from timestamp extra columns
|
||||
if ($def['Type'] == 'timestamp') {
|
||||
$def['Extra'] = preg_replace("/DEFAULT_GENERATED[ ]*/", '', $def['Extra']);
|
||||
}
|
||||
|
||||
$output[$table]['Columns'][] = $def;
|
||||
}
|
||||
|
1446
misc/db_schema.yaml
1446
misc/db_schema.yaml
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user