Commit Graph
488 Commits
Author SHA1 Message Date
Kevin Wu c98d2e2183 fix typo 2025-03-30 17:53:05 +02:00
David Wobrock 76525e47f8 Drop Python 3.7 and 3.8 support. 2025-03-02 18:11:07 +01:00
David Wobrock 6b919297df Upgrade pre-commit deps. 2025-03-02 18:11:07 +01:00
David Wobrock 816dd65e3c Support Python 3.13 and Django 5.1. 2025-03-02 18:11:07 +01:00
Igor Zmitrovich c9d5bce6d1 Update license pyproject.toml 2025-03-02 17:50:46 +01:00
David Wobrock 183bdd5d3b Bump to 5.1.0. 2024-03-30 11:54:10 +01:00
David Wobrock b9768534d1 Bump to 5.1.0. 2024-03-30 11:51:27 +01:00
Deven Dayal a230681de5 Don't consider partial unique index creation as making a column not nullable. 2024-03-30 11:48:49 +01:00
Artem Streltsov b15924ca0f Allow ignoring sqlmigrate errors. 2024-03-30 11:36:10 +01:00
David Wobrock a3acff2fef Update pre-commit hook versions. 2024-03-29 13:05:49 +01:00
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 3a557cbd7c Add changelog entry. 2024-02-04 20:33:26 +01:00
Artem Streltsov abb6233f44 Ignore 'IS NOT NULL' statements. 2024-02-04 20:33:26 +01:00
David Wobrock 0ce5bd8f4b Add Django 5.0 support. 2024-02-04 20:11:21 +01:00
David Wobrock 23997537e4 Upgrade pre-commit deps. 2024-02-04 20:11:21 +01:00
David Wobrock bda054a2cb Remove codecov integration. 2024-02-04 20:11:21 +01:00
David Wobrock 6dad9c01eb Add changelog entry. 2024-02-04 19:53:48 +01:00
Lie Ryan d677c08a07 Avoid using shell when spawning subprocess for git
This avoids security shenanigans that can come if your `git-commit-id`
may come from potentially untrusted source (e.g. an API), an attacker
could trick you to run shell commands like:

    ./manage.py lintmigrations --git-commit-id '; rm -rf dangerous'

or a malicious project may set a config like:

    [tool.django_migration_linter]
    git_commit_id = "; rm -rf dangerous"
2024-02-04 19:53:48 +01:00
dependabot[bot] fff081f865 Bump actions/setup-python from 4 to 5
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-04 19:42:35 +01:00
dependabot[bot] aebf1249a8 Bump codecov/codecov-action from 3.1.4 to 3.1.5
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3.1.4...v3.1.5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-04 19:41:00 +01:00
dependabot[bot] a8366a02b7 Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-29 11:21:53 +01:00
David Wobrock bb35cfa084 Add support for Python 3.12 2023-10-29 11:08:51 +01:00
David Wobrock 0320cf10dd Migrate from setup.py and setup.cfg to pyproject.toml 2023-10-29 10:56:37 +01:00
David Wobrock b1f1dd68bb Add .DS_Store to .gitignore 2023-10-29 10:00:24 +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 Wobrock 3503367f1f Bump to 5.0.0 2023-07-09 14:43:55 +02:00
David Wobrock a856f0d524 Apply updated pre-commit hooks. 2023-07-09 14:42:35 +02:00
David Wobrock 5695a95f81 Move CHANGELOG line to new features section. 2023-07-09 14:42:35 +02:00
David Cain 86b660fbf6 Also flag concurrent index creation
Creating indices concurrently (provided that index creation *completes*)
is generally a much safer way to build an index (since it allows reads
*and* writes to the table during index creation).

However, due to the inherent tradeoffs of concurrent index creation, the
operation will almost always take *longer* than a traditional (blocking)
index creation. It's actually much *more* important to lint against
concurrent index creation when an exclusive lock is open & held.

Test is from a comment by @David-Wobrock (I corrected syntax, though):
https://github.com/3YOURMIND/django-migration-linter/pull/251#discussion_r1249298197
2023-07-09 14:42:35 +02:00
David Cain 15dbe22f24 Add a CHANGELOG entry for the new check
5.0.0 will be released soon, be sure that we document this new check!
2023-07-09 14:42:35 +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 Cain 9fdfa06845 Fix error output when warnings are found
We should log the *warnings* found, not errors!
2023-07-09 14:42:35 +02:00
Caspar Wylie 2d15ea84f9 Support partial function inspection in data migrations 2023-07-03 21:02:14 +02:00
David Wobrock 97a1f5c6c9 Fix #250 -- Don't consider partial index creation as making a column not nullable. 2023-07-03 20:41:03 +02:00
David Wobrock b6acc1dd22 Add Django 4.2 support in CHANGELOG 2023-07-03 20:41:03 +02:00
David Wobrock 366d16b01a Add Django 4.2 compat' and update test dependencies. 2023-07-02 20:36:03 +02:00
David Wobrock f511d51d9a Apply pre-commit hooks on all files. 2023-07-02 20:36:03 +02:00
David Wobrock 7f6e8997eb Update pre-commit hooks. 2023-07-02 20:36:03 +02:00
David Wobrock 202a6d9d5d Add files to .gitignore and other improvements. 2022-12-26 16:26:24 +01:00
David Wobrock f86e0622a5 Add pre-commit hook and use in CI. 2022-12-26 16:26:24 +01:00
David Wobrock 2ee7dac3b3 Add internal classes and add type hints + mypy. 2022-12-26 16:26:24 +01:00
dependabot[bot] 847ac1241a Bump isort from 5.10.1 to 5.11.3
Bumps [isort](https://github.com/pycqa/isort) from 5.10.1 to 5.11.3.
- [Release notes](https://github.com/pycqa/isort/releases)
- [Changelog](https://github.com/PyCQA/isort/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pycqa/isort/compare/5.10.1...5.11.3)

---
updated-dependencies:
- dependency-name: isort
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 10:30:24 +01:00
David Wobrock 8d0462fe83 Add some commands for publishing. 2022-12-17 12:07:02 +01:00
David Wobrock b2338ff93b Stop including test files in dist. 2022-12-17 12:07:02 +01:00
dependabot[bot] c2a6bf4027 Bump black from 22.10.0 to 22.12.0
Bumps [black](https://github.com/psf/black) from 22.10.0 to 22.12.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/22.10.0...22.12.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-17 11:46:16 +01:00
David Wobrock d594aa6012 Use Python 3.10 for linting CI tasks and others. 2022-12-17 11:45:19 +01:00
David Wobrock f9a2e4189c Support Py3.11 and Django 4.1, and drop Django 2.1 support. 2022-12-17 11:45:19 +01:00
dependabot[bot] ec5731f298 Bump flake8 from 5.0.4 to 6.0.0
Bumps [flake8](https://github.com/pycqa/flake8) from 5.0.4 to 6.0.0.
- [Release notes](https://github.com/pycqa/flake8/releases)
- [Commits](https://github.com/pycqa/flake8/compare/5.0.4...6.0.0)

---
updated-dependencies:
- dependency-name: flake8
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 10:10:06 +01:00
Nikita Karamov cb8492d8a7 Use a context manager to write to /dev/null 2022-11-14 09:01:21 +01:00