django-migration-zero 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. django_migration_zero-0.1.0/.ambient-package-update/metadata.py +63 -0
  2. django_migration_zero-0.1.0/.coveragerc +7 -0
  3. django_migration_zero-0.1.0/.editorconfig +18 -0
  4. django_migration_zero-0.1.0/.github/workflows/ci.yml +51 -0
  5. django_migration_zero-0.1.0/.gitignore +160 -0
  6. django_migration_zero-0.1.0/.pre-commit-config.yaml +30 -0
  7. django_migration_zero-0.1.0/.readthedocs.yml +24 -0
  8. django_migration_zero-0.1.0/LICENSE +21 -0
  9. django_migration_zero-0.1.0/LICENSE.md +21 -0
  10. django_migration_zero-0.1.0/MANIFEST.in +4 -0
  11. django_migration_zero-0.1.0/PKG-INFO +222 -0
  12. django_migration_zero-0.1.0/README.md +178 -0
  13. django_migration_zero-0.1.0/django_migration_zero/__init__.py +6 -0
  14. django_migration_zero-0.1.0/django_migration_zero/admin.py +18 -0
  15. django_migration_zero-0.1.0/django_migration_zero/apps.py +7 -0
  16. django_migration_zero-0.1.0/django_migration_zero/exceptions.py +6 -0
  17. django_migration_zero-0.1.0/django_migration_zero/helpers/__init__.py +0 -0
  18. django_migration_zero-0.1.0/django_migration_zero/helpers/file_system.py +70 -0
  19. django_migration_zero-0.1.0/django_migration_zero/helpers/logger.py +8 -0
  20. django_migration_zero-0.1.0/django_migration_zero/locale/de/LC_MESSAGES/django.po +45 -0
  21. django_migration_zero-0.1.0/django_migration_zero/management/__init__.py +0 -0
  22. django_migration_zero-0.1.0/django_migration_zero/management/commands/__init__.py +0 -0
  23. django_migration_zero-0.1.0/django_migration_zero/management/commands/handle_migration_reset.py +60 -0
  24. django_migration_zero-0.1.0/django_migration_zero/management/commands/reset_local_migration_files.py +21 -0
  25. django_migration_zero-0.1.0/django_migration_zero/managers.py +25 -0
  26. django_migration_zero-0.1.0/django_migration_zero/migrations/0001_initial.py +32 -0
  27. django_migration_zero-0.1.0/django_migration_zero/migrations/__init__.py +0 -0
  28. django_migration_zero-0.1.0/django_migration_zero/models.py +40 -0
  29. django_migration_zero-0.1.0/django_migration_zero/services/__init__.py +0 -0
  30. django_migration_zero-0.1.0/django_migration_zero/services/local.py +39 -0
  31. django_migration_zero-0.1.0/django_migration_zero/settings.py +3 -0
  32. django_migration_zero-0.1.0/docs/Makefile +20 -0
  33. django_migration_zero-0.1.0/docs/conf.py +84 -0
  34. django_migration_zero-0.1.0/docs/features/changelog.rst +2 -0
  35. django_migration_zero-0.1.0/docs/index.rst +18 -0
  36. django_migration_zero-0.1.0/docs/make.bat +35 -0
  37. django_migration_zero-0.1.0/manage.py +22 -0
  38. django_migration_zero-0.1.0/pyproject.toml +175 -0
  39. django_migration_zero-0.1.0/pytest.init +2 -0
  40. django_migration_zero-0.1.0/scripts/unix/publish_to_pypi.sh +2 -0
  41. django_migration_zero-0.1.0/scripts/windows/publish_to_pypi.ps1 +2 -0
  42. django_migration_zero-0.1.0/settings.py +122 -0
  43. django_migration_zero-0.1.0/setup.cfg +3 -0
  44. django_migration_zero-0.1.0/tests/__init__.py +0 -0
