baard
baard

Reputation: 11

Reset SQLDelight database

During the initial development, my database schema is changing a lot. I'm able to create new database migrations using the [1,2,3,..].sqm files as the documentation specifies, and everything works as expected.

However, since this is the initial development, I would like to completely reset the database so I can have the app start at version "1" instead of starting at version "28". I can of course start a completely new project and make the finished schema the first migration there, but I was wondering why it doesn't work to just uninstall the app, redefine the .sqm files and rebuild it?

Upvotes: 0

Views: 439

Answers (1)

Kevin Galligan
Kevin Galligan

Reputation: 17352

As per the docs:

An .sq file always describes how to create the latest schema in an empty database. If your database is currently on an earlier version, migration files bring those databases up-to-date.

If your .sq files describe your schema (as per the statement above), then just delete your schema files and run a clean/build to make sure your generated files get rebuilt.

By "delete", I'm assuming you're using git or similar. If not, "delete" them by moving them, just in case :)

SqlDelight has a mode that builds the schema from the migration files rather than the .sq files. I don't remember the setting off hand. If you're using that, I think you'd have to "merge" your migrations, which I assume would need to be done manually. Technically, it could be automated, but I'd guess that's not something that's been built.

Upvotes: 0

Related Questions