Created
July 22, 2016 16:51
-
-
Save es0329/51d7708d9926ee39270b3235468914db to your computer and use it in GitHub Desktop.
SQLite database and upgrade attempt using SimpleSQLProvider.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.es0329.sqlite; | |
| import ckm.simple.sql_provider.UpgradeScript; | |
| import ckm.simple.sql_provider.annotation.ProviderConfig; | |
| import ckm.simple.sql_provider.annotation.SimpleSQLConfig; | |
| import com.es0329.sqlite.R; | |
| @SimpleSQLConfig( | |
| name = "FooProvider", | |
| authority = "com.es0329.sqlite.AUTHORITY", | |
| database = "foo.db", | |
| version = 2) | |
| public class FooProviderConfig implements ProviderConfig { | |
| @Override public UpgradeScript[] getUpdateScripts() { | |
| return new UpgradeScript[] { | |
| new UpgradeScript(2, R.raw.v2_upgrade) | |
| }; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.es0329.sqlite; | |
| import ckm.simple.sql_provider.annotation.SimpleSQLColumn; | |
| import ckm.simple.sql_provider.annotation.SimpleSQLTable; | |
| @SimpleSQLTable(table = "user", provider = "FooProvider") | |
| public class User { | |
| // version 1 = successful | |
| @SimpleSQLColumn(value = "id", primary = true) public String id = ""; | |
| @SimpleSQLColumn(value = "name") public String name = ""; | |
| // version 2 = no upgrade | |
| @SimpleSQLColumn(value = "avatar_url") public String avatar_url = ""; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ALTER TABLE user ADD COLUMN avatar_url TEXT |
Author
Sql script line must end with semicolon to be executed, e.g. ALTER TABLE user ADD COLUMN avatar_url TEXT;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initial CRUD using version 1 CRUD is successful. The script to alter is located at
res/raw/.Incrementing
FooProviderConfigversion doesn't seem to triggergetUpdateScripts().