diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..ae5be94 --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,7 @@ +0.1.1 - Released 2024-09-26 +* Minor format changes +* Removed an unnecessary default value +* Changed `print()` to `self.stdout.write()` in the migration commands + +0.1.0 - Initial public release +* Updated the name of the project to "drifter" diff --git a/pyproject.toml b/pyproject.toml index d9e3fff..887d0a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ description = "More migration commands to make development life simpler" license = { file = "LICENSE.txt" } name = "django-drifter" requires-python = ">=3.10" -version = "0.1.0" +version = "0.1.1" [project.optional-dependencies] development = [ diff --git a/src/__init__.py b/src/__init__.py index 3dc1f76..485f44a 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" diff --git a/src/drifter/management/commands/redo_migration.py b/src/drifter/management/commands/redo_migration.py index 0755c82..eec116d 100644 --- a/src/drifter/management/commands/redo_migration.py +++ b/src/drifter/management/commands/redo_migration.py @@ -29,7 +29,7 @@ def handle(self, *args: object, **options: object) -> None: cursor.execute("PRAGMA foreign_keys = OFF") query = "SELECT * FROM django_migrations" - app_name = options.get("app", None) + app_name = options.get("app") if app_name: query += " WHERE app=%s " query += " ORDER BY id DESC LIMIT 1" @@ -37,7 +37,7 @@ def handle(self, *args: object, **options: object) -> None: cursor.execute(query, [app_name]) last_migration = cursor.fetchone() if last_migration is None: - print("No migrations to redo") + self.stdout.write(self.style.WARNING("No migrations to redo")) return app_name = last_migration[1] diff --git a/src/drifter/management/commands/revert_migration.py b/src/drifter/management/commands/revert_migration.py index f6f41fc..0692771 100644 --- a/src/drifter/management/commands/revert_migration.py +++ b/src/drifter/management/commands/revert_migration.py @@ -38,14 +38,17 @@ def handle(self, *args: object, **options: object) -> None: if migration_name.startswith("0001"): migration_name = "zero" # Reset to initial state else: # get previous migration name - query = "SELECT * FROM django_migrations WHERE app=%s AND id < %s ORDER BY id DESC LIMIT 1" + query = ("SELECT * FROM django_migrations WHERE app=%s " + "AND id < %s ORDER BY id DESC LIMIT 1") cursor.execute(query, [app_name, migration[0]]) previous_migration = cursor.fetchone() if previous_migration is not None: migration_name = previous_migration[2] try: - print(f"Reverting {app_name} to {migration_name}") + self.stdout.write(self.style.SUCCESS( + f"Reverting {app_name} to {migration_name}" + )) call_command("migrate", app_name, migration_name) except CommandError as err: error = "Error reverting migration"