Wednesday, March 27, 2013

South Error in migration:

I can't find a similar scenario in the list archives, so .....

I had run the initial migration, etc and all seemed fine.

I modified one model from this:
class CCD(models.Model):
rm_version = models.ForeignKey(RMversion, related_name='%(class)s_related+')
...

to this:
class CCD(models.Model):
prj_name = models.ForeignKey(Project, verbose_name="Project Name")
...

The new ForeignKey in CCD, points to this, which already has the
RMversion relation.

class Project(models.Model):
prj_name = models.CharField("project name", max_length=110, unique=True)
rm_version = models.ForeignKey(RMversion, related_name='%(class)s_related+')
owner_group = models.CharField(max_length=110) #must be a member
of this group to edit this project

During the migration, here are the prompts and my responses:

(django)tim@tim-us_12-04:~/webapp/apps/mlhim$ python manage.py
schemamigration ccdgen --auto
? The field 'CCD.rm_version' does not have a default specified, yet
is NOT NULL.
? Since you are removing this field, you MUST specify a default
? value to use for existing rows. Would you like to:
? 1. Quit now, and add a default to the field in models.py
? 2. Specify a one-off value to use for existing columns now
? 3. Disable the backwards migration by raising an exception.
? Please select a choice: 2
? Please enter Python code for your one-off default value.
? The datetime module is available, so you can do e.g. datetime.date.today()
>>> See Project Value
! Invalid input: invalid syntax (<string>, line 1)
>>> "See Project RM"
- Deleted field rm_version on ccdgen.CCD
? The field 'CCD.prj_name' does not have a default specified, yet is NOT NULL.
? Since you are adding this field, you MUST specify a default
? value to use for existing rows. Would you like to:
? 1. Quit now, and add a default to the field in models.py
? 2. Specify a one-off value to use for existing columns now
? Please select a choice: 2
? Please enter Python code for your one-off default value.
? The datetime module is available, so you can do e.g. datetime.date.today()
>>> "2.4.2"
+ Added field prj_name on ccdgen.CCD
Created 0002_auto__del_field_ccd_rm_version__add_field_ccd_prj_name.py.
You can now apply this migration with: ./manage.py migrate ccdgen
(django)tim@tim-us_12-04:~/webapp/apps/mlhim$ python manage.py migrate ccdgen
Running migrations for ccdgen:
- Migrating forwards to
0002_auto__del_field_ccd_rm_version__add_field_ccd_prj_name.
> ccdgen:0001_initial
FATAL ERROR - The following SQL query failed: CREATE TABLE
"ccdgen_rmversion" ("id" serial NOT NULL PRIMARY KEY, "version_id"
varchar(10) NOT NULL UNIQUE);
The error was: relation "ccdgen_rmversion" already exists

Error in migration: ccdgen:0001_initial
DatabaseError: relation "ccdgen_rmversion" already exists


So, I have this "already exists" error.

Any hints on how to fix this?

Here is what is installed:
Django==1.5
South==0.7.6
Unipath==0.2.1
argparse==1.2.1
distribute==0.6.24
django-extensions==1.1.1
docutils==0.10
psycopg2==2.4.6
six==1.2.0
wsgiref==0.1.2

Using Postgres-9.1 on Unbuntu 12.04LTS


As always, THANKS!!!

--Tim



--
============================================
Timothy Cook, MSc +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment