Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realm reset schema version

I'm currently in the process of writing an app that uses Realm as a database. As I'm still writing it my models have invariably changed from what I initially designed. Unfortunately every time this happens I need to update a migration block.

Is there anyway to 'reset' my Realm so that until it's actual in 'production' I don't need to worry about Migration blocks at all? It's particularly a pain with some unit tests, I do actually delete all the tables when the tests run, but I'm assuming there must be a best practice to handle this

Specifically I am working in an iOS/Swift app.

like image 433
TommyBs Avatar asked Jan 30 '26 12:01

TommyBs


1 Answers

Yes, there is very useful solution, just type:

var config = Realm.Configuration()
config.deleteRealmIfMigrationNeeded = true
like image 128
klapinski Avatar answered Feb 02 '26 02:02

klapinski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!