Skip to content

fix: correct syntax generation for column types with parameters

Latest

Choose a tag to compare

@robinNcode robinNcode released this 01 Nov 17:57
· 1 commit to master since this release
ffcbf30
  • Fix CHAR column type generation syntax
  • Fix VARCHAR column type generation syntax
  • Fix DECIMAL column type generation with precision and scale

Previously, the mapToLaravelType() method was returning malformed
strings like 'char, 10' which resulted in invalid migration syntax:
$table->char, 10('column_name');

This commit refactors the method to return an array structure
containing the method name and parameters separately, allowing
proper syntax generation:
$table->char('column_name', 10);
$table->string('column_name', 255);
$table->decimal('column_name', 8, 2);

Changes:

  • Refactored mapToLaravelType() to return ['method' => '...', 'length' => '...']
  • Updated getColumnDefinition() to handle new array structure
  • Added proper parameter formatting for decimal types (precision, scale)

Tested with MySQL CHAR(10), VARCHAR(255), DECIMAL(8,2) columns"