Skip to content

Commit

Permalink
Use ORM to reset django_migrations table (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-anne committed Jul 15, 2024
1 parent d59b553 commit b4c8d25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

* *master* (unreleased)
* Use ORM to reset `django_migrations` table

* *2.1.0* (2024-07-09)
* Discover apps in nested directories
* Use `BASE_DIR` instead of `MIGRATION_ZERO_APPS_DIR`
Expand Down
5 changes: 2 additions & 3 deletions django_migration_zero/services/deployment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from logging import Logger

from django.core.management import call_command
from django.db import connections
from django.db.migrations.recorder import MigrationRecorder

from django_migration_zero.exceptions import InvalidMigrationTreeError
from django_migration_zero.helpers.logger import get_logger
Expand Down Expand Up @@ -34,8 +34,7 @@ def process(self):
# records of the other ones
self.logger.info("Resetting migration history for all apps...")

with connections["default"].cursor() as cursor:
cursor.execute("DELETE FROM `django_migrations`")
MigrationRecorder.Migration.objects.all().delete()

# Apply migrations via fake because the database is already up-to-date
self.logger.info("Populating migration history.")
Expand Down

0 comments on commit b4c8d25

Please sign in to comment.