Skip to content

Instantly share code, notes, and snippets.

@marceloleiva
Created February 20, 2025 01:02
Show Gist options
  • Select an option

  • Save marceloleiva/6bc1cca751832991c748302b233869bc to your computer and use it in GitHub Desktop.

Select an option

Save marceloleiva/6bc1cca751832991c748302b233869bc to your computer and use it in GitHub Desktop.
Restablecer migraciones en Django

Eliminar los archivos de migraciones:

find . -not -path "./.venv/*" -path "*/migrations/*.py" ! -name "__init__.py" -delete

Volver a generar las migraciones:

python manage.py makemigrations

Eliminar la tabla de migraciones:

python manage.py shell -c "from django.db import connection; cursor = connection.cursor(); cursor.execute('DROP TABLE django_migrations;');"

Realizar la migración:

python manage.py migrate --fake

Ejemplo obtenido desde https://medium.com/django-unleashed/how-to-reset-your-django-migrations-3717228054a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment