You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolved#2108 and some other backend specific issues
AI summary:
This pull request introduces several improvements and new features to the migrations and schema editing system, with a focus on enhanced cross-database compatibility, new constraint management, and improved test coverage. The most significant changes include the addition of a dialect-aware random hex default generator, support for named unique constraints in migrations, enhancements to schema editors for MySQL and MSSQL, and comprehensive tests for unique constraint handling.
Major Features and Enhancements
Added a new RandomHex dialect-aware SqlDefault subclass to generate random hex strings as default values across all supported backends, replacing backend-specific SQL expressions. (RandomHex) is now used in both models and migrations for fields like tracking_id. [1][2][3][4][5]
Introduced support for Meta.constraints on models, enabling named UniqueConstraint objects to be captured by the migration autodetector. This allows for automatic generation of AddConstraint and RemoveConstraint operations in migrations. [1][2][3]
Schema Editor and Backend Improvements
Enhanced MySQL and MSSQL schema editors:
MySQL: _alter_field now uses MODIFY COLUMN for NULL/NOT NULL changes and backtick-quoted templates.
MSSQL: _alter_field uses ALTER COLUMN for nullability, manages named default constraints, uses bracket-quoted templates, and downgrades self-referencing FK CASCADE to NO ACTION.
Migration and Model Changes
Updated migrations to use dialect-specific SQL for computed fields and switched from RunSQL to RunPython for better backend compatibility. [1][2][3]
Adjusted the order of model creation in migrations for consistency and correctness. [1][2]
Testing Improvements
Added comprehensive tests for unique constraint handling, including:
Inline unique constraints in CREATE TABLE statements.
Proper dropping of unique constraints when altering fields from unique to non-unique.
Backend-specific introspection and fallback behavior for constraint names in PostgreSQL and MySQL. [1][2][3]
Documentation
Updated the CHANGELOG.rst to document all new features, backend improvements, and bug fixes included in this release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolved #2108 and some other backend specific issues
AI summary:
This pull request introduces several improvements and new features to the migrations and schema editing system, with a focus on enhanced cross-database compatibility, new constraint management, and improved test coverage. The most significant changes include the addition of a dialect-aware random hex default generator, support for named unique constraints in migrations, enhancements to schema editors for MySQL and MSSQL, and comprehensive tests for unique constraint handling.
Major Features and Enhancements
RandomHexdialect-awareSqlDefaultsubclass to generate random hex strings as default values across all supported backends, replacing backend-specific SQL expressions. (RandomHex) is now used in both models and migrations for fields liketracking_id. [1] [2] [3] [4] [5]Meta.constraintson models, enabling namedUniqueConstraintobjects to be captured by the migration autodetector. This allows for automatic generation ofAddConstraintandRemoveConstraintoperations in migrations. [1] [2] [3]Schema Editor and Backend Improvements
_alter_fieldnow usesMODIFY COLUMNfor NULL/NOT NULL changes and backtick-quoted templates._alter_fieldusesALTER COLUMNfor nullability, manages named default constraints, uses bracket-quoted templates, and downgrades self-referencing FK CASCADE to NO ACTION.Migration and Model Changes
RunSQLtoRunPythonfor better backend compatibility. [1] [2] [3]Testing Improvements
CREATE TABLEstatements.Documentation
CHANGELOG.rstto document all new features, backend improvements, and bug fixes included in this release.