realm / realm-browser-osx

DEPRECATED - Realm Browser for Mac OS X has been replaced by realm-studio which is cross platform.
https://realm.io
501 stars 54 forks source link

Set Primary Key Column? #349

Closed patreu22 closed 7 years ago

patreu22 commented 7 years ago

Hey guys, awesome Repo, but I'm running in a few troubles:

I'm preparing a Database for an App using the Realm Browser. I'm importing a CSV and save the compressed Realm DB after that, everything fine.

Now I introduced the primary key variable in my Database, but I have no idea how to set that attribute in my pre-prepared Realm DB. Is there a solution for my problem or how would you solve that?

The iOS app that uses this DB prints out that:

Error Domain=io.realm Code=10 "Migration is required due to the following errors:
- Primary Key for class 'Questions' has been added." UserInfo={NSLocalizedDescription=Migration is required due to the following errors:
- Primary Key for class 'Questions' has been added., Error Code=10}

I understand why, but I would like to avoid a migration if you see a way to set that somehow through the CSV import process or after that in the Realm Browser?

Thx for the help :)

stel commented 7 years ago

Hey @patreu22!

Unfortunately there is no way to set Primary Key when you import data, so you need to perform migration.

Alternatively you can import the data manually into realm file created by your app. You might find using RealmConverter directly with Realm Cocoa more flexible for that.