Reputation: 3092
I know the problem but this doesn't to make sense because I thought South would handle this. I am trying to install a new STAGING server, so a new DB but I am getting south migration errors.
I have 2 apps, bar
and foo
, and below are the models.
I had a Foo dependent on Bar in the 0001_foo_initial
migrations. But then I removed Bar
and the also dependency because i didn't need them.
#in foo.models
class Foo(models.Model)
#bar = models.ForeignKey(Bar...) #dependency removed in foo 2nd migration
foo_name..
"""bar.models - removed in bar 2nd migration
class Bar(models.Model)
bar_name...
"""
#bar
0001_bar_initial.py - had Bar model
0002_bar_model_Bar_deleted.py - removed Bar model
#foo
0001_foo_initial.py - foo with bar dependency
0002_foo_foreign_key_bar_deleted.py - remove dependency
So when I ran migrate --all
and I am getting relationship doesn't exists in 0001_foo_initial.py
because its trying to add the dependency.
It seems it ran the bar
migrations first, which deleted the Bar
. It then attempts to run 0001_foo_initial
but since Bar
is already removed, it throws the error.
How do I go about fixing this error or did I miss something. I could delete the lines that have the dependency [e.g. remove the dependency in 0001_foo_initial.py] but then I will have to do lotta house maintenance for that, e.g. I will have to remove the file 0002_foo_foreign_key_bar_deleted
since there is none.
Upvotes: 2
Views: 79
Reputation: 474191
Don't run migrations on a new database server. Instead run syncdb
and make your existing migrations faked
via migrate --fake
.
syncdb
will create your current models structure in the database. Faking migrations is necessary for saying south
that migrations don't need to be applied.
Hope I've explained that well.
Upvotes: 1