mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
优化数据库迁移生成,支持decimal。
This commit is contained in:
@@ -135,7 +135,17 @@ class Migrate extends Command
|
||||
$column_item['type'] = $type_info[0];
|
||||
|
||||
$length = substr($type_info[1], 0, strpos($type_info[1], ')'));
|
||||
$column_item['options']['limit'] = $length;
|
||||
|
||||
if (strpos($length, ',') !== false) {
|
||||
|
||||
$length_info = explode(',', $length);
|
||||
|
||||
$column_item['options']['precision'] = $length_info[0];
|
||||
$column_item['options']['scale'] = $length_info[1];
|
||||
} else {
|
||||
|
||||
$column_item['options']['limit'] = $length;
|
||||
}
|
||||
|
||||
if (strpos($type, 'unsigned') !== false) {
|
||||
// 无符号
|
||||
@@ -183,6 +193,17 @@ class Migrate extends Command
|
||||
if (isset($type_map[$column_item_set['type']])) {
|
||||
$column_item_set['type'] = $type_map[$column_item_set['type']];
|
||||
}
|
||||
|
||||
foreach ($column_item_set['options'] as $key => $option) {
|
||||
|
||||
if(is_array($option)){
|
||||
|
||||
$column_item_set['options'][$key] = "[".implode(',',$option)."]";
|
||||
|
||||
}else{
|
||||
$column_item_set['options'][$key] = "'{$option}'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class {$class_name} extends Migrator
|
||||
{
|
||||
$table = $this->table('{$table}')
|
||||
->setComment('{$table_info.TABLE_COMMENT}')
|
||||
{volist name="table_columns" id="column"}->addColumn('{$column.field}', '{$column.type}', [{volist name="column.options" id="option"}'{$key}' => '{$option}', {/volist}])
|
||||
{volist name="table_columns" id="column"}->addColumn('{$column.field}', '{$column.type}', [{volist name="column.options" id="option"}'{$key}' => {$option|raw}, {/volist}])
|
||||
{/volist}
|
||||
{volist name="table_keys_uni" id="vo"}->addIndex('{$vo}',['unique'=>true])
|
||||
{/volist}
|
||||
|
||||
Reference in New Issue
Block a user