Ticket #435 (assigned defect)

Opened 5 years ago

Last modified 4 years ago

Changing a ForeignKey from a "real" model to a proxy of it generates invalid migration code

Reported by: Ulrich Petri <mail@…> Owned by: andrew
Priority: major Milestone: 1.0
Component: migrations Version: 0.7
Keywords: invalid code Cc:

Description

Steps to reproduce:

1) Have a model with a ForiegnKey? to e.g. auth.User
2) create & run migration
3) Add a ProxyModel? of auth.User (in my example "FilerUser?")
4) try to create migration (nothing to be done)
5) Change ForiegnKey? on first Model to use the Proxy
6) create migration - invalid python code results (see below)

class Migration(SchemaMigration):

    def forwards(self, orm):
        
        # Adding model 'FilerUser'
        db.create_table('auth_user', (
            ,
        ))
        db.send_create_signal('filer', ['FilerUser'])


    def backwards(self, orm):
        
        # Deleting model 'FilerUser'
        db.delete_table('auth_user')

Even worse than the broken forwards migration is the backwards one which would delete the base of the proxy model.

Change History

comment:1 Changed 5 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 0.7.1

This is probably related to #423, but doing a different operation.

comment:2 Changed 5 years ago by Ulrich Petri <mail@…>

I have to correct my report: actually I have a ManyToMany? field not a ForeignKey?.

comment:3 Changed 4 years ago by andrew

  • Milestone changed from 0.7.1 to 0.7.2

comment:4 Changed 4 years ago by andrew

  • Milestone changed from 0.7.2 to 0.7.3

comment:5 Changed 4 years ago by andrew

  • Milestone changed from 0.7.3 to 1.0
Note: See TracTickets for help on using tickets.