17. Flyway versioning
One or more numeric parts
Separated by a dot (.) or an underscore (_)
Underscores are replaced by dots at runtime
Leading zeroes are ignored in each part
1
001
5.2
5_2 (5.2 at runtime)
1.2.3.4.5.6.7.8.9
205.68
20130115113556
2013.1.15.11.35.56
2013.01.15.11.35.56
1__CreateTable.sql
001__AlterTable.sql
5.2__InsertDate.sql
5_2__DeleteData.sql
1.2.3.4.5.6.7.8.9__AnotherScript.sql
205.68__Transform.sql
20130115113556__InsertView.sql
2013.1.15.11.35.56__AddService.sql
2013.01.15.11.35.56__Delete.sql
18. Let’s Do Some Programming!
Building queries / SQL generation
Fetching results
Updating records
35. Records: create
// Create a new record
BookRecord book1 = create.newRecord(BOOK);
// Insert the record: INSERT INTO BOOK (TITLE) VALUES ('1984');
book1.setTitle("1984");
book1.store();
36. Records: update
BookRecord book2 = create.fetchOne(BOOK, BOOK.ID.equal(id));
// Update the record: UPDATE BOOK SET TITLE = 'Animal Farm' WHERE ID
= [id]
book2.setTitle("Animal Farm");
book2.store();
38. Records: batch changes
// Fetch a bunch of books
List<BookRecord> books = create.fetch(BOOK);
// Modify the above books, and add some new ones:
modify(books);
addMore(books);
// Batch-update and/or insert all of the above books
create.batchStore(books);
39. Records: update using a query
create.update(BOOK)
.set(BOOK.IS_BESTSELLER, 1)
.where(BOOK.SELLED_COPIES.greater(100000))
.execute();