1
1
Fork 0

Pad the lengths of the columns

This commit is contained in:
Michael 2021-06-14 05:33:47 +00:00
parent a827f948c8
commit 4095e6c9be
72 changed files with 761 additions and 751 deletions

View file

@ -167,6 +167,7 @@ class DBStructure
$tables = [];
foreach (self::definition(null) as $name => $definition) {
$fields = [];
$lengths = [];
foreach ($definition['fields'] as $key => $value) {
$field = [];
$field['name'] = $key;
@ -177,8 +178,17 @@ class DBStructure
$field['default'] = $value['default'] ?? 'NULL';
$field['extra'] = $value['extra'] ?? '';
foreach ($field as $fieldname => $fieldvalue) {
$lengths[$fieldname] = max($lengths[$fieldname] ?? 0, strlen($fieldvalue));
}
$fields[] = $field;
}
array_walk_recursive($fields, function(&$value, $key) use ($lengths)
{
$value = str_pad($value, $lengths[$key]);
});
$tables[] = ['name' => $name, 'comment' => $definition['comment']];
$content = Renderer::replaceMacros(Renderer::getMarkupTemplate('structure.tpl'), [
'$name' => $name,