summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/schema.py
AgeCommit message (Collapse)Author
2025-10-27Fixed #36624 -- Dropped support for MySQL < 8.4.Mariusz Felisiak
2025-10-18Fixed #21961 -- Added support for database-level delete options for ForeignKey.Mariusz Felisiak
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-03-09Fixed #35487 -- Removed CASCADE from RemoveField() on PostgreSQL.petr.prikryl
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Co-authored-by: Adam Johnson <me@adamj.eu> Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2025-02-09Fixed #36105 -- Dropped support for MariaDB 10.5.Mariusz Felisiak
2025-01-10Refs #36064 -- Added Model.has_db_default() to encapsulate NOT_PROVIDED checks.Simon Charette
This avoids many awkward checks against NOT_PROVIDED and provides symmetry with Field.has_default() which is also the reason why it wasn't made a property.
2023-12-14Fixed #35000 -- Skipped declaring empty string defaults on BLOB/TEXT field ↵Tobias Krönke
on MySQL. Empty string defaults are redundant on MySQL and prevent use of ALGORITHM=INSTANT.
2023-08-03Fixed #34761 -- Dropped support for MySQL < 8.0.11.Mariusz Felisiak
2023-05-12Fixed #470 -- Added support for database defaults on fields.Ian Foote
Special thanks to Hannes Ljungberg for finding multiple implementation gaps. Thanks also to Simon Charette, Adam Johnson, and Mariusz Felisiak for reviews.
2023-05-10Fixed #34553 -- Fixed improper % escaping of literal in constraints.Simon Charette
Proper escaping of % in string literals used when defining constaints was attempted (a8b3f96f6) by overriding quote_value of Postgres and Oracle schema editor. The same approach was used when adding support for constraints to the MySQL/MariaDB backend (1fc2c70). Later on it was discovered that this approach was not appropriate and that a preferable one was to pass params=None when executing the constraint creation DDL to avoid any form of interpolation in the first place (42e8cf47). When the second patch was applied the corrective of the first were not removed which caused % literals to be unnecessary doubled. This flew under the radar because the existings test were crafted in a way that consecutive %% didn't catch regressions. This commit introduces an extra test for __exact lookups which highlights more adequately % doubling problems but also adjust a previous __endswith test to cover % doubling problems (%\% -> %%\%%). Thanks Thomas Kolar for the report. Refs #32369, #30408, #30593.
2023-03-02Refs #34320 -- Stopped recreating check constraints when renaming fields.Mariusz Felisiak
This also fixes test_rename_field_with_check_to_truncated_name() on MariaDB 10.5.2+ as ALTER TABLE ... RENAME COLUMN statement doesn't rename inline constraints.
2023-02-01Refs #33476 -- Applied Black's 2023 stable style.David Smith
Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0
2023-01-31Fixed #34304 -- Made MySQL's SchemaEditor.remove_constraint() don't create ↵sag᠎e
foreign key index when unique constraint is ignored. Regression in b731e8841558ee4caaba766c83f34ea9c7004f8b.
2022-12-28Fixed #18468 -- Added support for comments on columns and tables.kimsoungryoul
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz Felisiak for reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-12-22Fixed #34219 -- Preserved Char/TextField.db_collation when altering column type.Mariusz Felisiak
This moves setting a database collation to the column type alteration as both must be set at the same time. This should also avoid another layer of the column type alteration when adding database comments support (#18468).
2022-09-13Fixed #31335 -- Fixed removing composed composed Meta constraints/indexes on ↵Sergey Fursov
foreign keys on MySQL.
2022-09-12Refs #31335 -- Added SchemaEditor._create_missing_fk_index() on MySQL.Sergey Fursov
2022-05-12Refs #27064 -- Added RenameIndex migration operation.David Wobrock
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-12-02Updated various links to HTTPS and new locations.Mariusz Felisiak
Co-Authored-By: Nick Pope <nick@nickpope.me.uk>
2021-09-22Fixed #33129 -- Dropped support for MariaDB 10.2.Mariusz Felisiak
2021-08-20Optimized DatabaseSchemaEditor._field_should_be_indexed() on MySQL.Matjaz Gregoric
2021-05-21Fixed #32503 -- Fixed altering BLOB/TEXT field to non-nullable with default ↵Yuekui Li
on MySQL 8.0.13+. MySQL 8.0.13+ supports defaults for BLOB/TEXT but not in the ALTER COLUMN statement. Regression in 6b16c91157512587017e9178d066ed1a683e7795. Thanks Matt Westcott for the report.
2021-02-09Fixed #32425 -- Fixed adding nullable field with default on MySQL.Jordan Bae
Thanks Simon Charette for the review.
2020-12-23Refs #26167 -- Made DatabaseSchemaEditor._create_index_sql()'s fields ↵Hannes Ljungberg
argument optional and kwarg-only.
2020-09-21Fixed #31777 -- Added support for database collations to Char/TextFields.Tom Carrick
Thanks Simon Charette and Mariusz Felisiak for reviews.
2020-04-09Refs #31411 -- Used RENAME COLUMN on MySQL 8.0.4+.Mariusz Felisiak
MySQL 8.0.3 added support for this syntax but also imposed a restriction against ALTER TABLE RENAME on tables in a foreign key relationship if a LOCK TABLES was active which has been lifted in MySQL 8.0.4+.
2020-04-02Fixed #31411 -- Used RENAME COLUMN on MariaDB 10.5.2+.Hasan Ramezani
2019-09-05Fixed #30750 -- Added support for check constraints on MySQL 8.0.16+.Mariusz Felisiak
2019-08-22Fixed #30712 -- Allowed BLOB/TEXT defaults on MySQL 8.0.13+.Nasir Hussain
2019-08-16Fixed #27676 -- Allowed BLOB/TEXT defaults on MariaDB 10.2.1+.Adam Johnson
2019-07-19Fixed #30593 -- Added support for check constraints on MariaDB 10.2+.Hasan Ramezani
2019-04-19Fixed #30380 -- Handled bytes in MySQL backend for PyMySQL support.Mariusz Felisiak
This commit partly reverts efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7.
2019-01-29Fixed #30108 -- Allowed adding foreign key constraints in the same statement ↵Dan Tao
that adds a field.
2018-10-29Fixed #29547 -- Added support for partial indexes.Mads Jensen
Thanks to Ian Foote, Mariusz Felisiak, Simon Charettes, and Markus Holtermann for comments and feedback.
2018-03-17Fixed #29103 -- Removed bad 'b'-prefix added by MySQL's ↵Claude Paroz
SchemaEditor.quote_value().
2018-01-03Fixed #28982 -- Simplified code with and/or.Дилян Палаузов
2017-06-06Fixed #28275 -- Added more hooks to SchemaEditor._alter_field().Florian Apolloner
2017-05-23Fixed #27859 -- Ignored db_index for TextField/BinaryField on Oracle and MySQL.Mariusz Felisiak
Thanks Zubair Alam for the initial patch and Tim Graham for the review.
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2016-11-05Fixed #27441 -- Improved SQL for 'DROP COLUMN' on MySQLAdam Chainz
'CASCADE' is an undocumented no-op in MySQL, so to avoid confusion Django no longer outputs it.
2016-08-01Fixed #26966 -- Made MySQL backend skip defaults for JSON columnsAdam Chainz
Thanks mcgeeco for reporting, and claudep and timgraham for review.
2016-06-28Fixed #26171 -- Made MySQL create an index on ForeignKeys with ↵Aaron Elliot Ross
db_contraint=False. Refactored "Prevented unneeded index creation on MySQL-InnoDB" (2ceb10f) to avoid setting db_index=False.
2016-05-07Fixed #26593 -- Leveraged deferrable_sql() in SchemaEditorMarkus Holtermann
2016-01-22Removed unused attributes of MySQL SchemaEditor.Tim Graham
2015-09-14Fixed #25393 -- Fixed MySQL crash when adding text/blob field with ↵Ville Skyttä
unhashable default.
2015-06-15Fixed #24972 -- Fixed removing unique_together indexes on MySQL.Adam Brenecki
2015-05-30Fixed #24846 -- Added support to MySQL SchemaEditor for all blob/text data typesAdam Chainz
2015-05-28Fixed #24817 -- Prevented loss of null info in MySQL field renaming.Andriy Sokolovskiy
2015-05-15Fixed #24757 -- Recreated MySQL index when needed during combined index removalClaude Paroz
Thanks Thomas Recouvreux for the report and Tim Graham for the tests and review.
2015-04-17Fixed #24595 -- Prevented loss of null info in MySQL field alterationClaude Paroz
Thanks Simon Percivall for the report, and Simon Charette and Tim Graham for the reviews.