# django-check-migration-wtf
## Description
**django-check-migration-wtf** is an extension for Django to check migrations and notify you if their are secure to do
on environments with zero downtime.
In some situations Django Migration system generate migrations to need do a downtime because they are blocking operation
or you write custom migration than can block you database.
Actually this extension only works for backends of PostgresSQL and Postgis, versions support 11, 12, 13 and 14.
**Advise**: this extension notify you for common blocking operations on database. Anyway you should review your migrations and understand their.
## Configuration
It is really simple
### Installation
Install the package with the typical tool (pip):
`pip install django-check-migration-wtf`
### Add to your project
Add app on your settings:
```python
INSTALLED_APPS = [
'django_check_migration_wtf',
...,
]
```
### Add some optional vars
Add some optional setup on your settings:
* `CHECK_MIGRATION_WTF_PSQL_VERSION` It is to know your PostgresSQL Version by default it is 9
* The next following vars are for use github integration:
* `CHECK_MIGRATION_WTF_GITHUB_TOKEN` Token to can use API of github, It only need permission of reading of repo.
* `CHECK_MIGRATION_WTF_REPO_NAME` Name of repository on Github
## Usage
It is really easy to use. It is execute by a typical django command like `makemigrations` or `migrate`...
It has two mode of usage.
### Local
First execute your `makemigrations` and you can do your custome modifications. Then **before** execute command `migrate`
execute the following command:
`python manage.py check_migration`
It will search all migrations that are not apply to the system (like `showmigrations`) and it will analyze if they are secure to do.
You can have two possibilities:
* When the migration or migrations are **secure**, you get the following response:
![image info](./images/migration-ok.png)
* When the migration or migrations are **not secure**, you get the following response:
![image info](./images/migration-bad.png)
### Github
This is reality an option of command to execute it on your continues integration.
It will search you migrations comparing the base branch and your current branch and the analyze it
`python manage.py check_migration --github <head_ref> <base_ref>`
## Limitations
* This extension not analyze code inside of `RunPython`
* Github option to work correctly suppose your migrations are inside of directory **migrations**
Raw data
{
"_id": null,
"home_page": "https://github.com/antonioIrizar/django-check-migration-wtf",
"name": "django-check-migration-wtf",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "django postgres postgresql migrations",
"author": "Antonio Irizar",
"author_email": "antonioirizar@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d2/34/75e2524631482d4b2e1ef0851e787636b9eb170d0e817e87ab3dfdb990ee/django-check-migration-wtf-1.4.0.tar.gz",
"platform": null,
"description": "# django-check-migration-wtf\n\n## Description\n\n**django-check-migration-wtf** is an extension for Django to check migrations and notify you if their are secure to do \non environments with zero downtime. \n\nIn some situations Django Migration system generate migrations to need do a downtime because they are blocking operation \nor you write custom migration than can block you database.\n\nActually this extension only works for backends of PostgresSQL and Postgis, versions support 11, 12, 13 and 14.\n\n**Advise**: this extension notify you for common blocking operations on database. Anyway you should review your migrations and understand their.\n\n## Configuration\n\nIt is really simple\n\n### Installation\n\nInstall the package with the typical tool (pip):\n\n`pip install django-check-migration-wtf`\n\n### Add to your project\n\nAdd app on your settings:\n\n```python\nINSTALLED_APPS = [\n 'django_check_migration_wtf',\n ...,\n]\n```\n\n### Add some optional vars \n\nAdd some optional setup on your settings:\n\n* `CHECK_MIGRATION_WTF_PSQL_VERSION` It is to know your PostgresSQL Version by default it is 9 \n* The next following vars are for use github integration:\n * `CHECK_MIGRATION_WTF_GITHUB_TOKEN` Token to can use API of github, It only need permission of reading of repo.\n * `CHECK_MIGRATION_WTF_REPO_NAME` Name of repository on Github\n\n## Usage\n\nIt is really easy to use. It is execute by a typical django command like `makemigrations` or `migrate`...\nIt has two mode of usage.\n\n### Local\n\nFirst execute your `makemigrations` and you can do your custome modifications. Then **before** execute command `migrate` \nexecute the following command:\n\n`python manage.py check_migration`\n\nIt will search all migrations that are not apply to the system (like `showmigrations`) and it will analyze if they are secure to do.\n\nYou can have two possibilities:\n\n* When the migration or migrations are **secure**, you get the following response:\n\n ![image info](./images/migration-ok.png)\n\n* When the migration or migrations are **not secure**, you get the following response:\n\n ![image info](./images/migration-bad.png)\n\n### Github\n\nThis is reality an option of command to execute it on your continues integration. \nIt will search you migrations comparing the base branch and your current branch and the analyze it\n\n`python manage.py check_migration --github <head_ref> <base_ref>`\n\n## Limitations\n\n* This extension not analyze code inside of `RunPython`\n* Github option to work correctly suppose your migrations are inside of directory **migrations** \n\n\n",
"bugtrack_url": null,
"license": "GLP3",
"summary": "A line of description",
"version": "1.4.0",
"split_keywords": [
"django",
"postgres",
"postgresql",
"migrations"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "fa7f3156783005e7ae34c7fd6ef4c091",
"sha256": "4c7cfaf3807c8b7282f790438ff9eb2300596bb77ba815fe79fbc497a0fa75fa"
},
"downloads": -1,
"filename": "django_check_migration_wtf-1.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fa7f3156783005e7ae34c7fd6ef4c091",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 31540,
"upload_time": "2022-12-19T14:01:46",
"upload_time_iso_8601": "2022-12-19T14:01:46.240858Z",
"url": "https://files.pythonhosted.org/packages/3e/54/c395dcb571c5483728fd486c4e7b2ff6f3882b726b181083c4bc4f939e67/django_check_migration_wtf-1.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "fcf1839c61631313d8b4a2df31b08e37",
"sha256": "abba5fd0b523a049c2e70c40b53a26d8e661d5e0182103fa1d9983b4da4394bb"
},
"downloads": -1,
"filename": "django-check-migration-wtf-1.4.0.tar.gz",
"has_sig": false,
"md5_digest": "fcf1839c61631313d8b4a2df31b08e37",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 25443,
"upload_time": "2022-12-19T14:01:48",
"upload_time_iso_8601": "2022-12-19T14:01:48.033606Z",
"url": "https://files.pythonhosted.org/packages/d2/34/75e2524631482d4b2e1ef0851e787636b9eb170d0e817e87ab3dfdb990ee/django-check-migration-wtf-1.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-19 14:01:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "antonioIrizar",
"github_project": "django-check-migration-wtf",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "Django",
"specs": [
[
">=",
"2.2"
],
[
"<",
"4.1"
]
]
},
{
"name": "psycopg2-binary",
"specs": [
[
"<",
"2.10"
],
[
">=",
"2.9"
]
]
},
{
"name": "PyGithub",
"specs": [
[
">=",
"1.50"
],
[
"<",
"2.0"
]
]
},
{
"name": "pytest",
"specs": [
[
"<",
"8"
],
[
">=",
"7.2"
]
]
},
{
"name": "pytest-django",
"specs": [
[
">=",
"4.5"
],
[
"<",
"5"
]
]
},
{
"name": "tox",
"specs": [
[
">=",
"4"
],
[
"<",
"5"
]
]
}
],
"tox": true,
"lcname": "django-check-migration-wtf"
}