Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to rollback a wrong migration #96

Open
poc7667 opened this issue May 10, 2015 · 2 comments
Open

How to rollback a wrong migration #96

poc7667 opened this issue May 10, 2015 · 2 comments

Comments

@poc7667
Copy link

poc7667 commented May 10, 2015

If I created a wrong migration,

How could I rollback to the original state,

in addition to remove the migration file, what else should I do ?

And once I created a migration file , should I run rake db:migrate command ?
thanks

Because I created a migration file 002, and the entity name is identical to the previous migration file's entity, then I delete the 002 migration file , and got the following exception, and I don't know what should I do.

(main)> 2015-05-10 23:11:40.973 water_info[16082:65199] CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/hsu-wei-cheng/Library/Developer/CoreSimulator/Devices/BF0E050B-4A5D-43C6-BACD-A052327FD003/data/Containers/Data/Application/B89CA289-7ED0-4D03-8B9B-F68E00E54CE6/Documents/water_info.sqlite options:{
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x116c01840 {URL=file:///Users/hsu-wei-cheng/Library/Developer/CoreSimulator/Devices/BF0E050B-4A5D-43C6-BACD-A052327FD003/data/Containers/Data/Application/B89CA289-7ED0-4D03-8B9B-F68E00E54CE6/Documents/water_info.sqlite, metadata={
    NSPersistenceFrameworkVersion = 519;
    NSStoreModelVersionHashes =     {
        FavoriteLocation = <77a4f3ca f11ed2e0 75d95e0f 4512a24f 316c12d0 080e4966 8fedc7ea 8dd386d9>;
    };
    NSStoreModelVersionHashesVersion = 3;
    NSStoreModelVersionIdentifiers =     (
        "0002 add reservioirs"
    );
    NSStoreType = SQLite;
    NSStoreUUID = "5C83F3F4-CBA3-4A10-BA48-8E3ECAA65507";
    "_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store} with userInfo dictionary {
    URL = "file:///Users/hsu-wei-cheng/Library/Developer/CoreSimulator/Devices/BF0E050B-4A5D-43C6-BACD-A052327FD003/data/Containers/Data/Application/B89CA289-7ED0-4D03-8B9B-F68E00E54CE6/Documents/water_info.sqlite";
    metadata =     {
        NSPersistenceFrameworkVersion = 519;
        NSStoreModelVersionHashes =         {
            FavoriteLocation = <77a4f3ca f11ed2e0 75d95e0f 4512a24f 316c12d0 080e4966 8fedc7ea 8dd386d9>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =         (
            "0002 add reservioirs"
        );
        NSStoreType = SQLite;
        NSStoreUUID = "5C83F3F4-CBA3-4A10-BA48-8E3ECAA65507";
        "_NSAutoVacuumLevel" = 2;
    };
@markrickert
Copy link
Member

Currently, rollbacks aren't supported in CDQ, so you'll have to delete the DB and start over again (easiest way is to just delete the app from the simulator). A cdq.reset! might do the trick too, but I'm not sure about that.

If you've already pushed a version with the incorrect field to the app store, you'll have to make your next migration still include it and simply add a new column to the table.

@kemiller
Copy link
Contributor

I assume you are talking about your local environment? In that case, simply resetting your simulator or deleting the app from your phone is probably what you want. cdq.reset! should do the trick too.

If you mean that a migration got into production, that's serious. You are better off making a new migration to fix the damage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants