{"id":15011390,"url":"https://github.com/i9or/migralite","last_synced_at":"2025-04-12T03:31:42.495Z","repository":{"id":252363411,"uuid":"840218477","full_name":"i9or/migralite","owner":"i9or","description":":card_file_box: Simple forward-only SQLite migration tool for Bun","archived":false,"fork":false,"pushed_at":"2024-10-22T10:15:28.000Z","size":262,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T16:44:25.833Z","etag":null,"topics":["bun","bunjs","migration-tool","migrations","sqlite","sqlite-database","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/i9or.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-09T08:13:45.000Z","updated_at":"2025-02-25T04:41:37.000Z","dependencies_parsed_at":"2024-10-22T15:52:20.012Z","dependency_job_id":"ade85621-246e-4d02-9431-a74adfcaa5bc","html_url":"https://github.com/i9or/migralite","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"3f31ce02c279dc8131190739e1654fc0d1168959"},"previous_names":["i9or/migralite"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i9or%2Fmigralite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i9or%2Fmigralite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i9or%2Fmigralite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i9or%2Fmigralite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i9or","download_url":"https://codeload.github.com/i9or/migralite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248512733,"owners_count":21116670,"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":["bun","bunjs","migration-tool","migrations","sqlite","sqlite-database","sqlite3"],"created_at":"2024-09-24T19:41:01.768Z","updated_at":"2025-04-12T03:31:42.210Z","avatar_url":"https://github.com/i9or.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Migralite\n\nMigralite is lightweight forward-only SQLite migration tool for Bun.\n\n\u003cimg src=\"./migralite-logo.png\" width=\"200\" alt=\"Migralite Logo\"/\u003e\n\nKey features:\n\n- Simple \\*.sql files as migration scripts\n- Forward-only [^1]\n- Runs on Bun\n- CLI with sensible defaults, so there's no need to implement migration script\n- Migration generator\n- Version tracking — keeps track of applied migrations to prevent duplicate runs\n- Migrations are wrapped in transactions by default\n\n[^1]: https://nickcraver.com/blog/2016/05/03/stack-overflow-how-we-do-deployment-2016-edition/#database-migrations\n\n## Usage\n\n## Installation\n\nAdd CLI tool to the Bun based project:\n\n```bash\nbun add -d migralite\n```\n\nAnd then used via `package.json` scripts:\n\n```json\n{\n  \"scripts\": {\n    \"db:migrate\": \"migralite --database ./path/to/db.sqlite\"\n  }\n}\n```\n\nThe tool could be used with `bunx` without adding it to the project:\n\n```bash\nbunx migralite --help\n```\n\n## Available commands\n\n### Help\n\n`--help` or `-h` — shows help in the terminal.\n\nExample:\n\n```bash\nbunx migralite --help\n```\n\n### Version\n\n`--version` or `-v` — shows current version of the CLI tool.\n\nExample:\n\n```bash\nbunx migralite --version\n```\n\n### Database path\n\n`--database` or `-d` — path to the SQLite database file.\n\nExample:\n\n```bash\nbunx migralite -d ./db/main.sqlite\n```\n\n### Migrations path\n\n`--migrations` or `-m` — path to the folder with SQL migration scripts, by default it's `./migrations` folder in the\nroot of the project.\n\nExample:\n\n```bash\nbunx migralite -d ./db/main.sqlite -m ./db/migrations\n```\n\n### Migration file generation\n\n`--generate` or `-g` — migration file generation mode. It accepts short summary of what migration script is doing to\ngenerate migration name. The summary is added as a comment to the migration script.\n\nExample:\n\n```bash\nbunx migralite -g \"Create users table\"\n```\n\nThis will create a migration file in `./migrations` folder called `./migrations/20240815123456__create-users-table.sql`.\n\nOnly this filename format is accepted by the migration tool. Anything else will result in error and migrations won't\nrun.\n\n## Use as a library\n\nIt's possible to use Migralite as a library:\n\n```ts\nimport { Database } from \"bun:sqlite\";\nimport { applyMigrations } from \"migralite\";\n\nconst db = new Database(\":memory:\");\n\ntry {\n    await applyMigrations(db, \"./migrations\");\n} catch (err) {\n    console.error(err);\n}\n```\n\nOr connect to an existing DB file:\n\n```ts\nimport { applyMigrations, connectToDatabase } from \"migralite\";\n\nconst db = connectToDatabase(\"./path/to/db\");\n\ntry {\n    await applyMigrations(db, \"./migrations\");\n} catch (err) {\n    console.error(err);\n}\n```\n\n## Development\n\nTo install dependencies:\n\n```bash\nbun install\n```\n\nTo run:\n\n```bash\nbun run cli.ts\n```\n\n## Contributions\n\nPlease raise an issue first and let's discuss. \nThis project is pretty much done, but I am still open for some sensible contributions.\n\n## Attributions\n\nLogo by https://www.behance.net/garnenka\n\n## License\n\nCode is distributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi9or%2Fmigralite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi9or%2Fmigralite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi9or%2Fmigralite/lists"}