{"id":37102038,"url":"https://github.com/rana718/graft","last_synced_at":"2026-01-14T12:22:25.576Z","repository":{"id":309572220,"uuid":"1010684010","full_name":"Rana718/Graft","owner":"Rana718","description":"Graft is a production-ready database migration CLI tool built with Go. It offers Prisma-like functionality with support for PostgreSQL, MySQL, and SQLite. 🔄 Smart migrations, 💾 automatic backups, and the ability to run raw SQL code.","archived":false,"fork":false,"pushed_at":"2025-12-03T06:52:51.000Z","size":103354,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-06T08:07:40.868Z","etag":null,"topics":["goalng-cli","golan","mysql","orm","postgresql","sqlite","tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rana718.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","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-06-29T15:39:58.000Z","updated_at":"2025-12-03T06:53:10.000Z","dependencies_parsed_at":"2025-10-21T13:18:19.060Z","dependency_job_id":"a53e5441-3636-4707-8995-b543b1192957","html_url":"https://github.com/Rana718/Graft","commit_stats":null,"previous_names":["rana718/graft"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Rana718/Graft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rana718%2FGraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rana718%2FGraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rana718%2FGraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rana718%2FGraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rana718","download_url":"https://codeload.github.com/Rana718/Graft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rana718%2FGraft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["goalng-cli","golan","mysql","orm","postgresql","sqlite","tools"],"created_at":"2026-01-14T12:22:24.738Z","updated_at":"2026-01-14T12:22:25.561Z","avatar_url":"https://github.com/Rana718.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿\u003ch1 align=\"center\"\u003e⚡ Flash ORM\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://go.dev/doc/go1.23\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Go-1.23%2B-blue.svg\" alt=\"Go Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-green.svg\" alt=\"License: MIT\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Lumos-Labs-HQ/flash/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/Lumos-Labs-HQ/flash?label=Release\" alt=\"Release\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/flashorm\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/flashorm?color=blue\u0026label=npm\" alt=\"npm version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/flashorm/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/flashorm?color=green\u0026label=python\" alt=\"PyPI version\"\u003e\n  \u003c/a\u003e\n\n\u003c/p\u003e\n\n![image](.github/flash-orm.png)\n\n---\n\nA powerful, database-agnostic ORM built in Go that provides Prisma-like functionality with multi-database support and type-safe code generation for Go, JavaScript, and TypeScript.\n\n## ✨ Features\n\n- 🗃️ **Multi-Database Support**: PostgreSQL, MySQL, SQLite\n- 🔄 **Migration Management**: Create, apply, and track migrations\n- 🔒 **Safe Migration System**: Transaction-based execution with automatic rollback\n- 📤 **Smart Export System**: Multiple formats (JSON, CSV, SQLite) for data portability\n- 🔧 **Code Generation**: Generate type-safe code for Go, JavaScript/TypeScript, and Python\n- 🟢 **Node.js Support**: First-class JavaScript/TypeScript support with type definitions\n- 🐍 **Python Support**: Full Python with async support\n- 🎨 **Enum Support**: PostgreSQL ENUM types with full migration support\n- ⚡ **Blazing Fast**: Outperforms Drizzle and Prisma in benchmarks\n- 🎯 **Prisma-like Commands**: Familiar CLI interface\n- 🔍 **Schema Introspection**: Pull schema from existing databases\n- 📊 **FlashORM Studio**: Visual database editor with table management, data editing, and auto-migration creation\n- 🛡️ **Conflict Detection**: Automatic detection and resolution of migration conflicts\n\n## 📊 Performance Benchmarks\n\nFlashORM significantly outperforms popular ORMs in real-world scenarios:\n\n| Operation                                  | FlashORM   | Drizzle     | Prisma      |\n| ------------------------------------------ | ---------- | ----------- | ----------- |\n| Insert 1000 Users                          | **149ms**  | 224ms       | 230ms       |\n| Insert 10 Cat + 5K Posts + 15K Comments    | **2410ms** | 3028ms      | 3977ms      |\n| Complex Query x500                         | **3156ms** | 12500ms     | 56322ms     |\n| Mixed Workload x1000 (75% read, 25% write) | **186ms**  | 1174ms      | 10863ms     |\n| Stress Test Simple Query x2000             | **79ms**   | 160ms       | 118ms       |\n| **TOTAL**                                  | **5980ms** | **17149ms** | **71510ms** |\n\n\n\n## 🚀 Installation\n\n### NPM (Node.js/TypeScript Projects)\n\n```bash\nnpm install -g flashorm\n```\n\n### Python Install\n\n```bash\npip install flashorm\n```\n\n### Go Install\n\n```bash\ngo install github.com/Lumos-Labs-HQ/flash@latest\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/Lumos-Labs-HQ/flash.git\ncd flash\nmake build-all\n```\n\n### Download Binary\n\nDownload the latest binary from [Releases](https://github.com/Lumos-Labs-HQ/flash/releases).\n\n# FlashORM - Database ORM\n\n## 🏁 Quick Start\n\n### 1. Initialize Your Project\n\n```bash\ncd your-project\nflash init --postgresql  # or --mysql, --sqlite\n```\n\n### 2. Configure Database\n\n```bash\n# Set your database URL\nexport DATABASE_URL=\"postgres://user:password@localhost:5432/mydb\"\n\n# Or create .env file\necho \"DATABASE_URL=postgres://user:password@localhost:5432/mydb\" \u003e .env\n```\n\n### 3. Create Your First Migration\n\n```bash\nflash migrate \"create users table\"\n```\n\n### 4. Apply Migrations Safely\n\n```bash\nflash apply\n```\n\n### 5. Check Status\n\n```bash\nflash status\n```\n\n## 📋 Commands\n\n| Command                 | Description                                         |\n| ----------------------- | --------------------------------------------------- |\n| `flash init`            | Initialize project with database-specific templates |\n| `flash migrate \u003cname\u003e`  | Create a new migration file                         |\n| `flash apply`           | Apply pending migrations with transaction safety    |\n| `flash status`          | Show migration status                               |\n| `flash pull`            | Extract schema from existing database               |\n| `flash studio`          | flash studio                                        |\n| `flash export [format]` | Export database (JSON, CSV, SQLite)                 |\n| `flash reset`           | Reset database (⚠️ destructive)                     |\n| `flash gen`             | Generate SQLC types                                 |\n| `flash raw \u003csql\u003e`       | Execute raw SQL                                     |\n\n### Global Flags\n\n- `--force` - Skip confirmation prompts\n- `--help` - Show help\n\n## 🗄️ Database Support\n\n### PostgreSQL\n\n```bash\nflash init --postgresql\nexport DATABASE_URL=\"postgres://user:pass@localhost:5432/db\"\n```\n\n### MySQL\n\n```bash\nflash init --mysql\nexport DATABASE_URL=\"user:pass@tcp(localhost:3306)/db\"\n```\n\n### SQLite\n\n```bash\nflash init --sqlite\nexport DATABASE_URL=\"sqlite://./database.db\"\n```\n\n## 🔧 Configuration\n\nFlashORM uses `flash.config.json` for configuration:\n\n```json\n{\n  \"version\": \"2\",\n  \"schema_path\": \"db/schema/schema.sql\",\n  \"queries\": \"db/queries/\",\n  \"migrations_path\": \"db/migrations\",\n  \"export_path\": \"db/export\",\n  \"database\": {\n    \"provider\": \"postgresql\",\n    \"url_env\": \"DATABASE_URL\"\n  },\n  \"gen\": {\n    \"js\": {\n      \"enabled\": true\n    }\n  }\n}\n```\n\n## 📁 Project Structure\n\nAfter running `flash init`:\n\n```\nyour-project/\n├── flash.config.json      # FlashORM configuration\n├── .env                  # Environment variables\n└── db/\n    ├── schema/\n    │   └── schema.sql    # Database schema\n    ├── queries/\n    │   └── users.sql     # SQL queries for SQLC\n    ├── migrations/       # Migration files (auto-created)\n    └── export/          # Export files (auto-created)\n```\n\n## 🔒 Safe Migration System\n\n### Transaction-Based Execution\n\nEach migration runs in its own transaction with automatic rollback on failure:\n\n```bash\nflash apply\n```\n\nOutput:\n\n```\n📦 Applying 2 migration(s)...\n  [1/2] 20251021132902_init\n      ✅ Applied\n  [2/2] 20251021140530_add_users_index\n      ✅ Applied\n✅ All migrations applied successfully\n```\n\n### Error Handling\n\nIf a migration fails, the transaction is automatically rolled back:\n\n```\n📦 Applying 2 migration(s)...\n  [1/2] 20251021132902_init\n      ✅ Applied\n  [2/2] 20251021140530_bad_migration\n❌ Failed at migration: 20251021140530_bad_migration\n   Error: syntax error at or near \"INVALID\"\n   Transaction rolled back. Fix the error and run 'flash apply' again.\n```\n\n## 🔄 Migration Workflow\n\n### 1. Create Migration\n\n```bash\nflash migrate \"add user roles\"\n```\n\nCreates a timestamped SQL file:\n\n```sql\n-- Migration: add_user_roles\n-- Created: 2025-10-21T13:29:02Z\n\nALTER TABLE users ADD COLUMN role VARCHAR(50) DEFAULT 'user';\nCREATE INDEX idx_users_role ON users(role);\n```\n\n### 2. Apply Migrations\n\n```bash\nflash apply\n```\n\n### 3. Check Status\n\n```bash\nflash status\n```\n\nOutput:\n\n```\nDatabase: Connected ✅\nMigrations: 3 total, 2 applied, 1 pending\n\n┌─────────────────────────────────┬─────────┬─────────────────────┐\n│ Migration                       │ Status  │ Applied At          │\n├─────────────────────────────────┼─────────┼─────────────────────┤\n│ 20251021_create_users_table     │ Applied │ 2025-10-21 13:29:02 │\n│ 20251021_add_user_email_index   │ Applied │ 2025-10-21 13:30:15 │\n│ 20251021_add_user_roles         │ Pending │ -                   │\n└─────────────────────────────────┴─────────┴─────────────────────┘\n```\n\n## 📊 Studio (Visual Database Editor)\n\nFlashORM Studio provides powerful visual interfaces for database management:\n\n### SQL Studio (PostgreSQL, MySQL, SQLite)\n\n**Features:**\n- 📋 **Visual Schema Designer**: View and edit database schema with interactive diagrams\n- ➕ **Add Tables**: Create new tables with columns, constraints, and relationships\n- ✏️ **Edit Tables**: Modify existing table structures, add/remove columns\n- 🔗 **Relationship Management**: Visualize and manage foreign key relationships\n- 📝 **Data Browser**: View, edit, insert, and delete records with a spreadsheet-like interface\n- 🔄 **Auto-Migration Creation**: Automatically generates migration files from schema changes\n- 🎨 **Enhanced UI**: Improved visibility with better contrast and larger interactive elements\n\n**Usage:**\n\n```bash\n# Start Studio with config file (auto-detects database)\nflash studio\n\n# Start Studio with direct database connection\nflash studio --db \"postgresql://user:pass@localhost:5432/mydb\"\n\n# Custom port\nflash studio --port 3000\n```\n\n### 🍃 MongoDB Studio\n\nA beautiful, modern interface for MongoDB - similar to MongoDB Compass!\n\n**Usage:**\n```bash\nflash studio --db \"mongodb://localhost:27017/mydb\"\n# or with MongoDB Atlas\nflash studio --db \"mongodb+srv://user:pass@cluster.mongodb.net/mydb\"\n```\n\n**Features:**\n- 📋 **Collection Browser** - View all collections with document counts\n- 📄 **Document Viewer** - Browse documents with syntax-highlighted JSON\n- ✏️ **Inline Editing** - Edit documents directly with JSON validation\n- ➕ **Create Documents** - Add new documents with JSON editor\n- 🗑️ **Delete Documents** - Remove documents with confirmation\n- 🔍 **Search \u0026 Filter** - Query documents using MongoDB filter syntax\n- 📊 **Database Stats** - View connection info and statistics\n- 📋 **Copy as JSON** - One-click copy of any document\n\n### 🔴 Redis Studio\n\nA powerful Redis management interface with a real CLI terminal - inspired by Upstash!\n\n**Usage:**\n```bash\nflash studio --redis \"redis://localhost:6379\"\n# or with password\nflash studio --redis \"redis://:password@localhost:6379\"\n```\n\n**Features:**\n- 🗂️ **Key Browser** - View keys with type indicators (STRING, LIST, SET, HASH, ZSET)\n- 🔍 **Pattern Search** - Search keys with wildcards (e.g., `user:*`)\n- ➕ **Create Keys** - Add new keys of any Redis type\n- ⏰ **TTL Management** - View and set key expiration\n- 💻 **Real CLI Terminal** - Full Redis CLI with command history (↑↓ arrows)\n- 📊 **Statistics** - Memory usage, connected clients, server info\n- 🗄️ **Database Selector** - Switch between db0-db15\n- 🧹 **Purge Database** - Clear all keys with one click\n\n**CLI Examples:**\n```\nredis\u003e SET mykey \"hello\"\nOK\nredis\u003e GET mykey\n\"hello\"\nredis\u003e HSET user:1 name \"John\" age 30\n(integer) 2\nredis\u003e MEMORY STATS\npeak.allocated: 1048576\n...\n```\n\n### Studio Workflow\n\n1. **View Schema**: Interactive diagram shows all tables and relationships\n2. **Edit Schema**: Click tables to modify structure, add columns, or change types\n3. **Manage Data**: Browse and edit data directly in the Studio interface\n4. **Generate Migrations**: Changes automatically create migration files for version control\n\n### Troubleshooting\n\n- Database connection errors: verify `DATABASE_URL` and network access.\n- Migration failures: inspect the migration SQL file, fix and re-run `flash apply`.\n\n## 📤 Export System\n\nExport your database to multiple formats for portability and analysis:\n\n### JSON Export (Default)\n\n```bash\nflash export\n# or\nflash export --json\n```\n\nCreates structured JSON with metadata:\n\n```json\n{\n  \"timestamp\": \"2025-10-21 14:00:07\",\n  \"version\": \"1.0\",\n  \"comment\": \"Database export\",\n  \"tables\": {\n    \"users\": [{ \"id\": 1, \"name\": \"Alice\", \"email\": \"alice@example.com\" }],\n    \"posts\": [{ \"id\": 1, \"user_id\": 1, \"title\": \"Hello World\" }]\n  }\n}\n```\n\n### CSV Export\n\n```bash\nflash export --csv\n```\n\nCreates directory with individual CSV files per table:\n\n```\ndb/export/export_2025-10-21_14-00-07_csv/\n├── users.csv\n├── posts.csv\n└── comments.csv\n```\n\n### SQLite Export\n\n```bash\nflash export --sqlite\n```\n\nCreates portable SQLite database file:\n\n```\ndb/export/export_2025-10-21_14-00-07.db\n```\n\n## 🔗 SQLC Integration\n\nGenerate type-safe Go code from SQL:\n\n```bash\n# Generate types after migrations\nflash gen\n\n# Apply migrations and generate types\nflash apply \u0026\u0026 flash gen\n```\n\nExample generated code:\n\n```go\ntype User struct {\n    ID        int32     `json:\"id\"`\n    Name      string    `json:\"name\"`\n    Email     string    `json:\"email\"`\n    CreatedAt time.Time `json:\"created_at\"`\n}\n\nfunc (q *Queries) GetUser(ctx context.Context, id int32) (User, error) {\n    // Generated implementation\n}\n```\n\n## 🛠️ Advanced Usage\n\n### Production Deployment\n\n```bash\n# Deploy without interactive prompts\nflash apply --force\n\n# Create export before deployment\nflash export --json\nflash apply --force\n```\n\n### Development Workflow\n\n```bash\n# Reset database during development\nflash reset --force\n\n# Extract schema from existing database\nflash pull\n```\n\n### Raw SQL Execution\n\n```bash\n# Execute raw SQL\nflash raw \"SELECT COUNT(*) FROM users;\"\n\n# Execute SQL file\nflash raw scripts/cleanup.sql\n```\n\n\u003c!-- ## 🚀 Roadmap \u0026 Future Features --\u003e\n\n\u003c!-- ### Coming Soon\n- 🐍 **Python Support**: Use FlashORM with Python projects --\u003e\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**Database Connection Failed**\n\n```bash\nError: failed to connect to database\n```\n\n- Check your `DATABASE_URL` environment variable\n- Verify database is running and accessible\n- Check firewall and network settings\n\n**Migration Failed with Rollback**\n\n```bash\n❌ Failed at migration: 20251021140530_bad_migration\n   Transaction rolled back. Fix the error and run 'flash apply' again.\n```\n\n- Check the migration SQL syntax\n- Verify table/column names exist\n- Fix the migration file and run `flash apply` again\n\n## 🤝 Contributing\n\nWe welcome contributions! Here's how to get started:\n\n```bash\ngit clone https://github.com/Lumos-Labs-HQ/flash.git\ncd flash\n\nmake dev-setup\n\nmake build-all\n```\n\n### Development Guidelines\n\n- Follow Go conventions and best practices\n- Add tests for new features\n- Update documentation\n- Use conventional commit messages\n- Test migration safety features\n\nSee [CONTRIBUTING.md](docs/CONTRIBUTING.md) for detailed guidelines.\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Inspired by [Prisma](https://www.prisma.io/) migration system\n- Built with [Cobra](https://github.com/spf13/cobra) CLI framework\n- Database drivers: [pgx](https://github.com/jackc/pgx), [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql), [go-sqlite3](https://github.com/mattn/go-sqlite3)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frana718%2Fgraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frana718%2Fgraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frana718%2Fgraft/lists"}