Embed Uniqueness Issues on 2.12
See original GitHub issueIssue 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
- Start a new project with
wagtail start myproject
on Wagtail 2.11, making sure the embeds app is added - Enter the django shell
- Create two Embeds objects with the same url using
Embed.objects.create
- 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:
- Created 3 years ago
- Comments:15 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.
It’ll just rebuild the whole table cleanly.