Here, I announce the new release of Kotlin db migration library, Harmonica 1.1.10.
You can see the code in GitHub.
New Big Feature
Here are new big functions since version 1.0.10.
- Foreign key
refer
function creates column with Foreign Key constraint.addForeignKey
creates new foreign key constraint.- SQLite support
- Support SQLite database in addition to MySQL and PostgreSQL.
- Rename column and table and index
- Added function to rename column and table and index.
date
,addDecimalColumn
- Add the function,
addDecimalColumn
to add decimal column to existing table. Now,date
andaddDateColumn
functions can accept default value in many types,String
,Date
,LocalDate
. addDateColumn
- Add the function,
addDateColumn
to add date column to existing table. - Support
blob
,time
,timestamp
,datetime
- Add functions to create columns of those types.
- Index Method
- Now we can choose index method in creating index.
Example migration
Here is an example code for migration, which is in GitHub: Harmonica Test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
/** * NotNullMigration */ class M20180714194338790_NotNullMigration : AbstractMigration() { override fun up() { createTable("not_null_table") { decimal("decimal_column", nullable = false) blob("blob_column", nullable = false) date("date_column", nullable = false) time("time_column", nullable = false) dateTime("date_time_column", nullable = false) timestamp("timestamp_column", nullable = false) text("text_column", nullable = false) refer("normal_table") } val tableName = "not_null_table_for_add" createTable(tableName) {} addDecimalColumn( tableName, "decimal_column", nullable = false) addBlobColumn( tableName, "blob_column", nullable = false) addDateColumn( tableName, "date_column", nullable = false) addTimeColumn( tableName, "time_column", nullable = false) addDateTimeColumn( tableName, "date_tiem_column", nullable = false) addTimestampColumn( tableName, "timestamp_column", nullable = false) addTextColumn( tableName, "text_column", nullable = false) addForeignKey( "not_null_table_for_add", "integer_column", "normal_table_for_add") } override fun down() { dropTable("not_null_table_for_add") dropTable("not_null_table") } } |