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

Bug: Missing Migrations for Updated Models in Wagtail Videos Package #118

Open
wajeshubham opened this issue Jan 4, 2024 · 3 comments
Open

Comments

@wajeshubham
Copy link

wajeshubham commented Jan 4, 2024

Issue Description

When installing the latest version of wagtailvideos, the package appears to be missing necessary migrations for the updated models. This leads to issues in generating new migrations in projects that depend on wagtailvideos.

Specifically, when running python manage.py migrate, it results in a NodeNotFoundError due to a missing migration dependency.

Steps to Reproduce

  1. Install the latest version of wagtailvideos.
  2. Attempt to create new migrations in a project that uses wagtailvideos. (After adding video field in one of my app's models)
  3. Here is the output after running python manage.py makemigrations.
WARNINGS:
?: (wagtailvideos.W001) ffmpeg could not be found on your system. Transcoding will be disabled
Migrations for 'wagtailvideos':
  /usr/local/lib/python3.11/site-packages/wagtailvideos/migrations/0015_alter_tracklisting_id_alter_video_id_and_more.py
    - Alter field id on tracklisting
    - Alter field id on video
    - Alter field id on videotrack
    - Alter field id on videotranscode
Migrations for 'contestants':
  iha_cms/contestants/migrations/0006_contestant_video.py # my local app
    - Add field video to contestant
  1. Run python manage.py migrate.

Expected Behavior

The migration process should complete without errors, with all dependencies correctly resolved.

Actual Behavior

The migration process fails with the following error:

raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration contestants.0006_contestant_video dependencies reference nonexistent parent node ('wagtailvideos', '0015_alter_tracklisting_id_alter_video_id_and_more')

Additional Information

Below is the generated migration file that causes the issue:

# Generated by Django 4.2.8 on 2024-01-04 13:12

from django.db import migrations, models
import django.db.models.deletion

class Migration(migrations.Migration):
    dependencies = [
        ("wagtailvideos", "0015_alter_tracklisting_id_alter_video_id_and_more"), # this migration file is getting created on the fly
        ("contestants", "0005_alter_vote_contestant_alter_vote_user"),
    ]

    operations = [
        migrations.AddField(
            model_name="contestant",
            name="video",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="+",
                to="wagtailvideos.video",
            ),
        ),
    ]

This issue indicates that the migration 0015_alter_tracklisting_id_alter_video_id_and_more is either missing or not pushed to the repository.

⁉️ Following way make it work (not sure if this is a correct way. LMK)

Updating the above migration file by changing wagtailvideos dependency as follows will resolve the issue

# ... same code

class Migration(migrations.Migration):
    dependencies = [
        ("wagtailvideos", "0014_alter_videotrack_file_alter_videotrack_kind_and_more"), # last migration file in wagtailvideos migrations
        ("contestants", "0005_alter_vote_contestant_alter_vote_user"),
    ]

    # ... same code

0014_alter_videotrack_file_alter_videotrack_kind_and_more being the latest migrations file from wagtailvideos package.

Suggested Fix

Please review the recent model changes in wagtailvideos and ensure that all necessary migrations are included in the package and pushed to the repository.


Environment

  • Wagtail Videos Version: 5.2.0
  • Wagtail Version: 5.2.2
  • Django Version: 4.2.8
  • Python Version: 3.11
  • Operating System: MacOS
@wajeshubham wajeshubham changed the title Missing Migrations for Updated Models in Wagtail Videos Package Bug: Missing Migrations for Updated Models in Wagtail Videos Package Jan 4, 2024
@seb-b
Copy link
Member

seb-b commented Jan 7, 2024

Hi @wajeshubham, I've tried to replicate this problem and not having much luck. Did you happen to upgrade django at the same time? There wasn't any changes made to the models in the version just released, but because the migrations are trying to update the id field makes me think it might have something to do with the default auto field setting? https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

@wajeshubham
Copy link
Author

Ahh! I see.

Thanks for your prompt response @seb-b . Yes, this problem persisted when I added wagtailvideos field in one of m y models, I understand your point regarding the possibility that this issue might be related to Django's default auto field setting. However, in my case, altering the default auto field setting isn't a viable option, as my project relies on dynamically creating primary keys for all the models.

Considering this, I'm curious if there's a workaround or solution that can be implemented within the wagtailvideos package itself. This would ideally address the migration dependencies without requiring significant changes to the existing Django settings or model configurations in projects that use wagtailvideos.

Is there a way we can ensure that the migrations within wagtailvideos are compatible with the dynamic creation of primary keys, as necessitated by the recent Django versions? Any guidance or alternative solutions you can provide would be greatly appreciated, as this seems to be a critical issue affecting the integration of wagtailvideos in projects with similar configurations.

Looking forward to your suggestions or insights on this matter. Cheers! :-D

@seb-b
Copy link
Member

seb-b commented Jan 8, 2024

@wajeshubham , I've just released version 5.2.1 with a possible fix, can you let me know if makemigrations still attempts to create a migration for wagtailvideos?

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