{"id":34968590,"url":"https://github.com/kristoferlund/ic-sql-migrate","last_synced_at":"2025-12-26T23:28:39.530Z","repository":{"id":312597936,"uuid":"1039271846","full_name":"kristoferlund/ic-sql-migrate","owner":"kristoferlund","description":"A lightweight SQLite migration library for Internet Computer (ICP) canisters, providing automatic database schema management and version control.","archived":false,"fork":false,"pushed_at":"2025-10-17T10:25:39.000Z","size":586,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-18T10:47:09.048Z","etag":null,"topics":["internet-computer","rust","sqlite"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ic-sql-migrate","language":"Rust","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/kristoferlund.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":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":"2025-08-16T21:09:36.000Z","updated_at":"2025-10-17T10:25:43.000Z","dependencies_parsed_at":"2025-08-31T20:37:31.292Z","dependency_job_id":"a16aef06-0858-4fdc-a7b8-5dc30a0add65","html_url":"https://github.com/kristoferlund/ic-sql-migrate","commit_stats":null,"previous_names":["kristoferlund/ic-sqlite-migrate","kristoferlund/ic-sql-migrate"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kristoferlund/ic-sql-migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristoferlund%2Fic-sql-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristoferlund%2Fic-sql-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristoferlund%2Fic-sql-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristoferlund%2Fic-sql-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kristoferlund","download_url":"https://codeload.github.com/kristoferlund/ic-sql-migrate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristoferlund%2Fic-sql-migrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28064601,"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","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["internet-computer","rust","sqlite"],"created_at":"2025-12-26T23:28:38.956Z","updated_at":"2025-12-26T23:28:39.520Z","avatar_url":"https://github.com/kristoferlund.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ic-sql-migrate\n\nA lightweight database migration library for Internet Computer (ICP) canisters with support for SQLite and Turso databases.\n\n[![Crates.io](https://img.shields.io/crates/v/ic-sql-migrate.svg)](https://crates.io/crates/ic-sql-migrate)\n[![Documentation](https://docs.rs/ic-sql-migrate/badge.svg)](https://docs.rs/ic-sql-migrate)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Overview\n\nThis library provides automatic database schema management and version control for ICP canisters. Migrations are compiled into your canister binary and executed automatically during initialization and upgrades, with full support for tracking applied migrations and data seeding.\n\n## Key Features\n\n- 🚀 **Multi-Database Support**: SQLite (via `ic-rusqlite`) and Turso databases\n- 📦 **Compile-Time Embedding**: Migrations embedded into your canister at compile time\n- 🌱 **Data Seeding**: Populate initial data using Rust functions with full IDE support\n- 🔄 **Automatic Tracking**: Migrations and seeds tracked to prevent duplicate execution\n- 🔒 **Transactional**: All operations run in transactions for data safety\n- 🏗️ **ICP Native**: Designed specifically for Internet Computer canisters\n\n## Quick Navigation\n\n### Getting Started\n- **📖 [Detailed Documentation](./packages/ic-sql-migrate/README.md)** - Complete guide with installation, configuration, and API reference\n- **💾 [SQLite Example](./examples/sqlite/README.md)** - Full-featured example with the Chinook database, complex queries, and performance tracking\n- **🌍 [Turso Example](./examples/turso/README.md)** - Async example showing Turso integration on ICP\n\n### Documentation Links\n- **[API Documentation](https://docs.rs/ic-sql-migrate)** - Rust API reference on docs.rs\n- **[Crates.io](https://crates.io/crates/ic-sql-migrate)** - Package information and version history\n- **[Changelog](./packages/ic-sql-migrate/CHANGELOG.md)** - Version history and changes\n\n## 30-Second Start\n\n### 1. Add to Cargo.toml\n```toml\n[dependencies]\nic-sql-migrate = { version = \"0.0.5\", features = [\"sqlite\"] }\nic-rusqlite = { version = \"0.4.3\", features = [\"precompiled\"] }\nic-cdk = \"0.18.7\"\n\n[build-dependencies]\nic-sql-migrate = \"0.0.5\"\n```\n\n### 2. Create build.rs\n```rust\nfn main() {\n    ic_sql_migrate::Builder::new().build().unwrap();\n}\n```\n\n### 3. Create migrations/000_initial.sql\n```sql\nCREATE TABLE users (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    name TEXT NOT NULL,\n    email TEXT\n);\n```\n\n### 4. Use in your canister\n```rust\nuse ic_cdk::{init, post_upgrade};\nuse ic_rusqlite::with_connection;\n\nstatic MIGRATIONS: \u0026[ic_sql_migrate::Migration] = ic_sql_migrate::include_migrations!();\n\n#[init]\nfn init() {\n    with_connection(|mut conn| {\n        ic_sql_migrate::sqlite::migrate(\u0026mut conn, MIGRATIONS).unwrap();\n    });\n}\n\n#[post_upgrade]\nfn post_upgrade() {\n    init();\n}\n```\n\n## How It Works\n\n1. **Build Time**: `Builder` scans your `migrations/` and `src/seeds/` directories, embedding SQL files and generating seed modules\n2. **WASI Conversion**: For SQLite, the `wasi2ic` tool converts WASI calls to IC-compatible polyfills\n3. **Runtime**: On canister init/upgrade, migrations execute in order, tracked in a `_migrations` table to prevent re-execution\n4. **Seeding**: Optional data seeding via Rust functions runs after migrations with the same tracking mechanism\n\n## Database Backend Comparison\n\n| Feature | SQLite | Turso |\n|---------|--------|-------|\n| **Async** | No | Yes |\n| **Complexity** | Full SQL support | Limited SQL subset |\n| **Best For** | Complex databases | Simple schemas |\n\nSee the [full comparison](./packages/ic-sql-migrate/README.md#differences-between-database-backends) in the package documentation.\n\n## Examples\n\nTwo complete working examples demonstrate real-world usage:\n\n### 📁 [SQLite Example](./examples/sqlite/README.md)\nAdvanced example with the full Chinook music database featuring:\n- 11 tables with thousands of records\n- Complex queries with multi-table JOINs and analytics\n- Bulk write operations for stress testing\n- Performance tracking with instruction counts\n\n### 📁 [Turso Example](./examples/turso/README.md)\nAsync example showing Turso integration:\n- Simple person table with migrations\n- Async operation patterns\n- Stable memory persistence\n\n## Support \u0026 Resources\n\n- **[Full Documentation](./packages/ic-sql-migrate/README.md)** - Complete guide with troubleshooting and advanced topics\n- **[Issues](https://github.com/kristoferlund/ic-sql-migrate/issues)** - Report bugs or request features\n- **[Examples](./examples)** - Working code samples for both backends\n\n## License\n\nMIT - See [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristoferlund%2Fic-sql-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristoferlund%2Fic-sql-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristoferlund%2Fic-sql-migrate/lists"}