Roomigrant icon indicating copy to clipboard operation
Roomigrant copied to clipboard

Room migration using .sql files

Open spurdow opened this issue 5 years ago • 4 comments

Hello @MatrixDev -

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

Thanks

spurdow avatar Nov 10 '20 17:11 spurdow

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

MatrixDev avatar Nov 11 '20 09:11 MatrixDev

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

spurdow avatar Nov 11 '20 17:11 spurdow

@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;

MatrixDev avatar Nov 12 '20 12:11 MatrixDev

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

spurdow avatar Nov 14 '20 15:11 spurdow