{"record":{"id":"685fe800ad6f81ba","repo":"sqlalchemy/alembic","slug":"individual-alter-column-constructs-not-supported-b","errorCode":null,"errorMessage":"Individual alter column constructs not supported by MySQL","messagePattern":"Individual alter column constructs not supported by MySQL","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"alembic/ddl/mysql.py","lineNumber":439,"sourceCode":"        if type_ is None:\n            raise util.CommandError(\n                \"All MySQL CHANGE/MODIFY COLUMN operations \"\n                \"require the existing type.\"\n            )\n\n        self.type_ = sqltypes.to_instance(type_)\n\n\nclass MySQLModifyColumn(MySQLChangeColumn):\n    pass\n\n\n@compiles(ColumnNullable, \"mysql\", \"mariadb\")\n@compiles(ColumnName, \"mysql\", \"mariadb\")\n@compiles(ColumnDefault, \"mysql\", \"mariadb\")\n@compiles(ColumnType, \"mysql\", \"mariadb\")\ndef _mysql_doesnt_support_individual(element, compiler, **kw):\n    raise NotImplementedError(\n        \"Individual alter column constructs not supported by MySQL\"\n    )\n\n\n@compiles(MySQLAlterDefault, \"mysql\", \"mariadb\")\ndef _mysql_alter_default(\n    element: MySQLAlterDefault, compiler: MySQLDDLCompiler, **kw\n) -> str:\n    return \"%s ALTER COLUMN %s %s\" % (\n        alter_table(compiler, element.table_name, element.schema),\n        format_column_name(compiler, element.column_name),\n        (\n            \"SET DEFAULT %s\" % format_server_default(compiler, element.default)\n            if element.default is not None\n            else \"DROP DEFAULT\"\n        ),\n    )\n","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/sqlalchemy/alembic/blob/5551b5d35f985c99cb8f1af2b3c526b050e4c059/alembic/ddl/mysql.py#L421-L457","documentation":"MySQL/MariaDB compilation of ColumnNullable, ColumnName, ColumnDefault, or ColumnType raises NotImplementedError. MySQL does not support individual ALTER COLUMN sub-operations; it requires a single CHANGE COLUMN or MODIFY COLUMN that restates the full column definition. Alembic emits MySQL-specific constructs (MySQLModifyColumn) instead, so hitting the generic ones means an unsupported path was reached.","triggerScenarios":"Custom code that directly compiles a bare ColumnNullable/ColumnName/ColumnDefault/ColumnType against the mysql or mariadb dialect; or an operations path that bypasses Alembic's alter_column MySQL rewrite and feeds the generic construct to the compiler.","commonSituations":"Third-party dialect plugins or custom ops that build standalone alter-column constructs; calling op.alter_column with a combination that Alembic's MySQL impl fails to translate into MySQLChangeColumn.","solutions":["Use op.alter_column() which Alembic translates to CHANGE/MODIFY COLUMN on MySQL, restating nullable/type/default together.","When altering a MySQL column, supply existing_type (and existing_nullable/existing_server_default) so the full MODIFY spec can be generated.","Avoid compiling bare ColumnNullable/ColumnType constructs directly for the MySQL dialect."],"exampleFix":"# before (unsupported on MySQL)\n# a bare alter that loses full column info\n\n# after: alter_column restates full definition\nop.alter_column('t', 'c', existing_type=sa.Integer(),\n               type_=sa.String(50), nullable=False)","handlingStrategy":"validation","validationCode":"def alter_column_mysql(op, table, col, existing_type, **kw):\n    # always pass existing_type so MODIFY COLUMN can restate the definition\n    op.alter_column(table, col, existing_type=existing_type, **kw)","typeGuard":"def has_existing_type(kw: dict) -> bool:\n    return kw.get('existing_type') is not None","tryCatchPattern":null,"preventionTips":["Always supply existing_type when calling op.alter_column on MySQL/MariaDB.","Let Alembic's MySQL impl translate to CHANGE/MODIFY COLUMN rather than building alter constructs manually.","Never compile bare ColumnNullable/ColumnType constructs for the MySQL dialect."],"tags":["mysql","mariadb","alter-column","ddl","dialect"],"backgroundTag":null,"analyzedSha":"5551b5d35f985c99cb8f1af2b3c526b050e4c059","analyzedAt":"2026-08-11T01:38:46.612Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}