{"id":46250999,"url":"https://github.com/proj-airi/drizzle-orm-browser","last_synced_at":"2026-03-03T22:11:37.715Z","repository":{"id":299677581,"uuid":"1003841870","full_name":"proj-airi/drizzle-orm-browser","owner":"proj-airi","description":"🌧️ Drizzle ORM migrations during runtime, in browser!","archived":false,"fork":false,"pushed_at":"2025-11-27T12:20:43.000Z","size":499,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-30T03:32:33.509Z","etag":null,"topics":["database-migrations","drizzle-orm","duckdb-wasm","local-first","pglite","proj-airi","unplugin"],"latest_commit_sha":null,"homepage":"https://proj-airi-drizzle-orm-browser.netlify.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/proj-airi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":["nekomeowww"]}},"created_at":"2025-06-17T18:46:12.000Z","updated_at":"2025-11-27T12:20:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"14692f0c-4bb5-430d-855d-598847c4295a","html_url":"https://github.com/proj-airi/drizzle-orm-browser","commit_stats":null,"previous_names":["proj-airi/drizzle-orm-browser"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/proj-airi/drizzle-orm-browser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proj-airi%2Fdrizzle-orm-browser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proj-airi%2Fdrizzle-orm-browser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proj-airi%2Fdrizzle-orm-browser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proj-airi%2Fdrizzle-orm-browser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/proj-airi","download_url":"https://codeload.github.com/proj-airi/drizzle-orm-browser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proj-airi%2Fdrizzle-orm-browser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30063561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["database-migrations","drizzle-orm","duckdb-wasm","local-first","pglite","proj-airi","unplugin"],"created_at":"2026-03-03T22:11:36.998Z","updated_at":"2026-03-03T22:11:37.700Z","avatar_url":"https://github.com/proj-airi.png","language":"TypeScript","readme":"# Drizzle ORM Browser Utilities\n\n\u003e [!NOTE]\n\u003e\n\u003e This project is part of (and also associate to) the [Project AIRI](https://github.com/moeru-ai/airi),\n\u003e we aim to build a LLM-driven VTuber like [Neuro-sama](https://www.youtube.com/@Neurosama) (subscribe\n\u003e  if you didn't!) if you are interested in, please do give it a try on [live demo](https://airi.moeru.ai).\n\n## Getting Started\n\n```shell\n# from @antfu/ni, can be installed via `npm i -g @antfu/ni`\nni -D @proj-airi/unplugin-drizzle-orm-migrations @proj-airi/drizzle-orm-browser-migrator\npnpm i -D @proj-airi/unplugin-drizzle-orm-migrations @proj-airi/drizzle-orm-browser-migrator\nyarn i -D @proj-airi/unplugin-drizzle-orm-migrations @proj-airi/drizzle-orm-browser-migrator\nnpm i -D @proj-airi/unplugin-drizzle-orm-migrations @proj-airi/drizzle-orm-browser-migrator\n```\n\nConfigure your `vite.config.ts` (or rolldown, rspack, Webpack, esbuild, all supported) to use the plugin:\n\n```ts\nimport DrizzleORMMigrations from '@proj-airi/unplugin-drizzle-orm-migrations/vite'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  plugins: [\n    // ... other plugins\n    DrizzleORMMigrations()\n  ]\n})\n```\n\nIn your actual initialization code (e.g. `src/main.ts`, `src/App.vue`, `src/App.tsx` or `src/index.ts`):\n\n```ts\nimport { IdbFs, PGlite } from '@electric-sql/pglite'\n// Import the migrator\nimport { migrate } from '@proj-airi/drizzle-orm-browser-migrator/pglite'\nimport { drizzle } from 'drizzle-orm/pglite'\n// Import the bundled migrations\nimport migrations from 'virtual:drizzle-migrations.sql'\n\nconst pgLite = new PGlite({ fs: new IdbFs('pglite-database') })\nconst db = drizzle({ client: pgLite })\n\n// Apply the migrations\nawait migrate(db, migrations)\n```\n\n## Why?\n\nBuilding a local-first app, or embedded memory system for LLMs in browser? It's\nhard to run migrations in browser with `drizzle-kit` currently, where `drizzle-kit`\nis essentially a CLI tool runs migrations automatically in Node.js environment requires\nTTY (or terminal you can interact with).\n\nWell what `drizzle-kit generate` does, is to generate a set of migration files based on the diff (difference)\ncalculated from the current specified schema (which you would normally configure in `drizzle.config.ts` with\nthe property of `schema`) with the journal and snapshots of the schemas (usually the files specified in\n`drizzle.config.ts` with property `out`).\n\nImagine we got this configuration for `drizzle.config.ts` for our local-first or memory app, we are integrating [PGLite](https://pglite.dev):\n\n```ts\nimport { defineConfig } from 'drizzle-kit'\n\nexport default defineConfig({\n  out: './drizzle',\n  schema: './src/db/schema.ts',\n  dialect: 'postgresql',\n})\n```\n\nand having this `src/db/schema.ts`:\n\n```ts\n// Drizzle ORM - PostgreSQL\n// https://orm.drizzle.team/docs/get-started/pglite-new\n\nimport { bigint, pgTable, varchar } from 'drizzle-orm/pg-core'\n\nexport const usersTable = pgTable('users', {\n  id: bigint().primaryKey().generatedAlwaysAsIdentity(),\n  name: varchar({ length: 255 }).notNull(),\n})\n```\n\nAfter we call `drizzle-kit generate`, it will generate a migration file in `./drizzle` directory, which\nconsist the following files:\n\n```shell\ndrizzle\n├── 0000_colorful_patch.sql\n└── meta\n    ├── 0000_snapshot.json\n    └── _journal.json\n\n2 directories, 5 files\n```\n\nWhere `0000_${random_generated_name}.sql` is the migration file, and `meta` directory contains\nthe snapshot of the schema and journal of the migrations.\n\nOne way to achieve the running migrations of the generated files in browser is to leverage the\ncapability of `vite` and `esbuild` supported `?raw` import syntax, which allows you to import\nthe content of the file as a string, and then you can execute the SQL statements with the database\nconnection you initialized in browser.\n\nStill, there leaves some problems for versioned migrations, where you have to implement a basic\nstorage system to keep track of the applied migrations to avoid running the same migration\nmultiple times.\n\nThe sub-packages in this repository provides a way to both bundle the migrations into a virtual\nmodule like how UnoCSS, and generated file-system based router like `unplugin-vue-router`, as\n\n```ts\nimport migrations from 'virtual:drizzle-migrations.sql'\n```\n\nas well as a browser environment compatible migrator implementation that can apply the migrations\nin versioned manner:\n\n```ts\nimport { IdbFs, PGlite } from '@electric-sql/pglite'\nimport { migrate } from '@proj-airi/drizzle-orm-browser-migrator/pglite'\nimport { drizzle } from 'drizzle-orm/pglite'\nimport migrations from 'virtual:drizzle-migrations.sql'\n\nconst pgLite = new PGlite({ fs: new IdbFs('pglite-database') })\nconst db = drizzle({ client: pgLite })\nawait migrate(db, migrations)\n```\n\n## TypeScript support\n\nAdd the following to your `tsconfig.json` to enable type support for the virtual module:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\n      \"@proj-airi/unplugin-drizzle-orm-migrations/types\"\n    ]\n  }\n}\n```\n\n## Packages\n\n- [`@proj-airi/drizzle-orm-browser-migrator`](https://github.com/proj-airi/drizzle-orm-browser/tree/main/packages/drizzle-orm-browser-migrator): 🦆 Drizzle ORM migrator applies migrations in browser environment, for PGLite, SQLite, DuckDB WASM!\n- [`@proj-airi/unplugin-drizzle-orm-migrations`](https://github.com/proj-airi/drizzle-orm-browser/tree/main/packages/unplugin-drizzle-orm-migrations): 🦆 Drizzle ORM migrations bundler plugin for bundling drizzle-kit migrations!\n\n### Development\n\n```bash\npnpm dev\n```\n\n## Other side projects born from Project AIRI\n\n- [Awesome AI VTuber](https://github.com/proj-airi/awesome-ai-vtuber): A curated list of AI VTubers and related projects\n- [`unspeech`](https://github.com/moeru-ai/unspeech): Universal endpoint proxy server for `/audio/transcriptions` and `/audio/speech`, like LiteLLM but for any ASR and TTS\n- [`hfup`](https://github.com/moeru-ai/hfup): tools to help on deploying, bundling to HuggingFace Spaces\n- [`xsai-transformers`](https://github.com/moeru-ai/xsai-transformers): Experimental [🤗 Transformers.js](https://github.com/huggingface/transformers.js) provider for [xsAI](https://github.com/moeru-ai/xsai).\n- [WebAI: Realtime Voice Chat](https://github.com/proj-airi/webai-realtime-voice-chat): Full example of implementing ChatGPT's realtime voice from scratch with VAD + STT + LLM + TTS.\n- [`@proj-airi/drizzle-duckdb-wasm`](https://github.com/moeru-ai/airi/tree/main/packages/drizzle-duckdb-wasm/README.md): Drizzle ORM driver for DuckDB WASM\n- [`@proj-airi/duckdb-wasm`](https://github.com/moeru-ai/airi/tree/main/packages/duckdb-wasm/README.md): Easy to use wrapper for `@duckdb/duckdb-wasm`\n- [Airi Factorio](https://github.com/moeru-ai/airi-factorio): Allow Airi to play Factorio\n- [Factorio RCON API](https://github.com/nekomeowww/factorio-rcon-api): RESTful API wrapper for Factorio headless server console\n- [`autorio`](https://github.com/moeru-ai/airi-factorio/tree/main/packages/autorio): Factorio automation library\n- [`tstl-plugin-reload-factorio-mod`](https://github.com/moeru-ai/airi-factorio/tree/main/packages/tstl-plugin-reload-factorio-mod): Reload Factorio mod when developing\n- [Velin](https://github.com/luoling8192/velin): Use Vue SFC and Markdown to write easy to manage stateful prompts for LLM\n- [`demodel`](https://github.com/moeru-ai/demodel): Easily boost the speed of pulling your models and datasets from various of inference runtimes.\n- [`inventory`](https://github.com/moeru-ai/inventory): Centralized model catalog and default provider configurations backend service\n- [MCP Launcher](https://github.com/moeru-ai/mcp-launcher): Easy to use MCP builder \u0026 launcher for all possible MCP servers, just like Ollama for models!\n- [🥺 SAD](https://github.com/moeru-ai/sad): Documentation and notes for self-host and browser running LLMs.\n\n## Acknowledgements\n\n- Comments under [FEATURE]: Running Migrations in the Browser for Local-First Apps: https://github.com/drizzle-team/drizzle-orm/issues/1009\n- Especially https://github.com/drizzle-team/drizzle-orm/issues/1009#issuecomment-2454115147\n","funding_links":["https://github.com/sponsors/nekomeowww"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproj-airi%2Fdrizzle-orm-browser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproj-airi%2Fdrizzle-orm-browser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproj-airi%2Fdrizzle-orm-browser/lists"}