NB! I have seen [Core Data Migration - Table Already Exists](https://stackoverflow.com/questions/9897452/core-data-migration-table-already-exists), and it did not solve my problem.

I'm trying to do a lightweight migration of my data model, and am getting a failure at this point:

```
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                         [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
                         nil];
store = [self addPersistentStoreWithType:NSSQLiteStoreType configuration:nil
                    URL:url options:options error:&error];

```

The error message is:

```
2012-09-06 17:14:19.450 Selene[79064:c07] CoreData: error: (1) I/O error for database at /Users/colin/Library/Application Support/iPhone Simulator/5.1/Applications/E1638F38-B13A-4728-91CD-CC380E761544/Library/Application Support/Selene/.Selene.sqlite.migrationdestination_41b5a6b5c6e848c462a8480cd24caef3.  SQLite error code:1, 'table ZMEASUREMENT already exists'

```

The actual change to the data model is the addition of a single optional string column on a completely different table, ZCYCLE. So it makes no sense that it's complaining about ZMEASUREMENT.

I've stepped through the core data instantiation, and the NSManagedObjectModel looks like it is loaded correctly (new version). The url is correct.

I've tried making Clean in xcode, Reset Contents and Settings... in iOS Simulator, regenerate a version-1 sqlite file from scratch (using Core Data), and then try migration to version-2 again -- no dice. So it's not that my sqlite file is corrupt somehow.

Is data model information stored anywhere else that my cleaning might have missed?

Is there any other way to debug what's actually happening in the lightweight migration? I can't find any information other than the "table already exists" error quoted above, which doesn't make any sense to me. Whatever's going on inside addPersistentStoreWithType: is opaque to me.

The only way I have found to get a migration to proceed is to rename the table Core Data is complaining about, ZMEASUREMENT, as part of the migration. This works for one(1) migration only, and then I have to rename the table again to do a second migration. I am really not ok with the idea of a table whose name has to change every time I alter my data model; surely Core Data is not this broken.

EDIT:
In case it helps, here's the list of attributes for table ZMEASUREMENT. Is any of this weird?

```
@property (nonatomic) int epochDay;         // Integer32 indexed
// time as number of seconds since local midnight, to avoid time zone and DST issues
@property (nonatomic, strong) NSNumber *localTime;  // Integer32 optional

// stored in Kelvins, to force me to test temperature conversion code properly
@property (nonatomic, strong) NSNumber *temperatureK;   // Float optional
@property (nonatomic) BOOL excludeTemperature;      // Boolean default=NO
@property (nonatomic, strong) NSNumber *fluidCode;  // Integer16 optional
@property (nonatomic, strong) NSNumber *openingCode;    // Integer16 optional
@property (nonatomic, strong) NSNumber *positionCode;   // Integer16 optional
@property (nonatomic, strong) NSNumber *textureCode;    // Integer16 optional
@property (nonatomic, strong) NSNumber *rateCode;   // Integer16 optional
@property (nonatomic, strong) NSNumber *heightCode; // Integer16 optional
// try renaming the internal property to see if it helps lightweight migration
@property (nonatomic, strong) NSString *commentDPL; // String optional
@property (nonatomic, strong) NSString *comment;    /* derived property (alias for commentDPL) */
@property (nonatomic, strong) NSSet *notes;     // Optional to-many relationship to MeasurementNote

```

The only non-optional fields are epochDay and excludeTemperature.