se.emilsjolander.sprinkles.Migration Java Examples
The following examples show how to use
se.emilsjolander.sprinkles.Migration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyApplication.java From sprinkles with Apache License 2.0 | 4 votes |
@Override public void onCreate() { super.onCreate(); Sprinkles sprinkles = Sprinkles.init(getApplicationContext()); sprinkles.addMigration(new Migration() { @Override protected void onPreMigrate() { // do nothing } @Override protected void doMigration(SQLiteDatabase db) { db.execSQL( "CREATE TABLE Notes (" + "id INTEGER PRIMARY KEY AUTOINCREMENT,"+ "content TEXT,"+ "created_at INTEGER,"+ "updated_at INTEGER"+ ")" ); db.execSQL( "CREATE TABLE Tags (" + "id INTEGER PRIMARY KEY AUTOINCREMENT,"+ "name TEXT"+ ")" ); db.execSQL( "CREATE TABLE NoteTagLinks (" + "note_id INTEGER,"+ "tag_id INTEGER,"+ "PRIMARY KEY(note_id, tag_id),"+ "FOREIGN KEY(note_id) REFERENCES Notes(id) ON DELETE CASCADE,"+ "FOREIGN KEY(tag_id) REFERENCES Tags(id) ON DELETE CASCADE"+ ")" ); } @Override protected void onPostMigrate() { // do nothing } }); }