Ticket #992 (accepted defect)

Opened 3 years ago

Last modified 3 years ago

Primary Key: SlugField to CharField

Reported by: guettli Owned by: andrew
Priority: minor Milestone: 1.0
Component: migrations Version: unknown
Keywords: Cc: hv@…

Description

I changed a SlugField? to CharField? of a primary key.

# models.py
  class EmailSender(models.Model):
-    id=models.SlugField(primary_key=True)
+    id=models.CharField(primary_key=True, max_length=50, validators=[RegexValidator(r'^[a-zA-Z0-9_.-]+$')])

The migration created with --auto looks like this:

#migration
class Migration(SchemaMigration):

     def forwards(self, orm):

         # Changing field 'EmailSender.id'
         db.alter_column('modwork_emailsender', 'id', self.gf('django.db.models.fields.CharField')(max_length=50,
primary_key=True))

         # Removing index on 'EmailSender', fields ['id']
         db.delete_index('modwork_emailsender', ['id'])

{{{ psql \d modwork_emailsender
modwork_tbz_d=> \d modwork_emailsender

Table "public.modwork_emailsender"

Column | Type | Modifiers


id | character varying(50) | not null
email | character varying(75) | not null
footer | text |

Indexes:

"modwork_emailsender_pkey" PRIMARY KEY, btree (id)
"modwork_emailsender_email_uniq" UNIQUE, btree (email)

}}}

2012-01-13 10:04:36 generic: DEBUG south execute "DROP INDEX "modwork_emailsender_id"" with params "[]"
django.db.utils.DatabaseError?: ERROR: Index »modwork_emailsender_id« does not exist

I removed the "delete_index()" and the migration was successfull.

south version:

hg summary
parent: 997:fcf464bd036f tip
 Fixed the timezone handling by simply converting the timezone aware datetime object into a naive version with the help of the default timezone (aka settings.TIME_ZONE).
branch: default
commit: 1 unknown (clean)
update: (current)

Related: http://groups.google.com/group/south-users/browse_thread/thread/90ca1d17285df720/33b1c6233f06f1c8?show_docid=33b1c6233f06f1c8

Change History

comment:1 Changed 3 years ago by andrew

  • Status changed from new to accepted
  • Milestone set to 1.0

comment:2 Changed 3 years ago by guettli

I am sorry, I could not find a way to fix the markup of the description.

Note: See TracTickets for help on using tickets.