diff --git a/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php b/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php index 5a56e52..0d0c798 100644 --- a/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php +++ b/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php @@ -131,10 +131,10 @@ protected function getFields($columns, IndexGenerator $indexGenerator) $type = 'softDeletes'; $name = ''; } elseif ($name == 'created_at' and isset($fields['updated_at'])) { - $fields['updated_at'] = ['field' => '', 'type' => 'timestamps']; + $fields['updated_at'] = ['field' => '', 'type' => 'timestamps', 'args' => $column->getPrecision()]; continue; } elseif ($name == 'updated_at' and isset($fields['created_at'])) { - $fields['created_at'] = ['field' => '', 'type' => 'timestamps']; + $fields['created_at'] = ['field' => '', 'type' => 'timestamps', 'args' => $column->getPrecision()]; continue; } } elseif (in_array($type, ['decimal', 'float', 'double'])) { diff --git a/src/OscarAFDev/MigrationsGenerator/Syntax/AddToTable.php b/src/OscarAFDev/MigrationsGenerator/Syntax/AddToTable.php index fbc0ffa..4380de1 100644 --- a/src/OscarAFDev/MigrationsGenerator/Syntax/AddToTable.php +++ b/src/OscarAFDev/MigrationsGenerator/Syntax/AddToTable.php @@ -34,14 +34,24 @@ protected function getItem(array $field) // If we have args, then it needs // to be formatted a bit differently - if (isset($field['args'])) { - $output = sprintf( - "\$table->%s(%s, %s)", - $type, - $property, - $field['args'] - ); - } + if (isset($field['args']) && $type !== 'text') + { + if ($property == '' || $property == null) { + $output = sprintf( + "\$table->%s(%s)", + $type, + $field['args'] + ); + } + else { + $output = sprintf( + "\$table->%s('%s', %s)", + $type, + $property, + $field['args'] + ); + } + } if (isset($field['decorators'])) { $output .= $this->addDecorators( $field['decorators'] ); }