Commit Graph
44 Commits
Author SHA1 Message Date
David Wobrock 18a39cb3fc Support Django 5.0 db_default attribute.
A DB default is not considered backward incompatible, as the default value is kept on DB-level.
See https://docs.djangoproject.com/en/dev/releases/5.0/#database-computed-default-values
2024-03-29 12:39:30 +01:00
David Wobrock 0320cf10dd Migrate from setup.py and setup.cfg to pyproject.toml 2023-10-29 10:56:37 +01:00
jason.lee 117967a957 Adding a unique constraint solution correction
Correct solution to instruct app code to follow unique constraint before db constraint is deployed
2023-09-08 15:05:23 +02:00
David Cain 48fac8856b Downgrade CREATE_INDEX_EXCLUSIVE to a warning
While it's always a dangerous *pattern* to create an index while a
transaction is open & holds an exclusive lock, in practice it's not
always a big deal (for example, indexing a table with very few rows can
be fast). Accordingly, downgrade to a warning.
2023-07-09 14:42:35 +02:00
David Cain 0c5519d9dc Add new check for indexing with atomic=True
Briefly, this check helps prevent a long-running index creation from
preventing all reads and writes to a table.

This supplements an existing check
==================================
There is an existing check, `CREATE_INDEX` which warns about creating
indices without the `CONCURRENTLY` argument. It's a helpful check!

However, there are some valid reasons to prefer non-concurrent index
creation. For example, concurrent index creation may struggle to
complete when applied to write-heavy tables (since Postgres will have to
make repeated passes on the table to accommodate the new reads since the
last round).

The danger of `EXCLUSIVE` locks
===============================
If you *do* want to create indices nonconcurrently, there is still a
**huge footgun** to be aware of -- locks which are held in a transaction
are not released until the transaction closes.

Dangerous Django defaults
=========================
By default, any time you add a new Django field with `db_index=True` or
`unique=True`, the automatically generated `Migration` has:

- implicit setting of `atomic=True` (transactions are on)
- an `ALTER TABLE...ADD COLUMN` call (exclusively locks the table)
- a `CREATE INDEX` invocation (*hopefully* quick, due to nullable
  columns)

It's even more dangerous if you combine an `ALTER TABLE` call with
`CREATE INDEX` of an existing, non-nullable column.

Favor `atomic=False` if you must index
======================================
Index-creating migrations should have few `operations`. Since index
creation does not modify row-level data (and only requires locking
against writes), there's no reason to use transactions.

It's prudent to bypass the default `atomic=True` for index creation.
2023-07-09 14:42:35 +02:00
David Wobrock f86e0622a5 Add pre-commit hook and use in CI. 2022-12-26 16:26:24 +01:00
David Wobrock 8d0462fe83 Add some commands for publishing. 2022-12-17 12:07:02 +01:00
Sören Wegener a3fc5f1a50 Improve error message when an unsupported database vendor/SQL analyser was selected. 2022-10-03 15:48:11 +02:00
David Wobrock c7d9129db9 Adapt 'warnings-as-errors' option to allow taking migration test codes as input 2022-03-13 17:26:40 +01:00
Ben Limmer 61237c37d7 docs: fix IgnoreMigration link 2022-02-15 19:30:18 +01:00
David Wobrock 4fa6a33153 Fix #198 -- Allow using Django settings for linter configuration 2022-02-15 19:21:58 +01:00
David Wobrock 76a55dbb12 Raise when unsupported db vendor, and add option to specify SQL analyser 2022-01-30 15:20:18 +01:00
David Wobrock 3076c88181 Add documentation about dropping a column in multiple steps 2022-01-28 20:39:59 +01:00
David Wobrock aef3db3e41 Remove 'Others' mention 2021-12-20 22:03:28 +01:00
David Wobrock 4e279a9450 Add a solution for RunPython import errors 2021-12-20 22:03:28 +01:00
David Wobrock fbd4b2971f Add documentation about all implemented backward incompatible migrations 2021-12-20 22:03:28 +01:00
David Wobrock 610e4646b8 Add table deletion case to doc 2021-12-20 22:03:28 +01:00
David Wobrock 0394377db0 Add emoji in backward incompatibilities titles 2021-12-20 22:03:28 +01:00
David Wobrock 410ac91fd3 Update a bit adding a not null column section 2021-12-20 22:03:28 +01:00
David Wobrock 88c7d4cd50 Reformat table in incompatibilites doc 2021-12-20 22:03:28 +01:00
David Wobrock 1f8476fc43 Add details about some backward incompatible operations
- adding a NOT NULL column
- dropping a column
- sqlite special case
2021-12-20 22:03:28 +01:00
David Wobrock 967047d4e6 Add type for each migration linter check
Add to the docs whether it raises an error or warning by default
2021-12-20 22:03:28 +01:00
David Wobrock 085048d22b Drop Py2.7, 3.5 and Django 1.11, 2.0, 2.1, 3.0 2021-11-12 17:26:38 +01:00
Daniel Hahler 6ba4010381 Fix/revisit docs
Started with a follow-up to fa9b2f97, which missed applying the fix to
docs, and then added some more while reading it.
2021-11-12 08:53:25 +01:00
Raju Mazumder 1612ecc029 Raju | fix typo in incompatibilities doc 2021-09-07 09:47:10 +02:00
David Wobrock fa56196f04 Add PG reindex linting warning and improve some smaller stuff 2021-06-19 18:15:40 +02:00
David Wobrock ea89043d8c Add to documentation 2021-06-19 18:15:40 +02:00
David Wobrock 0ac5a9dba3 Add pyproject.toml back to available config files 2021-05-26 19:05:33 +02:00
David Wobrock 7c5bcb9923 Document new lintmigrations command arguments 2021-05-26 18:53:19 +02:00
David-Wobrock 2f3ce1d7cc Remove toml support 2021-04-01 23:11:35 +02:00
Łukasz Skarżyński ba62f664d4 update supported config files names 2021-02-04 19:22:57 +01:00
David-Wobrock 137089573c Implement include migration name options 2021-01-31 17:44:58 +01:00
David-Wobrock 2dc4caadf9 Implement config files 2021-01-17 16:28:31 +01:00
David-Wobrock 4b15e11faa Rename data migration lint checks 2020-11-30 21:40:57 +01:00
David-Wobrock f5d0da4932 Run some checks on RunSQL migration operation 2020-11-26 19:02:57 +01:00
David-Wobrock 780630131f Add warning if RunPython model variable name not the same as model class 2020-11-26 19:02:57 +01:00
David-Wobrock 5e26d9a910 Document the incompatibility codes 2020-11-26 19:02:57 +01:00
David-Wobrock 321b41ddd0 Start using GitHub Actions and remove Travis 2020-11-26 18:43:34 +01:00
David Wobrock 86ccbfea4f Add documentation for the makemigrations override 2020-07-02 19:15:30 +02:00
David-Wobrock 87040845ed Fix #106 -- Add forgotten documentation about IgnoreMigration() 2020-05-04 20:41:51 +02:00
David Wobrock e49f6dea9c Document, add to changelog the data migrations and rename to 'warnings-as-errors' (plural) 2020-02-07 23:29:15 +01:00
David Wobrock d01875b3be add warnings and RunPython basic linting 2020-02-07 23:29:15 +01:00
David-Wobrock 0fdff490b6 Add information to how to configure test databases 2020-01-11 22:35:20 +01:00
David-Wobrock f9dc725e00 Split documentation to multiple files in docs/ and use markdown 2020-01-11 22:35:20 +01:00