Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 0010_auto_20200508_1851 migration doesn't seem to be reversable #291

Open
Lorac opened this issue Jul 5, 2024 · 3 comments
Open

The 0010_auto_20200508_1851 migration doesn't seem to be reversable #291

Lorac opened this issue Jul 5, 2024 · 3 comments

Comments

@Lorac
Copy link

Lorac commented Jul 5, 2024

After I imported the data, I wanted to restart fresh, so I tried to migrate backward.

  Unapplying cities_light.0010_auto_20200508_1851...Traceback (most recent call last):
  File ".../lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UniqueViolation: could not create unique index "cities_light_city_region_id_name_29b81cd4_uniq"
DETAIL:  Key (region_id, name)=(57, Neston) is duplicated.

Since I wanted to restart fresh, I deleted the offending cities. But I got more from the slug, too:

  Unapplying cities_light.0010_auto_20200508_1851...Traceback (most recent call last):
  File ".../.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UniqueViolation: could not create unique index "cities_light_city_region_id_slug_dc18c213_uniq"
DETAIL:  Key (region_id, slug)=(57, ashford) is duplicated.

Since there is duplication, It is impossible to revert to the old unique_together key which is : 'unique_together': set([('region', 'name'), ('region', 'slug')]),

image

@Lorac Lorac changed the title 0010_auto_20200508_1851 doesn't seem to be reversable The 0010_auto_20200508_1851 migration doesn't seem to be reversable Jul 5, 2024
@marianoeramirez
Copy link
Collaborator

Thats right. You should delete the duplicate row manually before revert.

@Lorac
Copy link
Author

Lorac commented Jul 5, 2024

Would it be possible to squash all the migrations together?

@marianoeramirez
Copy link
Collaborator

It's not recommended because of this public library is being used across multiple servers in different situations. There are on other status and we want to allow them to move to a new version of the library without any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants