{"action":"created","issue":{"url":"https://api.github.com/repos/pardom/ActiveAndroid/issues/318","labels_url":"https://api.github.com/repos/pardom/ActiveAndroid/issues/318/labels{/name}","comments_url":"https://api.github.com/repos/pardom/ActiveAndroid/issues/318/comments","events_url":"https://api.github.com/repos/pardom/ActiveAndroid/issues/318/events","html_url":"https://github.com/pardom/ActiveAndroid/pull/318","id":52702748,"number":318,"title":"Add AA_DB_RESET flag","user":{"login":"jlhonora","id":1577721,"avatar_url":"https://avatars.githubusercontent.com/u/1577721?v=3","gravatar_id":"","url":"https://api.github.com/users/jlhonora","html_url":"https://github.com/jlhonora","followers_url":"https://api.github.com/users/jlhonora/followers","following_url":"https://api.github.com/users/jlhonora/following{/other_user}","gists_url":"https://api.github.com/users/jlhonora/gists{/gist_id}","starred_url":"https://api.github.com/users/jlhonora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlhonora/subscriptions","organizations_url":"https://api.github.com/users/jlhonora/orgs","repos_url":"https://api.github.com/users/jlhonora/repos","events_url":"https://api.github.com/users/jlhonora/events{/privacy}","received_events_url":"https://api.github.com/users/jlhonora/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-23T00:17:26Z","updated_at":"2015-06-24T13:43:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pardom/ActiveAndroid/pulls/318","html_url":"https://github.com/pardom/ActiveAndroid/pull/318","diff_url":"https://github.com/pardom/ActiveAndroid/pull/318.diff","patch_url":"https://github.com/pardom/ActiveAndroid/pull/318.patch"},"body":"There are certain SQLite features that are hard to\r\nset or modify in an existing DB, such as:\r\n\r\n - Set foreign key actions\r\n - Rename columns or tables\r\n - `ON (UPDATE|CREATE)` definitions\r\n\r\nThey usually require creating a new table, dropping\r\nthe old one, and renaming the new one. If a full\r\ndb reset is performed then these definitions can be\r\nincluded without migration scripts.\r\n\r\nReset capabilities are added with these changes. A\r\ndb delete/create will be issued whenever the\r\n`AA_DB_VERSION` changes and the following lines\r\nexist in the app's manifest:\r\n\r\n```\r\n<meta-data\r\n    android:name=\"AA_DB_RESET\"\r\n    android:value=\"true\" />\r\n```\r\n\r\nThe reset will be checked in the `Cache.initialize`\r\nmethod.\r\n\r\nps: This change also includes the changes for the Travis CI\r\n setup (PR https://github.com/pardom/ActiveAndroid/pull/310).\r\nI'm not sure which approach is worse:\r\n\r\n1. Open a PR with a failed Travis build.\r\n2. Open a PR with changes from another PR.\r\n\r\nPlease let me know if you prefer approach number 1."},"comment":{"url":"https://api.github.com/repos/pardom/ActiveAndroid/issues/comments/114872068","html_url":"https://github.com/pardom/ActiveAndroid/pull/318#issuecomment-114872068","issue_url":"https://api.github.com/repos/pardom/ActiveAndroid/issues/318","id":114872068,"user":{"login":"jlhonora","id":1577721,"avatar_url":"https://avatars.githubusercontent.com/u/1577721?v=3","gravatar_id":"","url":"https://api.github.com/users/jlhonora","html_url":"https://github.com/jlhonora","followers_url":"https://api.github.com/users/jlhonora/followers","following_url":"https://api.github.com/users/jlhonora/following{/other_user}","gists_url":"https://api.github.com/users/jlhonora/gists{/gist_id}","starred_url":"https://api.github.com/users/jlhonora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlhonora/subscriptions","organizations_url":"https://api.github.com/users/jlhonora/orgs","repos_url":"https://api.github.com/users/jlhonora/repos","events_url":"https://api.github.com/users/jlhonora/events{/privacy}","received_events_url":"https://api.github.com/users/jlhonora/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T13:43:41Z","updated_at":"2015-06-24T13:43:41Z","body":"@oleonov Actually I was thinking about closing this PR, since the same functionality can be easily achieved by just changing the database name (with the AA_DB_NAME tag). Sometimes this is not possible or desired, but for me it works just as well as putting an AA_DB_RESET flag.\r\n\r\nRenaming the database is actually even better: If you use AA_DB_RESET you are stuck with it in all further migrations, but with renaming you have a clean slate in your app's DB. Why? Look at this case:\r\n\r\nDB version 1: First Schema\r\nDB version 2: AA_DB_RESET = true, Second Schema.\r\nDB version 3: AA_DB_RESET = false, Additional migration script, third schema.\r\n\r\nIf a user jumps from version 1 to 3 the database won't be reset, and the app will most likely crash.\r\n\r\nIt does have a small drawback: the old database won't be deleted in the new install. If your DB is big then you'll be wasting valuable space, but this could be checked in the app's initialization."}}