{"id":51119024,"url":"https://github.com/sulthonzh/dbmigrate","last_synced_at":"2026-06-25T00:30:38.517Z","repository":{"id":363203465,"uuid":"1256770276","full_name":"sulthonzh/dbmigrate","owner":"sulthonzh","description":"Zero-dependency database migration tool for SQLite, PostgreSQL, and MySQL","archived":false,"fork":false,"pushed_at":"2026-06-16T03:44:45.000Z","size":163,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-16T05:23:20.628Z","etag":null,"topics":["cli","database","migration","mysql","postgresql","schema","sqlite","zero-dependency"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/sulthonzh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-02T04:34:16.000Z","updated_at":"2026-06-16T03:42:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sulthonzh/dbmigrate","commit_stats":null,"previous_names":["sulthonzh/dbmigrate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sulthonzh/dbmigrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sulthonzh%2Fdbmigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sulthonzh%2Fdbmigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sulthonzh%2Fdbmigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sulthonzh%2Fdbmigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sulthonzh","download_url":"https://codeload.github.com/sulthonzh/dbmigrate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sulthonzh%2Fdbmigrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34755061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"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":["cli","database","migration","mysql","postgresql","schema","sqlite","zero-dependency"],"created_at":"2026-06-25T00:30:38.441Z","updated_at":"2026-06-25T00:30:38.506Z","avatar_url":"https://github.com/sulthonzh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbmigrate - Zero-Dep Database Migration Tool\n\nA zero-dependency CLI tool for managing database schema migrations across SQLite, PostgreSQL, and MySQL.\n\n## Why You Need This\n\nMost migration tools are either:\n- Over-engineered with tons of dependencies\n- Database-specific, forcing you to switch tools\n- Require complex configuration\n- Don't handle rollback cleanly\n\n**dbmigrate** solves this with:\n- ✅ Zero dependencies - works anywhere Node.js runs\n- ✅ Multi-database support - SQLite, PostgreSQL, MySQL\n- ✅ Clean rollback support\n- ✅ Simple configuration - just a `.dbmigrate.json` file\n- ✅ Transaction safety - all operations are transactional\n- ✅ Hot-reload migrations - add new migrations without rebase\n\n## Quick Start\n\n```bash\n# Install globally\nnpm install -g dbmigrate\n\n# Or use npx\nnpx dbmigrate --help\n```\n\n## Usage\n\n### Initialize a migration project\n```bash\n# Create a new migration project in current directory\ndbmigrate init\n\n# Initialize with specific database connection\ndbmigrate init --driver sqlite --database ./data.db\n```\n\n### Create a new migration\n```bash\n# Create migration file\ndbmigrate create add_users_table\n\n# Creates: migrations/20240602123456_add_users_table.sql\n```\n\n### Run migrations\n```bash\n# Run all pending migrations\ndbmigrate migrate\n\n# Rollback last migration\ndbmigrate rollback\n\n# Rollback to specific migration\ndbmigrate rollback --to 20240602120000_initial_setup\n\n# Dry run - see what would be applied\ndbmigrate migrate --dry-run\n```\n\n### Check migration status\n```bash\n# See applied migrations\ndbmigrate status\n\n# Show next migration\ndbmigrate next\n```\n\n## Configuration\n\nCreate `.dbmigrate.json` in your project root:\n\n```json\n{\n  \"driver\": \"sqlite\",\n  \"database\": \"./data.db\",\n  \"migrationsDir\": \"./migrations\",\n  \"tableName\": \"schema_migrations\",\n  \"transaction\": true\n}\n```\n\n### Drivers\n\n- **sqlite**: SQLite database (file or `:memory:`)\n- **postgresql**: PostgreSQL connection string\n- **mysql**: MySQL connection string\n\n### Configuration Examples\n\n```json\n// SQLite\n{\n  \"driver\": \"sqlite\",\n  \"database\": \"./myapp.db\"\n}\n\n// PostgreSQL\n{\n  \"driver\": \"postgresql\",\n  \"database\": \"postgres://user:pass@localhost:5432/mydb\"\n}\n\n// MySQL\n{\n  \"driver\": \"mysql\",\n  \"database\": \"mysql://user:pass@localhost:3306/mydb\"\n}\n```\n\n## Migration Files\n\nMigration files follow the pattern: `TIMESTAMP_description.sql`\n\nExample:\n```\nmigrations/\n├── 20240602120000_initial_setup.sql\n├── 20240602120001_add_users_table.sql\n└── 20240602120002_add_indexes.sql\n```\n\n### Migration Structure\n\n```sql\n-- Up migration\nCREATE TABLE users (\n  id INTEGER PRIMARY KEY,\n  email TEXT UNIQUE NOT NULL,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\n-- Down migration (optional)\nDROP TABLE users;\n```\n\n### Multi-step Migrations\n\n```sql\n-- Migrate up\nCREATE TABLE products (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL,\n  price DECIMAL(10,2) DEFAULT 0\n);\n\nCREATE TABLE categories (\n  id INTEGER PRIMARY KEY,\n  name TEXT UNIQUE NOT NULL\n);\n\n-- Migrate down\nDROP TABLE categories;\nDROP TABLE products;\n```\n\n## Commands\n\n### init\nInitialize a new migration project\n```bash\ndbmigrate init [options]\n\nOptions:\n  --driver \u003cdriver\u003e    Database driver (sqlite|postgresql|mysql)\n  --database \u003curl\u003e     Database connection string/file path\n  --migrations-dir \u003cdir\u003e  Directory for migration files (default: ./migrations)\n  --table \u003cname\u003e       Migration tracking table (default: schema_migrations)\n  --no-transaction    Disable transactions\n```\n\n### create\nCreate a new migration file\n```bash\ndbmigrate create \u003cdescription\u003e [options]\n\nOptions:\n  --dir \u003cdir\u003e         Migration directory\n  --template \u003cfile\u003e   Custom SQL template\n```\n\n### migrate\nRun pending migrations\n```bash\ndbmigrate migrate [options]\n\nOptions:\n  --dry-run           Show what would be applied\n  --force            Skip confirmation\n  --verbose          Show detailed output\n```\n\n### rollback\nRollback migrations\n```bash\ndbmigrate rollback [options]\n\nOptions:\n  --to \u003ctimestamp\u003e    Rollback to specific migration\n  --steps \u003cnumber\u003e    Rollback N steps (default: 1)\n  --force            Skip confirmation\n```\n\n### status\nShow migration status\n```bash\ndbmigrate status [options]\n\nOptions:\n  --json             Output in JSON format\n  --pending-only     Show only pending migrations\n```\n\n### next\nShow the next migration to apply\n```bash\ndbmigrate next\n```\n\n### reset\nReset the migration table (dangerous!)\n```bash\ndbmigrate reset [options]\n\nOptions:\n  --force            Skip confirmation\n```\n\n## Examples\n\n### Example 1: SQLite Blog App\n\n```bash\n# Initialize SQLite database\ndbmigrate init --driver sqlite --database ./blog.db\n\n# Create migration for posts table\ndbmigrate create add_posts_table\n\n# Edit migration file:\nCREATE TABLE posts (\n  id INTEGER PRIMARY KEY,\n  title TEXT NOT NULL,\n  content TEXT,\n  published BOOLEAN DEFAULT 0,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\n# Create migration for comments table\ndbmigrate create add_comments_table\n\n# Edit migration file:\nCREATE TABLE comments (\n  id INTEGER PRIMARY KEY,\n  post_id INTEGER,\n  author TEXT NOT NULL,\n  content TEXT,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  FOREIGN KEY (post_id) REFERENCES posts(id)\n);\n\n# Run migrations\ndbmigrate migrate\n\n# Check status\ndbmigrate status\n\n# Add a new column\ndbmigrate create add_slug_to_posts\n\n-- Edit migration file:\nALTER TABLE posts ADD COLUMN slug TEXT UNIQUE;\n\n-- Down migration:\nALTER TABLE posts DROP COLUMN slug;\n\n# Apply new migration\ndbmigrate migrate\n```\n\n### Example 2: PostgreSQL API\n\n```bash\n# Initialize PostgreSQL\ndbmigrate init --driver postgresql --database \"postgres://user:pass@localhost:5432/api\"\n\n# Create migration for users\ndbmigrate create users_schema\n\n-- Migration file:\nCREATE TABLE users (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  email VARCHAR(255) UNIQUE NOT NULL,\n  password_hash VARCHAR(255) NOT NULL,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE INDEX idx_users_email ON users(email);\n\n-- Down migration:\nDROP INDEX idx_users_email;\nDROP TABLE users;\n\n# Run with transactions (default)\ndbmigrate migrate\n\n# Rollback if needed\ndbmigrate rollback\n```\n\n## Features\n\n### Transaction Safety\nAll migrations run in transactions by default. If any step fails, the entire migration is rolled back.\n\n```json\n{\n  \"transaction\": true\n}\n```\n\n### Hot Reload\nAdd new migration files without rebase. dbmigrate automatically detects new migrations.\n\n### Rollback Support\nEvery migration can have a down operation for clean rollback.\n\n### Environment Variables\nSupport for environment variables in configuration:\n\n```json\n{\n  \"driver\": \"${DB_DRIVER:-sqlite}\",\n  \"database\": \"${DB_URL:-./data.db}\"\n}\n```\n\n### Version Pinning\nPin to a specific schema version:\n\n```bash\n# Apply migrations up to version 20240602120000\ndbmigrate migrate --to 20240602120000\n```\n\n## API Usage\n\n```javascript\nimport { Migrator } from 'dbmigrate';\n\n// Initialize migrator\nconst migrator = new Migrator({\n  driver: 'sqlite',\n  database: './app.db',\n  migrationsDir: './migrations'\n});\n\n// Run migrations\nawait migrator.migrate();\n\n// Rollback\nawait migrator.rollback();\n\n// Get status\nconst status = await migrator.getStatus();\n```\n\n## Error Handling\n\ndbmigrate provides clear error messages:\n- **Connection errors**: Database not accessible\n- **Migration errors**: SQL syntax issues\n- **Conflict errors**: Migration already applied/applied\n- **Configuration errors**: Invalid config files\n\n## Development\n\nBuilt with:\n- Node.js (native)\n- Zero external dependencies\n- TypeScript for type safety\n- Comprehensive test suite\n\n## License\n\nMIT - feel free to use in any project.\n\n## Contributing\n\n1. Fork the repo\n2. Create a feature branch\n3. Add tests for new functionality\n4. Ensure all tests pass\n5. Submit a pull request\n\n## Support\n\nIssues: https://github.com/sulthonzh/dbmigrate/issues","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsulthonzh%2Fdbmigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsulthonzh%2Fdbmigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsulthonzh%2Fdbmigrate/lists"}