Adjust default behavior of "migrate" command (#12320)
* Adjust default behavior of "migrate" command
- Does not create new migration files automatically
* Add dummy field - ensure detected by CI
* Revert "Add dummy field - ensure detected by CI"
This reverts commit e7a101fe87.
* Fix typo
* Adjust contributing docs
* Add CHANGELOG entry
This commit is contained in:
parent
d041e251d2
commit
996dbc5aa8
|
|
@ -46,4 +46,6 @@ jobs:
|
|||
run: |
|
||||
python ./.github/scripts/check_source_strings.py --frontend --backend
|
||||
- name: Check Migration Files
|
||||
run: python3 .github/scripts/check_migration_files.py
|
||||
run: |
|
||||
invoke migrate --detect
|
||||
python3 .github/scripts/check_migration_files.py
|
||||
|
|
|
|||
|
|
@ -405,7 +405,9 @@ jobs:
|
|||
- name: Test Translations
|
||||
run: invoke dev.translate
|
||||
- name: Check Migration Files
|
||||
run: python3 .github/scripts/check_migration_files.py
|
||||
run: |
|
||||
invoke migrate --detect
|
||||
python3 .github/scripts/check_migration_files.py
|
||||
- name: Coverage Tests
|
||||
run: invoke dev.test --check --coverage --translations
|
||||
- name: Upload raw coverage to artifacts
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Breaking Changes
|
||||
|
||||
- [#12320](https://github.com/inventree/InvenTree/pull/12320) changes the default behavior of the `invoke migrate` command. Now, it no longer generates new migrations by default. Instead, it will only apply existing migrations to the database. If you want to detect and generate new migrations, you must now explicitly use the `--detect` flag. This change was made to prevent accidental generation of migrations when running the command, which could lead to unexpected changes in the database schema. Additionally, `invoke update` will no longer result in new migrations being generated, and will only apply existing migrations to the database. This change was made to ensure that the update process is predictable and does not introduce unexpected changes to the database schema.
|
||||
- [#12223](https://github.com/inventree/InvenTree/pull/12223) removes support for python 3.11 and stops providing packages for Debian 11 and Ubuntu 20.04.
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ The project uses [Invoke](https://www.pyinvoketasks.com/) (`tasks.py`) as the ta
|
|||
# One-time setup: creates venv at dev/venv/, installs deps, sets up pre-commit hooks
|
||||
invoke dev.setup-dev
|
||||
|
||||
# Apply database migrations
|
||||
invoke migrate
|
||||
# Apply database migrations (and detect/create new migration files if required)
|
||||
invoke migrate --detect
|
||||
|
||||
# Create an admin account (required to log in)
|
||||
invoke superuser
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ django-upgrade --target-version {{ config.extra.django_version }} `find . -name
|
|||
|
||||
## Migration Files
|
||||
|
||||
Any required migration files **must** be included in the commit, or the pull-request will be rejected. If you change the underlying database schema, make sure you run `invoke migrate` and commit the migration files before submitting the PR.
|
||||
Any required migration files **must** be included in the commit, or the pull-request will be rejected. If you change the underlying database schema, make sure you run `invoke migrate --detect` and commit the migration files before submitting the PR.
|
||||
|
||||
*Note: A github action checks for unstaged migration files and will reject the PR if it finds any!*
|
||||
|
||||
|
|
|
|||
9
tasks.py
9
tasks.py
|
|
@ -1070,10 +1070,13 @@ def listbackups(c):
|
|||
},
|
||||
)
|
||||
@state_logger
|
||||
def migrate(c, detect: bool = True, verbose: bool = False):
|
||||
"""Performs database migrations.
|
||||
def migrate(c, detect: bool = False, verbose: bool = False):
|
||||
"""Performs database migrations. This is a critical step if the database schema has been altered.
|
||||
|
||||
This is a critical step if the database schema have been altered!
|
||||
Arguments:
|
||||
c: Command line context.
|
||||
detect: Whether to detect and create new migrations based on changes to models. Default is False.
|
||||
verbose: Whether to print verbose output from migration commands. Default is False.
|
||||
"""
|
||||
info('Running InvenTree database migrations...')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue