MatrixDev / Roomigrant

Automated Android Room ORM migrations generator with compile-time code generation
MIT License
374 stars 23 forks source link

Room migration using .sql files #13

Open spurdow opened 3 years ago

spurdow commented 3 years ago

Hello @MatrixDev -

Would it be possible to have a support to pull .sql files to use as migration?

Thanks

MatrixDev commented 3 years ago

hello @spurdow. what do you mean by "pulling sql files"?

spurdow commented 3 years ago

Hello @MatrixDev - Btw - firstly thanks. This library greatly helps us.

I mean instead migrating by adding migration codes, Is it possible to store .sql files in asset/ or any configurable folder in AS and then the lib will automatically pull that depending on the db schema version like 1.sql , 2.sql so on and so forth.

Similar to the then ActiveAndroid https://github.com/pardom-zz/ActiveAndroid which is amazing. Thanks

MatrixDev commented 3 years ago

@spurdow, glad you've liked this library. So from what I understood those *.sql files will just contain plain SQL commands to alter database.

For example instead of writing:

@FieldMigrationRule(version1 = 3, version2 = 4, table = "Object1Dbo", field = "intValRenamed")
fun migrate_3_4_Object1Dbo_intVal(): String {
    return "`Object1Dbo`.`intVal`"
}

You'll have 3-4.sql file containing SQL script to execute?

ALTER TABLE Items ADD COLUMN color INTEGER;
spurdow commented 3 years ago

@MatrixDev Yes - or 4.sql will do I guess?