@@ -0,0 +1,63 @@
1
+ from ambient_package_update.metadata.author import PackageAuthor
2
+ from ambient_package_update.metadata.constants import DEV_DEPENDENCIES, LICENSE_MIT
3
+ from ambient_package_update.metadata.package import PackageMetadata
4
+ from ambient_package_update.metadata.readme import ReadmeContent
5
+
6
+ METADATA = PackageMetadata(
7
+ package_name='django_migration_zero',
8
+ authors=[
9
+ PackageAuthor(
10
+ name='Ambient Digital',
11
+ email='hello@ambient.digital',
12
+ ),
13
+ ],
14
+ company='Ambient Innovation: GmbH',
15
+ license=LICENSE_MIT,
16
+ license_year=2023,
17
+ development_status='4 - Beta',
18
+ readme_content=ReadmeContent(
19
+ tagline="""Welcome to **django-migration-zero** - the holistic implementation of "migration zero" pattern for
20
+ Django covering local changes and CI/CD pipeline adjustments.
21
+
22
+ This package implements the "migration zero" pattern to clean up your local migrations and provides convenient
23
+ management commands to recreate your migration files and updating your migration history on your environments
24
+ (like test or production systems).""",
25
+ content="""## Features
26
+
27
+ * Remove all existing local migration files and recreate them as initial migrations
28
+ * Configuration singleton in Django admin to prepare your clean-up deployment
29
+ * Management command for your pipeline to update Django's migration history table to reflect the changed migrations
30
+
31
+ ## Motivation
32
+
33
+ Working with any proper ORM will result in database changes which are reflected in migration files to update your
34
+ different environment's database structure. These files are versioned in your repository and if you follow any of the
35
+ most popular deployment approaches, they won't be needed when they are deployed on production. This means, they clutter
36
+ your repo, might lead to merge conflicts in the future and will slow down your test setup.
37
+
38
+ Django's default way of handling this is called "squashing". This approach is covered broadly in the
39
+ (official documentation)[https://docs.djangoproject.com/en/dev/topics/migrations/#migration-squashing. The main
40
+ drawback here is, that you have to take care of circular dependencies between models. Depending on your project's
41
+ size, this can take a fair amount of time.
42
+
43
+ The main benefit of squashing migrations is, that the history stays intact, therefore it can be used for example in
44
+ package which can be installed by anybody and you don't have control over their database.
45
+
46
+ If you are working on a "regular" application, you have full control over your data(bases) and once everything has
47
+ been applied on the "last" system, typically production, the migrations are obsolete. To avoid spending much time on
48
+ fixing squashed migrations you won't need, you can use the "migration zero" pattern. In a nutshell, this means:
49
+
50
+ * Delete all your local migration files
51
+ * Recreate initial migration files containing your current model state
52
+ * Fix the migration history on every of your environments""",
53
+ ),
54
+ dependencies=[
55
+ 'Django>=3.2',
56
+ ],
57
+ optional_dependencies={
58
+ 'dev': [
59
+ *DEV_DEPENDENCIES,
60
+ ],
61
+ },
62
+ ruff_ignore_list=[],
63
+ )
@@ -0,0 +1,7 @@
1
+ [run]
2
+ omit =
3
+ setup.py,
4
+ *_test.py,
5
+ tests.py,
6
+ *tests*,
7
+ conftest.py
@@ -0,0 +1,18 @@
1
+ # http://editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.{py,rst,ini}]
12
+ indent_style = space
13
+ indent_size = 4
14
+ ij_continuation_indent_size = 8
15
+
16
+ [*.yml]
17
+ indent_style = space
18
+ indent_size = 2
@@ -0,0 +1,51 @@
1
+ name: Unit tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ '**' ]
6
+
7
+ jobs:
8
+ linting:
9
+ runs-on: ubuntu-22.04
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+
13
+ - name: Set up Python 3.12
14
+ uses: actions/setup-python@v3
15
+ with:
16
+ python-version: "3.12"
17
+
18
+ - name: Install required packages
19
+ run: pip install pre-commit
20
+
21
+ - name: Run pre-commit hooks
22
+ run: pre-commit run --all-files --hook-stage push
23
+
24
+ build:
25
+ name: Python ${{ matrix.python-version }}, django ${{ matrix.django-version }}
26
+ runs-on: ubuntu-22.04
27
+ strategy:
28
+ matrix:
29
+ python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
30
+ django-version: [32, 41, 42]
31
+
32
+ exclude:
33
+ - python-version: '3.12'
34
+ django-version: 32
35
+ - python-version: '3.11'
36
+ django-version: 32
37
+ - python-version: '3.10'
38
+ django-version: 32
39
+
40
+ steps:
41
+ - uses: actions/checkout@v3
42
+ - name: setup python
43
+ uses: actions/setup-python@v3
44
+ with:
45
+ python-version: ${{ matrix.python-version }}
46
+ - name: Install tox
47
+ run: pip install tox
48
+ - name: Run Tests
49
+ env:
50
+ TOXENV: django${{ matrix.django-version }}
51
+ run: tox
@@ -0,0 +1,160 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ .idea/
@@ -0,0 +1,30 @@
1
+ # you find the full pre-commit-tools docu under:
2
+ # https://pre-commit.com/
3
+
4
+ repos:
5
+ - repo: https://github.com/psf/black-pre-commit-mirror
6
+ rev: 23.9.1
7
+ hooks:
8
+ - id: black
9
+ args: [ --check, --diff, --config, ./pyproject.toml ]
10
+ stages: [ push ]
11
+
12
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
13
+ rev: 'v0.0.292'
14
+ hooks:
15
+ - id: ruff
16
+ args: [ --fix, --exit-non-zero-on-fix ]
17
+
18
+ - repo: https://github.com/asottile/pyupgrade
19
+ rev: v3.14.0
20
+ hooks:
21
+ - id: pyupgrade
22
+ args: [ --py38-plus ]
23
+ stages: [ push ]
24
+
25
+ - repo: https://github.com/adamchainz/django-upgrade
26
+ rev: 1.15.0
27
+ hooks:
28
+ - id: django-upgrade
29
+ args: [--target-version, "3.2"]
30
+ stages: [ push ]
@@ -0,0 +1,24 @@
1
+ # .readthedocs.yml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Set the version of Python and other tools you might need
9
+ build:
10
+ os: ubuntu-22.04
11
+ tools:
12
+ python: "3.11"
13
+
14
+ # Build documentation in the docs/ directory with Sphinx
15
+ sphinx:
16
+ configuration: docs/conf.py
17
+
18
+ # Optionally declare the Python requirements required to build your docs
19
+ python:
20
+ install:
21
+ - method: pip
22
+ path: .
23
+ extra_requirements:
24
+ - dev
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ambient Digital
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ambient Innovation: GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE.md
3
+ recursive-exclude * *.pyc
4
+ recursive-include django_migration_zero *.py *.html *.js *.cfg *.mo *.po
@@ -0,0 +1,222 @@
1
+ Metadata-Version: 2.1
2
+ Name: django-migration-zero
3
+ Version: 0.1.0
4
+ Summary: Holistic implementation of "migration zero" pattern for Django covering local changes and in-production database
5
+ Author-email: Ambient Digital <hello@ambient.digital>
6
+ Description-Content-Type: text/markdown
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Environment :: Web Environment
9
+ Classifier: Framework :: Django
10
+ Classifier: Framework :: Django :: 3.2
11
+ Classifier: Framework :: Django :: 4.1
12
+ Classifier: Framework :: Django :: 4.2
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Natural Language :: English
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Utilities
25
+ Requires-Dist: Django>=3.2
26
+ Requires-Dist: freezegun~=1.2 ; extra == "dev"
27
+ Requires-Dist: pytest-django~=4.5 ; extra == "dev"
28
+ Requires-Dist: pytest-mock~=3.10 ; extra == "dev"
29
+ Requires-Dist: pre-commit~=3.2 ; extra == "dev"
30
+ Requires-Dist: black~=23.3 ; extra == "dev"
31
+ Requires-Dist: Django~=3.2 ; extra == "dev"
32
+ Requires-Dist: sphinx==4.2.0 ; extra == "dev"
33
+ Requires-Dist: sphinx-rtd-theme==1.0.0 ; extra == "dev"
34
+ Requires-Dist: m2r2==0.3.1 ; extra == "dev"
35
+ Requires-Dist: mistune<2.0.0 ; extra == "dev"
36
+ Requires-Dist: ambient-package-update~=23.10.1 ; extra == "dev"
37
+ Project-URL: Bugtracker, https://github.com/ambient-innovation/django-migration-zero/issues
38
+ Project-URL: Changelog, https://django-migration-zero.readthedocs.io/en/latest/features/changelog.html
39
+ Project-URL: Documentation, https://django-migration-zero.readthedocs.io/en/latest/index.html
40
+ Project-URL: Homepage, https://github.com/ambient-innovation/django-migration-zero/
41
+ Project-URL: Maintained by, https://ambient.digital/
42
+ Provides-Extra: dev
43
+
44
+ [![PyPI release](https://img.shields.io/pypi/v/django-migration-zero.svg)](https://pypi.org/project/django-migration-zero/)
45
+ [![Downloads](https://static.pepy.tech/badge/django-migration-zero)](https://pepy.tech/project/django-migration-zero)
46
+ [![Linting](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
47
+ [![Coding Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
48
+ [![Documentation Status](https://readthedocs.org/projects/django-migration-zero/badge/?version=latest)](https://django-migration-zero.readthedocs.io/en/latest/?badge=latest)
49
+
50
+ Welcome to **django-migration-zero** - the holistic implementation of "migration zero" pattern for
51
+ Django covering local changes and CI/CD pipeline adjustments.
52
+
53
+ This package implements the "migration zero" pattern to clean up your local migrations and provides convenient
54
+ management commands to recreate your migration files and updating your migration history on your environments
55
+ (like test or production systems).
56
+
57
+ * [PyPI](https://pypi.org/project/django-migration-zero/)
58
+ * [GitHub](https://github.com/ambient-innovation/django-migration-zero)
59
+ * [Full documentation](https://django-migration-zero.readthedocs.io/en/latest/index.html)
60
+ * Creator & Maintainer: [Ambient Digital](https://ambient.digital)
61
+
62
+ ## Features
63
+
64
+ * Remove all existing local migration files and recreate them as initial migrations
65
+ * Configuration singleton in Django admin to prepare your clean-up deployment
66
+ * Management command for your pipeline to update Django's migration history table to reflect the changed migrations
67
+
68
+ ## Motivation
69
+
70
+ Working with any proper ORM will result in database changes which are reflected in migration files to update your
71
+ different environment's database structure. These files are versioned in your repository and if you follow any of the
72
+ most popular deployment approaches, they won't be needed when they are deployed on production. This means, they clutter
73
+ your repo, might lead to merge conflicts in the future and will slow down your test setup.
74
+
75
+ Django's default way of handling this is called "squashing". This approach is covered broadly in the
76
+ (official documentation)[https://docs.djangoproject.com/en/dev/topics/migrations/#migration-squashing. The main
77
+ drawback here is, that you have to take care of circular dependencies between models. Depending on your project's
78
+ size, this can take a fair amount of time.
79
+
80
+ The main benefit of squashing migrations is, that the history stays intact, therefore it can be used for example in
81
+ package which can be installed by anybody and you don't have control over their database.
82
+
83
+ If you are working on a "regular" application, you have full control over your data(bases) and once everything has
84
+ been applied on the "last" system, typically production, the migrations are obsolete. To avoid spending much time on
85
+ fixing squashed migrations you won't need, you can use the "migration zero" pattern. In a nutshell, this means:
86
+
87
+ * Delete all your local migration files
88
+ * Recreate initial migration files containing your current model state
89
+ * Fix the migration history on every of your environments
90
+
91
+
92
+
93
+
94
+ ## Installation
95
+
96
+
97
+ - Install the package via pip:
98
+
99
+ `pip install django-migration-zero`
100
+
101
+ or via pipenv:
102
+
103
+ `pipenv install django-migration-zero`
104
+
105
+ - Add module to `INSTALLED_APPS` within the main django `settings.py`:
106
+
107
+ ````
108
+ INSTALLED_APPS = (
109
+ ...
110
+ 'django_migration_zero',
111
+ )
112
+ ````
113
+
114
+
115
+ ## Contribute
116
+
117
+ ### Setup package for development
118
+
119
+ - Create a Python virtualenv and activate it
120
+ - Install "pip-tools" with `pip install pip-tools`
121
+ - Compile the requirements with `pip-compile --extra dev, -o requirements.txt pyproject.toml --resolver=backtracking`
122
+ - Sync the dependencies with your virtualenv with `pip-sync`
123
+
124
+ ### Add functionality
125
+
126
+ - Create a new branch for your feature
127
+ - Change the dependency in your requirements.txt to a local (editable) one that points to your local file system:
128
+ `-e /Users/workspace/django-migration-zero` or via pip `pip install -e /Users/workspace/django-migration-zero`
129
+ - Ensure the code passes the tests
130
+ - Create a pull request
131
+
132
+ ### Run tests
133
+
134
+ - Run tests
135
+ ````
136
+ pytest --ds settings tests
137
+ ````
138
+
139
+ ### Git hooks (via pre-commit)
140
+
141
+ We use pre-push hooks to ensure that only linted code reaches our remote repository and pipelines aren't triggered in
142
+ vain.
143
+
144
+ To enable the configured pre-push hooks, you need to [install](https://pre-commit.com/) pre-commit and run once:
145
+
146
+ pre-commit install -t pre-push -t pre-commit --install-hooks
147
+
148
+ This will permanently install the git hooks for both, frontend and backend, in your local
149
+ [`.git/hooks`](./.git/hooks) folder.
150
+ The hooks are configured in the [`.pre-commit-config.yaml`](templates/.pre-commit-config.yaml.tpl).
151
+
152
+ You can check whether hooks work as intended using the [run](https://pre-commit.com/#pre-commit-run) command:
153
+
154
+ pre-commit run [hook-id] [options]
155
+
156
+ Example: run single hook
157
+
158
+ pre-commit run ruff --all-files --hook-stage push
159
+
160
+ Example: run all hooks of pre-push stage
161
+
162
+ pre-commit run --all-files --hook-stage push
163
+
164
+ ### Update documentation
165
+
166
+ - To build the documentation run: `sphinx-build docs/ docs/_build/html/`.
167
+ - Open `docs/_build/html/index.html` to see the documentation.
168
+
169
+ ### Translation files
170
+
171
+ If you have added custom text, make sure to wrap it in `_()` where `_` is
172
+ gettext_lazy (`from django.utils.translation import gettext_lazy as _`).
173
+
174
+ How to create translation file:
175
+
176
+ * Navigate to `django-migration-zero`
177
+ * `python manage.py makemessages -l de`
178
+ * Have a look at the new/changed files within `django_migration_zero/locale`
179
+
180
+ How to compile translation files:
181
+
182
+ * Navigate to `django-migration-zero`
183
+ * `python manage.py compilemessages`
184
+ * Have a look at the new/changed files within `django_migration_zero/locale`
185
+
186
+ ### Publish to ReadTheDocs.io
187
+
188
+ - Fetch the latest changes in GitHub mirror and push them
189
+ - Trigger new build at ReadTheDocs.io (follow instructions in admin panel at RTD) if the GitHub webhook is not yet set
190
+ up.
191
+
192
+ ### Publish to PyPi
193
+
194
+ - Update documentation about new/changed functionality
195
+
196
+ - Update the `Changelog`
197
+
198
+ - Increment version in main `__init__.py`
199
+
200
+ - Create pull request / merge to master
201
+
202
+ - This project uses the flit package to publish to PyPI. Thus publishing should be as easy as running:
203
+ ```
204
+ flit publish
205
+ ```
206
+
207
+ To publish to TestPyPI use the following ensure that you have set up your .pypirc as
208
+ shown [here](https://flit.readthedocs.io/en/latest/upload.html#using-pypirc) and use the following command:
209
+
210
+ ```
211
+ flit publish --repository testpypi
212
+ ```
213
+
214
+ ### Maintenance
215
+
216
+ Please note that this package supports the [ambient-package-update](https://pypi.org/project/ambient-package-update/).
217
+ So you don't have to worry about the maintenance of this package. All important configuration and setup files are
218
+ being rendered by this updater. It works similar to well-known updaters like `pyupgrade` or `django-upgrade`.
219
+
220
+ To run an update, refer to the [documentation page](https://pypi.org/project/ambient-package-update/)
221
+ of the "ambient-package-update".
222
+