diff options
author | James Moger <james.moger@gitblit.com> | 2014-11-06 15:34:50 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-11-09 11:15:14 -0500 |
commit | 96d0aca9ff3b29be62bc6558af80fe115b646b88 (patch) | |
tree | 250e525f8975d44c95c5111bfb66d6d2cdd84919 /src/site/table_versioning.mkd | |
parent | db0d58c22a0bd4fa2baf023428599757aa4db381 (diff) | |
download | iciql-96d0aca9ff3b29be62bc6558af80fe115b646b88.tar.gz iciql-96d0aca9ff3b29be62bc6558af80fe115b646b88.zip |
Implement Dao proxy generation with annotated sql statement execution
This functionality is inspired by JDBI but is not based on it's implementation.
Diffstat (limited to 'src/site/table_versioning.mkd')
-rw-r--r-- | src/site/table_versioning.mkd | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/site/table_versioning.mkd b/src/site/table_versioning.mkd index 2e95aaa..480dd22 100644 --- a/src/site/table_versioning.mkd +++ b/src/site/table_versioning.mkd @@ -26,4 +26,34 @@ both of which allow for non-linear upgrades. If the upgrade method call is succ The actual upgrade procedure is beyond the scope of iciql and is your responsibility to implement. This is simply a mechanism to automatically identify when an upgrade is necessary.
**NOTE:**<br/>
-The database entry of the *iq_versions* table is specified as SCHEMANAME='' and TABLENAME=''.
\ No newline at end of file +The database entry of the *iq_versions* table is specified as SCHEMANAME='' and TABLENAME=''.
+
+### Effective use of Versioning with a DAO
+
+When Iciql identifies that a version upgrade is necessary it will call the appropriate method and give you a `Db` instance. With the `Db` instance you may open a version-specific [DAO](dao.html) instance that could give you a clean way to define all your upgrade commands.
+
+---JAVA---
+public interface V2Upgrade extends Dao {
+
+ @SqlStatement("ALTER TABLE PRODUCT ADD COLUMN TEST INT DEFAULT 0")
+ void updateProductTable();
+
+ @SqlStatement("UPDATE PRODUCT SET CATEGORY = :new WHERE CATEGORY = :old"")
+ void renameCategory(@Bind("old") String oldName, @Bind("new") String newName);
+}
+
+public class MyUpgrader implements DbUpgrader {
+
+ public boolean upgradeDatabase(Db db, int fromVersion, int toVersion) {
+
+ if (2 == toVersion) {
+ V2Upgrade dao = db.open(V2Upgrade.class);
+ dao.updateProductTable();
+ dao.renameCategory("Condiments", "Dressings");
+ return true;
+ }
+
+ return false;
+ }
+
+---JAVA---
\ No newline at end of file |