{"id":29916689,"url":"https://github.com/octaviocossy/comparedb-ai","last_synced_at":"2026-05-05T11:33:00.292Z","repository":{"id":304586853,"uuid":"1019168845","full_name":"Octaviocossy/comparedb-ai","owner":"Octaviocossy","description":"An AI-powered database schema synchronization tool that compares two SQL Server schemas and generates comprehensive migration scripts.","archived":false,"fork":false,"pushed_at":"2025-07-27T02:31:01.000Z","size":151,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-27T05:17:57.710Z","etag":null,"topics":["ai","nextjs","sql-server","vercel-ai-sdk"],"latest_commit_sha":null,"homepage":"https://comparedb-ai.vercel.app","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/Octaviocossy.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}},"created_at":"2025-07-13T22:21:57.000Z","updated_at":"2025-07-27T02:45:07.000Z","dependencies_parsed_at":"2025-07-27T04:19:17.478Z","dependency_job_id":null,"html_url":"https://github.com/Octaviocossy/comparedb-ai","commit_stats":null,"previous_names":["octaviocossy/comparedb-ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Octaviocossy/comparedb-ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Octaviocossy%2Fcomparedb-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Octaviocossy%2Fcomparedb-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Octaviocossy%2Fcomparedb-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Octaviocossy%2Fcomparedb-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Octaviocossy","download_url":"https://codeload.github.com/Octaviocossy/comparedb-ai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Octaviocossy%2Fcomparedb-ai/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268337973,"owners_count":24234538,"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-08-02T02:00:12.353Z","response_time":74,"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":["ai","nextjs","sql-server","vercel-ai-sdk"],"created_at":"2025-08-02T05:01:21.736Z","updated_at":"2026-05-05T11:33:00.244Z","avatar_url":"https://github.com/Octaviocossy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CompareDB AI\n\nAn AI-powered database schema synchronization tool that compares two SQL Server schemas and generates comprehensive migration scripts. Built for local development and database administration tasks.\n\n## 🚀 Features\n\n- **AI-Powered Schema Comparison**: Uses OpenAI to intelligently compare database schemas\n- **Comprehensive Migration Scripts**: Generates idempotent SQL scripts with proper transaction safety\n- **Complete Object Coverage**: Handles tables, columns, indexes, views, stored procedures, functions, triggers, and seed data\n- **Logical Operation Order**: Creates, alters, and drops objects in the correct dependency order\n- **Clipboard Integration**: Easy copy-to-clipboard functionality for generated scripts\n- **Modern UI**: Clean, responsive interface with dark mode support\n- **Web-Based**: Accessible via web browser with client-side API key configuration\n- **Model Selection**: Support for GPT-4o and GPT-4o-mini models\n\n## 🛠️ Technology Stack\n\n- **Frontend**: Next.js 15, React 19, TypeScript\n- **Styling**: TailwindCSS 4, shadcn/ui components\n- **AI Integration**: OpenAI API with Vercel AI SDK\n- **Deployment**: Vercel\n- **Development**: ESLint, Prettier, Turbopack\n\n## 🏗️ How It Works\n\n1. **Input**: Paste your source schema (truth) and target schema (current state)\n2. **AI Processing**: The tool analyzes both schemas using sophisticated AI prompts\n3. **Script Generation**: Generates a complete `sync_schema.sql` migration script\n4. **Copy to Clipboard**: Use the copy button to copy the generated script to your clipboard\n5. **Safe Execution**: Scripts include existence checks and transaction wrapping\n\n### Migration Script Features\n\n- **DROP** obsolete objects (constraints, indexes, views, SPs, functions, triggers)\n- **CREATE/ALTER** tables and columns\n- **CREATE/ALTER** constraints (PK, FK, CHECK)\n- **CREATE/ALTER** indexes\n- **CREATE/ALTER** views, stored procedures, functions, triggers\n- **INSERT/UPDATE** seed data\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n- Node.js 18+ \n- pnpm (recommended) or npm\n- OpenAI API key\n\n### Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd comparedb-ai\n   ```\n\n2. **Install dependencies**\n   ```bash\n   pnpm install\n   ```\n\n3. **Run the development server**\n   ```bash\n   pnpm dev\n   ```\n\n4. **Open your browser**\n   Navigate to `http://localhost:3000`\n\n### Production Deployment\n\nThe application is deployed on Vercel and available at the production URL. The OpenAI API key is configured through the web client interface.\n\n**Security Note**: The API key is never stored and is only used temporarily for API requests.\n\n## 📖 Usage\n\n1. **Configure API Key**: Click the settings icon to enter your OpenAI API key and select a model (GPT-4o or GPT-4o-mini)\n2. **Paste Source Schema**: Add your reference/target database schema in the \"Source\" panel\n3. **Paste Target Schema**: Add your current database schema in the \"Target\" panel  \n4. **Generate Migration**: Click \"Compare\" to generate the synchronization script\n5. **Copy \u0026 Execute**: Use the \"Copy Diff\" button to copy the generated `sync_schema.sql` script to your clipboard, then paste it into your SQL editor and run it on your database\n\n## 🔧 Available Scripts\n\n- `pnpm dev` - Start development server with Turbopack\n- `pnpm build` - Build for production\n- `pnpm start` - Start production server\n- `pnpm lint` - Run ESLint\n\n## 🛡️ Safety Features\n\n- **Existence Checks**: Every operation includes proper existence validation\n- **Transaction Wrapping**: All changes wrapped in TRY/CATCH transactions\n- **Idempotent Scripts**: Safe to run multiple times\n- **Rollback Support**: Automatic rollback on errors\n\n## 📝 Example Workflow\n\n```sql\n-- Generated script structure:\nBEGIN TRY\n  BEGIN TRANSACTION;\n    -- === 1. DROP obsolete objects ===\n    -- === 2. CREATE/ALTER tables and columns ===\n    -- === 3. CREATE/ALTER constraints ===\n    -- === 4. CREATE/ALTER indexes ===\n    -- === 5. CREATE/ALTER views/SPs/functions/triggers ===\n    -- === 6. Seed data updates ===\n  COMMIT;\nEND TRY\nBEGIN CATCH\n  ROLLBACK;\n  THROW;\nEND CATCH;\n```\n\n## 🤝 Contributing\n\nThis project is designed for local use and development. Feel free to fork and customize for your specific needs.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctaviocossy%2Fcomparedb-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctaviocossy%2Fcomparedb-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctaviocossy%2Fcomparedb-ai/lists"}