{"id":21216801,"url":"https://github.com/farjs/better-sqlite3-migrate","last_synced_at":"2026-01-25T13:01:47.017Z","repository":{"id":239293329,"uuid":"799118462","full_name":"farjs/better-sqlite3-migrate","owner":"farjs","description":"Automates Sqlite DB schema versioning","archived":false,"fork":false,"pushed_at":"2025-11-08T14:57:13.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-08T16:23:16.210Z","etag":null,"topics":["sql-migrate","sql-migration","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/farjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-11T08:27:55.000Z","updated_at":"2025-11-08T14:57:17.000Z","dependencies_parsed_at":"2024-05-11T10:22:41.679Z","dependency_job_id":"4fdd1186-9919-48ac-90bf-d7937d918b26","html_url":"https://github.com/farjs/better-sqlite3-migrate","commit_stats":null,"previous_names":["farjs/better-sqlite3-migrate"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/farjs/better-sqlite3-migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farjs%2Fbetter-sqlite3-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farjs%2Fbetter-sqlite3-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farjs%2Fbetter-sqlite3-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farjs%2Fbetter-sqlite3-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farjs","download_url":"https://codeload.github.com/farjs/better-sqlite3-migrate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farjs%2Fbetter-sqlite3-migrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28753411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T10:25:12.305Z","status":"ssl_error","status_checked_at":"2026-01-25T10:25:11.933Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["sql-migrate","sql-migration","sqlite","sqlite3"],"created_at":"2024-11-20T21:55:38.548Z","updated_at":"2026-01-25T13:01:46.997Z","avatar_url":"https://github.com/farjs.png","language":"JavaScript","readme":"[![CI](https://github.com/farjs/better-sqlite3-migrate/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/farjs/better-sqlite3-migrate/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amain)\n[![Coverage Status](https://coveralls.io/repos/github/farjs/better-sqlite3-migrate/badge.svg?branch=main)](https://coveralls.io/github/farjs/better-sqlite3-migrate?branch=main)\n[![npm version](https://img.shields.io/npm/v/@farjs/better-sqlite3-migrate)](https://www.npmjs.com/package/@farjs/better-sqlite3-migrate)\n\n## @farjs/better-sqlite3-migrate\n\nAutomates Sqlite DB schema versioning.\n\nUses [wrapper](https://github.com/farjs/better-sqlite3-wrapper)\naround [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)\nand [bun:sqlite](https://bun.sh/docs/api/sqlite)\nto allow cross- runtime/engine usage.\n\n### How to use it\n\n#### 1. Add SQL Migrations Scripts\n\nAdd your `SQL` migrations scripts under dedicated project sub-folder, for ex. `./migrations`.\n\nSee example SQL migrations scripts:\n\n- [V001\\_\\_initial_db_structure.sql](test/migrations/V001__initial_db_structure.sql)\n- [V002\\_\\_rename_db_field.sql](test/migrations/V002__rename_db_field.sql)\n\n#### 2. Generate `bundle.json` migrations file\n\nTo generate singe migrations bundle file you can use `sql-bundle` script and run it as part of build process.\n\nFor example, in your `package.json`:\n\n```json\n\"scripts\": {\n  \"sql-bundle\": \"npx sql-bundle ./migrations\"\n}\n```\n\nThen run it as follows:\n\n```bash\nnpm run sql-bundle\n```\n\n`bundle.json` file will be (re)generated in the same `./migrations` folder.\n\n#### 3. Exclude `bundle.json` file from `git`\n\nSince it can be easily generated from the input `SQL` migrations files there is no need to commit this file.\n\nYou can exclude it by adding the following line to your\n`.gitignore` file:\n\n```bash\nmigrations/bundle.json\n```\n\n#### 4. Load and run migrations bundle\n\nThe final setup is to actually load and apply migrations on your `Sqlite` DB during app startup:\n\n```javascript\nimport Database from \"@farjs/better-sqlite3-wrapper\";\nimport { readBundle, runBundle } from \"@farjs/better-sqlite3-migrate\";\n\n// connect to your DB\nconst db = new Database(\":memory:\");\n\nconst bundleUrl = new URL(\"./migrations/bundle.json\", import.meta.url);\n\n// load migrations bundle\nconst bundle = await readBundle(bundleUrl);\n\n// apply it\nawait runBundle(db, bundle);\n```\n\nThis will create (or update existing) `schema_versions` DB table with the all SQL migrations that were applied.\n\nSo, next time it will only apply new SQL migrations, that were not applied before (not exist in `schema_versions` table yet).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarjs%2Fbetter-sqlite3-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarjs%2Fbetter-sqlite3-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarjs%2Fbetter-sqlite3-migrate/lists"}