Skip to content

When running pytest on a database with --reuse-db where python manage.py migrate was already run, cause failure on old runpython #756

Open
@allan-simon

Description

@allan-simon

I explain myself,

I have a project with a lot of migrations, with 3 important migrations for our case (in that order):

  1. a migration that add the field foo to the model Bar
  2. a migration that has a RunPython, doing some computation based on the field foo
  3. a migration that remove the field foo

now if i first do

python manage.py migrate

I finish with a database without field foo => normal and expected

if I then run pytest --reuse-db I will got SQL failure because pytest re-runs all migrations, but without actually replaying the changes on the database , but only running the RunPython, so the RunPython of 2) is run on database were the field has already been removed

is it a known behaviour , if so why ?

I would have thought that it would see migrations has been run , and will not execute anything, runpython included

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