question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Embed Uniqueness Issues on 2.12

See original GitHub issue

Issue Summary

Embed uniqueness was not enforced at a db level pre-2.12, so it is possible for https://github.com/wagtail/wagtail/blob/master/wagtail/embeds/migrations/0008_allow_long_urls.py to fail during upgrade. (Additionally, because the uniqueness is enforced on the hash, rather than the url, there seems to be an additional issue with certain url strings that are apparently unique in postgres (a url_count annotation is 1 for both) but equal in Python, but I haven’t worked out exactly what the problem is here)

Steps to Reproduce

  1. Start a new project with wagtail start myproject on Wagtail 2.11, making sure the embeds app is added
  2. Enter the django shell
  3. Create two Embeds objects with the same url using Embed.objects.create
  4. Attempt the 2.12 upgrade

Technical details

  • Python version: 3.6.4
  • Django version: 2.2.13
  • Wagtail version: 2.11.3 -> 2.12
  • Browser version: N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
hanzvanaardtcommented, Nov 30, 2021

I ran into the same issue. It turns out that the issue is caused by a migration using pgloader (in my case this was done from SQLite to Postgres) but it could be from other databases as well. PGLoader converts constraints by creating them as indexes in PostgreSQL whereas with Django Migrations they are created as constraints. So during the migration the constraint is not found and an error is reported.
The issue can be resolved by following these steps: Enter the DB Shell ( python manage.py dbshell ) Step 1: DROP INDEX wagtailembeds_embed_url_max_width_8a2922d8_uniq; Step 2: ALTER TABLE public.wagtailembeds_embed ADD CONSTRAINT wagtailembeds_embed_url_max_width_8a2922d8_uniq UNIQUE(url, max_width);

If the above DROP INDEX does not work in Step 1 then execute \d wagtailembeds_embed to get the correct INDEX name.

2reactions
the-wong-devcommented, Jun 9, 2021

I just resolved this same issue and the solution is pretty simple, especially if you have a GUI to interact with the database (I’m using HeidiSQL). For reference, I’m on Wagtail 2.13.1 and Django 3.2.4.

  1. Drop the wagtailembeds_embed table.
  2. Remove all ‘wagtailembeds’ migrations from the django_migrations table.
  3. Run ‘python manage.py migrate’.

It’ll just rebuild the whole table cleanly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uniqueness Constraint Migration | Mendix ... - Mendix Docs
After some time, the data structure is changed, because logic has been added to the app that only allows one Address per Person....
Read more >
Uniqueness in Interchange - Axway Documentation Portal
In order to process message flows in a coherent and predictable manner, Interchange enforces the uniqueness of object names.
Read more >
GLOBAL UNIQUENESS AND STABILITY IN DETERMINING ...
GLOBAL UNIQUENESS AND STABILITY IN DETERMINING COEFFICIENTS OF WAVE EQUATIONS · 1. INTRODUCTION AND MAIN RESULT · 2. CARLEMAN ESTIMATE · 3. LINEARIZED...
Read more >
SQL Performance Best Practices | CockroachDB Docs
This issue is particularly relevant when using a simple SQL table of two columns ... The best practices for generating unique IDs in...
Read more >
Embedding laws in diffusions by functions of time
Skorokhod embedding, Brownian motion, diffusion process, Markov ... lem and prove the existence and uniqueness of functions of time for general target.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found