Commit Graph
476 Commits
Author SHA1 Message Date
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
David Wobrock e8f83708b0 Run black. 2022-11-03 22:00:00 +01:00
Sondre Lillebø Gundersen a9405eaf83 feat: Support Path type for project_root_path
Django has switched to using pathlib.Path in startproject. This adds support for these in the project root path config option.
2022-11-03 22:00:00 +01:00
Sondre Lillebø Gundersen bd4eb89b8c chore: Upgrade Python syntax with pyupgrade
Run with the following pre-commit configuration:

```
repos:
  - repo: https://github.com/asottile/pyupgrade
    rev: v3.1.0
    hooks:
      - id: pyupgrade
        args: [ "--py3-plus", "--py36-plus", "--py37-plus" ]
```

The rationale for every change can be found at https://github.com/asottile/pyupgrade
2022-11-03 22:00:00 +01:00
dependabot[bot] 92eab3c929 Bump black from 22.8.0 to 22.10.0
Bumps [black](https://github.com/psf/black) from 22.8.0 to 22.10.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.8.0...22.10.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-10-12 18:34:52 +02: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 9ad7bcced0 Add release not for IgnoreMigration.elidable=True change. 2022-10-03 15:47:49 +02:00
Tobias Krönke d1c1388f28 feat(IgnoreMigration): elidable by default to support squashing 2022-10-03 15:47:49 +02:00
dependabot[bot] da5e7b88f4 Bump codecov/codecov-action from 3.1.0 to 3.1.1
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3.1.0...v3.1.1)

---
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>
2022-10-03 15:22:00 +02:00
dependabot[bot] 62d5ece51f Bump black from 22.6.0 to 22.8.0
Bumps [black](https://github.com/psf/black) from 22.6.0 to 22.8.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.6.0...22.8.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-09-05 17:17:52 +02:00
David Wobrock 6ba29a6b5d Fix flake8 linting. 2022-08-07 17:06:10 +02:00
David Wobrock 1fb2b62fc3 Upgrade flake8 to 5.0.4. 2022-08-07 17:06:10 +02:00
dependabot[bot] c69da5e1dd Bump flake8 from 4.0.1 to 5.0.1
Bumps [flake8](https://github.com/pycqa/flake8) from 4.0.1 to 5.0.1.
- [Release notes](https://github.com/pycqa/flake8/releases)
- [Commits](https://github.com/pycqa/flake8/compare/4.0.1...5.0.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-07 17:06:10 +02:00