Replace the config/database.py content with your previously created database information
Open terminal at folder root
Run pip install -r requirements.txt
Run masonite-orm migrate
Expected behavior
The masonite-orm migrate command exit with code 0, the database is updated correctly to reflect the migrations.
Actual behavior
The masonite-orm migrate command exit with code 1, and displays an error code. The last migration is not migrated.
Screenshots or code snippets
Log showed by console:
Migrating: 2024_06_19_201336_test_table
Migrated: 2024_06_19_201336_test_table (0.03s)
Migrating: 2024_06_19_201408_test_enum
QueryException
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL DEFAULT 'foo'' at line 1")
at .venv\Lib\site-packages\masoniteorm\connections\MySQLConnection.py:176 in query
172│ return self.format_cursor_results(cursor.fetchone())
173│ else:
174│ return self.format_cursor_results(cursor.fetchall())
175│ except Exception as e:
→ 176│ raise QueryException(str(e)) from e
177│ finally:
178│ self._cursor.close()
179│ if self.get_transaction_level() <= 0:
180│ self.open = 0
SQL statement generated by MySQLPlateform (retrived using masonite-orm migrate --show):
ALTER TABLE `test` ADD `test_enum` ENUM NOT NULL DEFAULT 'foo'
SQL statement that should have been generated:
ALTER TABLE `test` ADD `test_enum` ENUM('foo', 'bar', 'baz') NOT NULL DEFAULT 'foo'
Describe the bug
When running a migration containing an enum column to add to an existing table, using the MySQL connector, the migration fails.
To Reproduce
config/database.py
content with your previously created database informationpip install -r requirements.txt
masonite-orm migrate
Expected behavior
The
masonite-orm migrate
command exit with code 0, the database is updated correctly to reflect the migrations.Actual behavior
The
masonite-orm migrate
command exit with code 1, and displays an error code. The last migration is not migrated.Screenshots or code snippets
Log showed by console:
SQL statement generated by
MySQLPlateform
(retrived usingmasonite-orm migrate --show
):SQL statement that should have been generated:
Desktop
What database are you using?
Additional context
The
src/masoniteorm/schema/platforms/MySQLPlatform.py:add_column_string
function simply has nocolumn_constraint
format field (as used insrc/masoniteorm/schema/platforms/MySQLPlatform.py:columnize_string
to fill the values insrc/masoniteorm/schema/platforms/MySQLPlatform.py:columnize
)This comment also applies when modifying a existing column, as can be seen in
src/masoniteorm/schema/platforms/MySQLPlatform.py:change_column_string
, but this function isn't used ; for changed columns,src/masoniteorm/schema/platforms/MySQLPlatform.py:columnize
is used instead, as can be seen insrc/masoniteorm/schema/platforms/MySQLPlatform.py:compile_alter_sql
, so the whole issue doesn't seems to apply when editing a column.