{"id":16223742,"url":"https://github.com/lykmapipo/sqlbrite-migrations","last_synced_at":"2025-10-30T15:13:28.365Z","repository":{"id":139149709,"uuid":"85483931","full_name":"lykmapipo/sqlbrite-migrations","owner":"lykmapipo","description":"SQLBrite helper class to manage database creation and version management using an application's raw asset files.","archived":false,"fork":false,"pushed_at":"2017-07-10T20:51:54.000Z","size":129,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T18:38:43.859Z","etag":null,"topics":["android","migration","sqlbrite","sqlite","yaml"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lykmapipo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-19T14:49:36.000Z","updated_at":"2023-10-20T10:12:09.000Z","dependencies_parsed_at":"2024-01-07T06:59:52.216Z","dependency_job_id":null,"html_url":"https://github.com/lykmapipo/sqlbrite-migrations","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fsqlbrite-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fsqlbrite-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fsqlbrite-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fsqlbrite-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lykmapipo","download_url":"https://codeload.github.com/lykmapipo/sqlbrite-migrations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244426360,"owners_count":20450949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","migration","sqlbrite","sqlite","yaml"],"created_at":"2024-10-10T12:19:55.875Z","updated_at":"2025-10-30T15:13:23.330Z","avatar_url":"https://github.com/lykmapipo.png","language":"Java","readme":"sqlbrite-migrations\n===================\n\n[![](https://jitpack.io/v/lykmapipo/sqlbrite-migrations.svg)](https://jitpack.io/#lykmapipo/sqlbrite-migrations)\n\nSQLBrite helper class to manage database creation and version management using an application's raw asset files.\n\n*Note!: Current all migrations must be placed on `migrations` folder inside `assets` folder*\n\n[Check Sample](https://github.com/lykmapipo/sqlbrite-migrations/tree/master/app)\n\n\n![Screen Listing Seeded Data](https://raw.githubusercontent.com/lykmapipo/sqlbrite-migrations/master/screens/Screenshot_2017-03-19-20-38-41.png)\n\n\n## Installation\nAdd [https://jitpack.io](https://jitpack.io) to your build.gradle with:\n```gradle\nallprojects {\n    repositories {\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\nadd `sqlbite-migrations` dependency into your project\n\n```gradle\ndependencies {\n    compile 'com.github.lykmapipo:sqlbrite-migrations:v1.0.1'\n}\n```\n\n## Usage\n```java\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.widget.ListView;\nimport com.github.lykmapipo.sqlbrite.migrations.SQLBriteOpenHelper;\nimport com.squareup.sqlbrite2.BriteDatabase;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\n\npublic class MainActivity extends AppCompatActivity {\n\n    private BriteDatabase database;\n    private BriteAdapter adapter;\n    private Disposable disposable;\n    private ListView listView;\n\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        adapter = new BriteAdapter(getApplicationContext());\n        listView = (ListView) findViewById(R.id.list);\n        listView.setAdapter(adapter);\n    }\n\n    @Override\n    protected void onResume() {\n        super.onResume();\n\n        database = SQLBriteOpenHelper.get(getApplicationContext(), \"brite\", 1);\n\n        disposable = database.createQuery(\"brites\", \"SELECT * FROM brites\")\n                .mapToList(Brite.MAPPER)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(adapter);\n\n    }\n\n    @Override\n    protected void onPause() {\n        super.onPause();\n        disposable.dispose();\n    }\n}\n```\n\n## Migrations\nAll migrations must be named after database version. So if you start a new project your first migration will be `1.yaml`.\nWhen upgrading to new version the the migration file must have the name corresponding to the new database version i.e\nif you upgrading from `version 1` to `version 2` then you migration script name will be `2.yaml`\n\nAll migration have the below format:\n\n```yaml\nup: # sql scripts to run during database upgrade or create\n  - CREATE TABLE tests (name VARCHAR(45))\nseeds: # sql scripts to be run during seeding\n  - INSERT INTO tests (name) values(\"Test\")\ndown: # sql scripts to run during database downgrade\n  - DROP TABLE tests\n```\n\nWhere:\n\n- `up` - List of SQL DDL to be applied to a database. Mainly for creating or altering a table.\n- `seeds` - List of SQL DML to be applied to a database. All DML will be applied after success `up DDL`.\n- `down` - List of DML and DDL to be applied to a database when downgrading.\n\nWhole of migration occur with a single database transaction. So up and seeding may happen or fail as whole.\n\n## Contribute\nIt will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. \nDo not forget to add a bit of test(s) of what value you adding.\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2017 lykmapipo \u0026\u0026 Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","funding_links":[],"categories":["Database"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flykmapipo%2Fsqlbrite-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flykmapipo%2Fsqlbrite-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flykmapipo%2Fsqlbrite-migrations/lists"}