Skip to content

"Relation {table} does not exist" when creating using prototype modelΒ #376

@benwad

Description

@benwad

Hi, I couldn't find anything about this issue so I thought I'd post it here. I have a test like this:

@pytest.mark.django_db
def test_0104_migration(migrator_factory):
    migrator = migrator_factory("default")
    old_state = migrator.apply_initial_migration(("my_app", "0103_previous_migration"))
    Overlay = old_state.apps.get_model("my_app", "Overlay")
    OverlayVersion = old_state.apps.get_model("my_app", "OverlayVersion")
    Video = old_state.apps.get_model("my_other_app", "Video")

    video_1 = Video.objects.create() # This is where the error happens
    overlay_no_current_version = Overlay.objects.create(video=video_1,)

This gives me the error: django.db.utils.ProgrammingError: relation "my_app_video" does not exist.

I also get the following error during teardown: psycopg2.errors.UndefinedTable: relation "django_content_type" does not exist

The test is running inside docker, with Postgres as the DB backend. Is there something I'm missing with apply_initial_migration which might not be creating these tables? I also tried Overlay.objects.create and OverlayVersion.objects.create and I get the same error. How could I go about debugging this? The migration itself works, and I've rebuilt the whole container and run the whole migration graph a number of times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions