├── supabase
├── seed.sql
├── .gitignore
└── README.md
├── patches
└── README.md
├── vscode-extension
├── .gitignore
├── icon.png
├── media
│ ├── drizzle.png
│ └── drizzle_dark.png
├── README.md
├── .vscodeignore
├── src
│ ├── modules
│ │ ├── visualizer
│ │ │ ├── stop-visualizer
│ │ │ │ └── command.ts
│ │ │ ├── panel.ts
│ │ │ └── open-visualizer
│ │ │ │ └── codelens.ts
│ │ └── studio
│ │ │ ├── stop-studio
│ │ │ └── command.ts
│ │ │ ├── panel.ts
│ │ │ └── open-studio
│ │ │ └── codelens.ts
│ └── views
│ │ └── index.tsx
├── tsconfig.json
└── LICENSE
├── apps
├── drizzle-run
│ ├── app
│ │ ├── registry
│ │ │ ├── .gitignore
│ │ │ ├── .prettierrc
│ │ │ ├── README.md
│ │ │ ├── dialects
│ │ │ │ ├── sqlite
│ │ │ │ │ ├── presets
│ │ │ │ │ │ ├── _blank
│ │ │ │ │ │ │ ├── manifest.json
│ │ │ │ │ │ │ ├── db.ts
│ │ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ │ └── schema.ts
│ │ │ │ │ │ └── starter-01
│ │ │ │ │ │ │ ├── manifest.json
│ │ │ │ │ │ │ ├── db.ts
│ │ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ │ └── seed.ts
│ │ │ │ │ └── core
│ │ │ │ │ │ ├── utils.ts
│ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ ├── schema.ts
│ │ │ │ │ │ ├── seed.ts
│ │ │ │ │ │ └── db.ts
│ │ │ │ ├── postgresql
│ │ │ │ │ ├── presets
│ │ │ │ │ │ ├── _blank
│ │ │ │ │ │ │ ├── manifest.json
│ │ │ │ │ │ │ ├── db.ts
│ │ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ │ └── schema.ts
│ │ │ │ │ │ ├── starter-01
│ │ │ │ │ │ │ ├── manifest.json
│ │ │ │ │ │ │ ├── db.ts
│ │ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ │ ├── seed.ts
│ │ │ │ │ │ │ └── schema.ts
│ │ │ │ │ │ └── rls
│ │ │ │ │ │ │ ├── manifest.json
│ │ │ │ │ │ │ ├── db.ts
│ │ │ │ │ │ │ └── seed.ts
│ │ │ │ │ └── core
│ │ │ │ │ │ ├── utils.ts
│ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ ├── schema.ts
│ │ │ │ │ │ ├── seed.ts
│ │ │ │ │ │ └── db.ts
│ │ │ │ └── manifest.schema.json
│ │ │ ├── utils
│ │ │ │ └── query-logger.ts
│ │ │ ├── meta.schema.json
│ │ │ └── presets.test.ts
│ │ ├── utils
│ │ │ ├── is-browser.ts
│ │ │ ├── cn.ts
│ │ │ ├── robot.ts
│ │ │ ├── assert.ts
│ │ │ ├── use-is-mobile-app-layout.ts
│ │ │ ├── use-form.ts
│ │ │ └── use-dialog.ts
│ │ ├── routes
│ │ │ ├── _.$.tsx
│ │ │ ├── auth.sign-out
│ │ │ │ └── route.tsx
│ │ │ └── healthcheck.tsx
│ │ ├── database
│ │ │ ├── utils.ts
│ │ │ ├── .client
│ │ │ │ ├── migrations
│ │ │ │ │ ├── meta
│ │ │ │ │ │ └── _journal.json
│ │ │ │ │ ├── 0000_init.sql
│ │ │ │ │ └── export.json
│ │ │ │ └── schema.ts
│ │ │ ├── .server
│ │ │ │ ├── migrations
│ │ │ │ │ ├── meta
│ │ │ │ │ │ └── _journal.json
│ │ │ │ │ └── 0001_unknown_unicorn.sql
│ │ │ │ ├── db.ts
│ │ │ │ └── relations.ts
│ │ │ ├── scripts
│ │ │ │ └── export-local-db-migrations.ts
│ │ │ └── types.ts
│ │ ├── routes.ts
│ │ ├── components
│ │ │ ├── ui
│ │ │ │ ├── icons
│ │ │ │ │ └── README.md
│ │ │ │ ├── skeleton.tsx
│ │ │ │ ├── label.tsx
│ │ │ │ ├── separator.tsx
│ │ │ │ ├── textarea.tsx
│ │ │ │ ├── input.tsx
│ │ │ │ ├── sonner.tsx
│ │ │ │ ├── checkbox.tsx
│ │ │ │ ├── badge.tsx
│ │ │ │ └── tooltip.tsx
│ │ │ ├── toolbar.tsx
│ │ │ ├── nav-item.tsx
│ │ │ └── anonymous-cta.tsx
│ │ ├── entry.client.tsx
│ │ ├── modules
│ │ │ └── playground
│ │ │ │ └── highlighter.ts
│ │ └── server
│ │ │ ├── session.ts
│ │ │ ├── index.ts
│ │ │ └── middleware.ts
│ ├── .drizzle-lab
│ │ ├── client.json
│ │ ├── visualizer.json
│ │ └── server.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── fonts
│ │ │ ├── Inter-Medium.ttf
│ │ │ └── Inter-Regular.ttf
│ ├── types
│ │ ├── reset.d.ts
│ │ ├── icon-name.d.ts
│ │ ├── brand.d.ts
│ │ └── global.d.ts
│ ├── react-router.config.ts
│ ├── other
│ │ ├── svg-icons
│ │ │ ├── x.svg
│ │ │ ├── check.svg
│ │ │ ├── chevron-right.svg
│ │ │ ├── play.svg
│ │ │ ├── cloud.svg
│ │ │ ├── chevrons-up-down.svg
│ │ │ ├── code.svg
│ │ │ ├── user-round.svg
│ │ │ ├── panel-top.svg
│ │ │ ├── info.svg
│ │ │ ├── captions.svg
│ │ │ ├── lock.svg
│ │ │ ├── ellipsis-vertical.svg
│ │ │ ├── history.svg
│ │ │ ├── arrow-right-left.svg
│ │ │ ├── circle-user-round.svg
│ │ │ ├── database.svg
│ │ │ ├── square-terminal.svg
│ │ │ ├── book-text.svg
│ │ │ ├── diamond.svg
│ │ │ ├── settings-2.svg
│ │ │ ├── cloud-upload.svg
│ │ │ ├── external-link.svg
│ │ │ ├── camera.svg
│ │ │ ├── share.svg
│ │ │ ├── ghost.svg
│ │ │ ├── log-out.svg
│ │ │ ├── clipboard.svg
│ │ │ ├── eye.svg
│ │ │ ├── link.svg
│ │ │ ├── triangle-alert.svg
│ │ │ ├── eraser.svg
│ │ │ ├── wrench.svg
│ │ │ ├── file-pen-line.svg
│ │ │ ├── braces.svg
│ │ │ ├── shield.svg
│ │ │ ├── shrink.svg
│ │ │ ├── cloud-off.svg
│ │ │ ├── clipboard-check.svg
│ │ │ ├── folder-open.svg
│ │ │ ├── box.svg
│ │ │ ├── book-image.svg
│ │ │ ├── git-fork.svg
│ │ │ ├── list-restart.svg
│ │ │ ├── badge-check.svg
│ │ │ ├── save.svg
│ │ │ ├── shield-check.svg
│ │ │ ├── image-down.svg
│ │ │ ├── captions-off.svg
│ │ │ ├── share-2.svg
│ │ │ ├── trash-2.svg
│ │ │ ├── loader-pinwheel.svg
│ │ │ ├── sheet.svg
│ │ │ ├── key-round.svg
│ │ │ ├── view.svg
│ │ │ ├── box-plus.svg
│ │ │ ├── sprout.svg
│ │ │ ├── cable.svg
│ │ │ ├── github.svg
│ │ │ ├── wand-sparkles.svg
│ │ │ ├── bug-off.svg
│ │ │ ├── telescope.svg
│ │ │ ├── bug-play.svg
│ │ │ └── bug.svg
│ │ └── sly.json
│ ├── drizzle.client.config.ts
│ ├── drizzle.server.config.ts
│ ├── .env.example
│ ├── fly.toml
│ └── tsconfig.json
└── cli
│ ├── example
│ ├── pg
│ │ ├── external.ts
│ │ └── drizzle.config.ts
│ ├── multi-files-barrel
│ │ ├── schemas
│ │ │ ├── index.ts
│ │ │ ├── users.ts
│ │ │ └── relations.ts
│ │ ├── enums.ts
│ │ ├── index.ts
│ │ └── drizzle.config.ts
│ ├── multi-files
│ │ ├── schemas
│ │ │ ├── users.ts
│ │ │ └── relations.ts
│ │ └── drizzle.config.ts
│ ├── multi-packages
│ │ ├── package-users
│ │ │ └── database
│ │ │ │ └── schema.ts
│ │ ├── drizzle.config.ts
│ │ ├── drizzle.config.dev.ts
│ │ └── package-relations
│ │ │ └── database
│ │ │ └── relations.ts
│ ├── sqlite
│ │ └── drizzle.config.ts
│ └── mysql
│ │ └── drizzle.config.ts
│ ├── .gitignore
│ ├── public
│ ├── error.webp
│ └── favicon.png
│ ├── postcss.config.js
│ ├── tsconfig.build.json
│ ├── .eslintrc.cjs
│ ├── tailwind.config.ts
│ ├── visualizer
│ └── entry.client.tsx
│ ├── drizzle.config.ts
│ ├── tsconfig.json
│ └── LICENSE
├── .env.example
├── packages
├── api
│ ├── src
│ │ ├── extensions
│ │ │ ├── index.ts
│ │ │ └── symbols.ts
│ │ ├── sql
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── relations
│ │ │ └── index.ts
│ │ ├── pg
│ │ │ ├── index.node.ts
│ │ │ ├── index.web.ts
│ │ │ ├── utils.ts
│ │ │ └── index.ts
│ │ ├── sqlite
│ │ │ ├── index.node.ts
│ │ │ ├── index.web.ts
│ │ │ ├── index.ts
│ │ │ └── serializer
│ │ │ │ └── sql-to-snapshot.ts
│ │ ├── mysql
│ │ │ ├── index.node.ts
│ │ │ ├── index.web.ts
│ │ │ └── index.ts
│ │ ├── config
│ │ │ ├── index.node.ts
│ │ │ └── env.node.ts
│ │ └── internal
│ │ │ ├── relations.ts
│ │ │ └── style.ts
│ ├── tsconfig.json
│ └── tsup.config.ts
└── visualizer
│ ├── vite-env.d.ts
│ ├── src
│ ├── index.ts
│ ├── lib
│ │ └── utils.ts
│ └── components
│ │ ├── theme.ts
│ │ └── ui
│ │ └── separator.tsx
│ ├── demo
│ ├── main.tsx
│ └── app.tsx
│ ├── .gitignore
│ ├── components.json
│ ├── index.html
│ ├── tsconfig.json
│ ├── vite.config.ts
│ └── README.md
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── docs-template.yaml
│ └── feature-template.yaml
└── PULL_REQUEST_TEMPLATE.md
├── shared
├── eslint-config
│ ├── README.md
│ └── package.json
├── typescript-config
│ ├── reset.d.ts
│ ├── package.json
│ ├── react-library.json
│ ├── remix.json
│ ├── base.json
│ └── node-library.json
├── ui
│ ├── types
│ │ └── icon-name.d.ts
│ ├── src
│ │ ├── icons
│ │ │ └── README.md
│ │ ├── utils
│ │ │ └── cn.ts
│ │ └── components
│ │ │ ├── skeleton.tsx
│ │ │ ├── label.tsx
│ │ │ ├── textarea.tsx
│ │ │ ├── input.tsx
│ │ │ ├── separator.tsx
│ │ │ ├── sonner.tsx
│ │ │ ├── checkbox.tsx
│ │ │ └── switch.tsx
│ ├── turbo.json
│ ├── .eslintrc.cjs
│ ├── other
│ │ ├── sly.json
│ │ └── svg-icons
│ │ │ ├── check.svg
│ │ │ ├── chevron-right.svg
│ │ │ ├── play.svg
│ │ │ ├── cloud.svg
│ │ │ ├── chevrons-up-down.svg
│ │ │ ├── user-round.svg
│ │ │ ├── code.svg
│ │ │ ├── panel-top.svg
│ │ │ ├── info.svg
│ │ │ ├── lock.svg
│ │ │ ├── captions.svg
│ │ │ ├── ellipsis-vertical.svg
│ │ │ ├── arrow-right-left.svg
│ │ │ ├── circle-user-round.svg
│ │ │ ├── history.svg
│ │ │ ├── database.svg
│ │ │ ├── diamond.svg
│ │ │ ├── settings-2.svg
│ │ │ ├── square-terminal.svg
│ │ │ ├── book-text.svg
│ │ │ ├── cloud-upload.svg
│ │ │ ├── external-link.svg
│ │ │ ├── camera.svg
│ │ │ ├── log-out.svg
│ │ │ ├── share.svg
│ │ │ ├── clipboard.svg
│ │ │ ├── eye.svg
│ │ │ ├── ghost.svg
│ │ │ ├── link.svg
│ │ │ ├── triangle-alert.svg
│ │ │ ├── eraser.svg
│ │ │ ├── file-pen-line.svg
│ │ │ ├── wrench.svg
│ │ │ ├── braces.svg
│ │ │ ├── shield.svg
│ │ │ ├── shrink.svg
│ │ │ ├── clipboard-check.svg
│ │ │ ├── cloud-off.svg
│ │ │ ├── box.svg
│ │ │ ├── folder-open.svg
│ │ │ ├── book-image.svg
│ │ │ ├── git-fork.svg
│ │ │ ├── badge-check.svg
│ │ │ ├── list-restart.svg
│ │ │ ├── image-down.svg
│ │ │ ├── save.svg
│ │ │ ├── shield-check.svg
│ │ │ ├── captions-off.svg
│ │ │ ├── share-2.svg
│ │ │ ├── trash-2.svg
│ │ │ ├── loader-pinwheel.svg
│ │ │ ├── sheet.svg
│ │ │ ├── key-round.svg
│ │ │ ├── view.svg
│ │ │ ├── box-plus.svg
│ │ │ ├── sprout.svg
│ │ │ ├── cable.svg
│ │ │ ├── github.svg
│ │ │ ├── wand-sparkles.svg
│ │ │ ├── bug-off.svg
│ │ │ ├── telescope.svg
│ │ │ ├── bug-play.svg
│ │ │ └── bug.svg
│ ├── tsconfig.json
│ └── components.json
└── eslint-plugin-node-imports
│ └── package.json
├── .gitignore
├── .vscode
├── extensions.json
├── settings.json
└── launch.json
├── .changeset
├── config.json
└── README.md
├── .dockerignore
├── pnpm-workspace.yaml
├── turbo.json
└── README.md
/supabase/seed.sql:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/patches/README.md:
--------------------------------------------------------------------------------
1 | Patches
--------------------------------------------------------------------------------
/vscode-extension/.gitignore:
--------------------------------------------------------------------------------
1 | apps/visualizer
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/.gitignore:
--------------------------------------------------------------------------------
1 | dist
--------------------------------------------------------------------------------
/apps/cli/example/pg/external.ts:
--------------------------------------------------------------------------------
1 | export const info = "test";
2 |
--------------------------------------------------------------------------------
/supabase/.gitignore:
--------------------------------------------------------------------------------
1 | # Supabase
2 | .branches
3 | .temp
4 | .env
5 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | SUPABASE_AUTH_GITHUB_CLIENT_ID=
2 | SUPABASE_AUTH_GITHUB_SECRET=
--------------------------------------------------------------------------------
/packages/api/src/extensions/index.ts:
--------------------------------------------------------------------------------
1 | export { explain } from "./explain";
2 |
--------------------------------------------------------------------------------
/packages/visualizer/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/packages/api/src/sql/index.ts:
--------------------------------------------------------------------------------
1 | export { splitSqlStatements } from "./utils";
2 |
--------------------------------------------------------------------------------
/supabase/README.md:
--------------------------------------------------------------------------------
1 | # This is to run Supabase locally
2 |
3 | TODO: add instructions
--------------------------------------------------------------------------------
/apps/drizzle-run/.drizzle-lab/client.json:
--------------------------------------------------------------------------------
1 | [{"id":"playground","position":{"x":-320,"y":-360}}]
--------------------------------------------------------------------------------
/packages/api/src/relations/index.ts:
--------------------------------------------------------------------------------
1 | export { relationsToTypeScript } from "./typescript";
2 |
--------------------------------------------------------------------------------
/apps/cli/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | /.cache
4 | build
5 | dist
6 | .env
7 | .drizzle-lab/
--------------------------------------------------------------------------------
/apps/drizzle-run/.drizzle-lab/visualizer.json:
--------------------------------------------------------------------------------
1 | [{"id":"playground","position":{"x":-200,"y":-60}}]
--------------------------------------------------------------------------------
/packages/api/src/extensions/symbols.ts:
--------------------------------------------------------------------------------
1 | export const DrizzleLab = Symbol.for("drizzle:lab");
2 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/is-browser.ts:
--------------------------------------------------------------------------------
1 | export const isBrowser = typeof document !== "undefined";
2 |
--------------------------------------------------------------------------------
/apps/cli/public/error.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/apps/cli/public/error.webp
--------------------------------------------------------------------------------
/apps/cli/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/apps/cli/public/favicon.png
--------------------------------------------------------------------------------
/vscode-extension/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/vscode-extension/icon.png
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [rphlmr, drizzle-team]
4 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/routes/_.$.tsx:
--------------------------------------------------------------------------------
1 | export default function NotFound() {
2 | return
Not found
;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/api/src/pg/index.node.ts:
--------------------------------------------------------------------------------
1 | export * from ".";
2 | export { importFromFiles } from "./loader/files.node.ts";
3 |
--------------------------------------------------------------------------------
/shared/eslint-config/README.md:
--------------------------------------------------------------------------------
1 | # `@turbo/eslint-config`
2 |
3 | Collection of internal eslint configurations.
4 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 2,
3 | "useTabs": false,
4 | "printWidth": 120
5 | }
6 |
--------------------------------------------------------------------------------
/packages/api/src/sqlite/index.node.ts:
--------------------------------------------------------------------------------
1 | export * from ".";
2 | export { importFromFiles } from "./loader/files.node.ts";
3 |
--------------------------------------------------------------------------------
/vscode-extension/media/drizzle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/vscode-extension/media/drizzle.png
--------------------------------------------------------------------------------
/apps/drizzle-run/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/apps/drizzle-run/public/favicon.ico
--------------------------------------------------------------------------------
/apps/cli/postcss.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/apps/drizzle-run/.drizzle-lab/server.json:
--------------------------------------------------------------------------------
1 | [{"id":"playground","position":{"x":0,"y":-180}},{"id":"user","position":{"x":460,"y":20}}]
--------------------------------------------------------------------------------
/apps/drizzle-run/types/reset.d.ts:
--------------------------------------------------------------------------------
1 | // Do not add any other lines of code to this file!
2 | import "@total-typescript/ts-reset";
3 |
--------------------------------------------------------------------------------
/packages/api/src/mysql/index.node.ts:
--------------------------------------------------------------------------------
1 | export * from "./index.ts";
2 | export { importFromFiles } from "./loader/files.node.ts";
3 |
--------------------------------------------------------------------------------
/shared/typescript-config/reset.d.ts:
--------------------------------------------------------------------------------
1 | // Do not add any other lines of code to this file!
2 | import "@total-typescript/ts-reset";
3 |
--------------------------------------------------------------------------------
/vscode-extension/media/drizzle_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/vscode-extension/media/drizzle_dark.png
--------------------------------------------------------------------------------
/shared/ui/types/icon-name.d.ts:
--------------------------------------------------------------------------------
1 | // This file is a fallback until you run npm run icons build
2 |
3 | export type IconName = string;
4 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files-barrel/schemas/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./users";
2 | export * from "./posts";
3 | export * from "./relations";
4 |
--------------------------------------------------------------------------------
/apps/drizzle-run/types/icon-name.d.ts:
--------------------------------------------------------------------------------
1 | // This file is a fallback until you run npm run icons build
2 |
3 | export type IconName = string;
4 |
--------------------------------------------------------------------------------
/packages/api/src/pg/index.web.ts:
--------------------------------------------------------------------------------
1 | export type { Snapshot } from "./schema";
2 | export { schemaToSnapshot } from "./serializer/snapshot";
3 |
--------------------------------------------------------------------------------
/apps/drizzle-run/public/fonts/Inter-Medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/apps/drizzle-run/public/fonts/Inter-Medium.ttf
--------------------------------------------------------------------------------
/apps/drizzle-run/public/fonts/Inter-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rphlmr/drizzle-lab/HEAD/apps/drizzle-run/public/fonts/Inter-Regular.ttf
--------------------------------------------------------------------------------
/packages/api/src/mysql/index.web.ts:
--------------------------------------------------------------------------------
1 | export { schemaToSnapshot } from "./serializer/snapshot";
2 |
3 | export type { Snapshot } from "./schema";
4 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/utils.ts:
--------------------------------------------------------------------------------
1 | import { sql } from "drizzle-orm/sql";
2 |
3 | export function now() {
4 | return sql`now()`;
5 | }
6 |
--------------------------------------------------------------------------------
/packages/api/src/sqlite/index.web.ts:
--------------------------------------------------------------------------------
1 | export { schemaToSnapshot } from "./serializer/snapshot";
2 |
3 | export type { Snapshot } from "./schema";
4 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files-barrel/enums.ts:
--------------------------------------------------------------------------------
1 | import { pgEnum } from "drizzle-orm/pg-core";
2 |
3 | export const postTypeEnum = pgEnum("post_type", ["mobile_app", "web_app"]);
4 |
--------------------------------------------------------------------------------
/packages/visualizer/src/index.ts:
--------------------------------------------------------------------------------
1 | "use client";
2 |
3 | import "./style.css";
4 |
5 | export * from "./compute";
6 | export * from "./legend";
7 | export * from "./visualizer";
8 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files-barrel/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./enums";
2 | export * from "./schemas/posts";
3 | export * from "./schemas/users";
4 | export * from "./schemas/relations";
5 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/README.md:
--------------------------------------------------------------------------------
1 | TODO: add instructions
2 |
3 | `db:generate` does not use `drizzle.config.ts` because Firefox is unable to handle `require("not/node_module/file.ts")`
--------------------------------------------------------------------------------
/vscode-extension/README.md:
--------------------------------------------------------------------------------
1 | # Drizzle ORM VSCode Extension
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/shared/ui/src/icons/README.md:
--------------------------------------------------------------------------------
1 | # Icons
2 |
3 | This directory contains SVG icons that are used by the app.
4 |
5 | Everything in this directory is generated by running `icons build`.
6 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/_blank/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../../manifest.schema.json",
3 | "name": "Blank",
4 | "description": "Start from scratch"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/api/src/config/index.node.ts:
--------------------------------------------------------------------------------
1 | export type { Config, PartialConfig } from "./loader.node.ts";
2 | export { importDrizzleConfig } from "./loader.node.ts";
3 | export * from "./env.node.ts";
4 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/_blank/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../../manifest.schema.json",
3 | "name": "Blank",
4 | "description": "Start from scratch"
5 | }
6 |
--------------------------------------------------------------------------------
/apps/drizzle-run/types/brand.d.ts:
--------------------------------------------------------------------------------
1 | export {};
2 |
3 | declare global {
4 | declare const brand: unique symbol;
5 |
6 | export type Brand = T & { [brand]: TBrand };
7 | }
8 |
--------------------------------------------------------------------------------
/shared/ui/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://turbo.build/schema.json",
3 | "extends": ["//"],
4 | "tasks": {
5 | "build": {
6 | "outputs": ["dist/**"]
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/routes.ts:
--------------------------------------------------------------------------------
1 | import type { RouteConfig } from "@react-router/dev/routes";
2 | import { flatRoutes } from "@react-router/fs-routes";
3 |
4 | export default flatRoutes() satisfies RouteConfig;
5 |
--------------------------------------------------------------------------------
/apps/drizzle-run/react-router.config.ts:
--------------------------------------------------------------------------------
1 | import type { Config } from "@react-router/dev/config";
2 |
3 | export default {
4 | future: {
5 | unstable_optimizeDeps: true,
6 | },
7 | } satisfies Config;
8 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/icons/README.md:
--------------------------------------------------------------------------------
1 | # Icons
2 |
3 | This directory contains SVG icons that are used by the app.
4 |
5 | Everything in this directory is generated by running `icons build`.
6 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/core/utils.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any utilities you want to use in the playground
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
--------------------------------------------------------------------------------
/shared/ui/src/utils/cn.ts:
--------------------------------------------------------------------------------
1 | import { type ClassValue, clsx } from "clsx";
2 | import { twMerge } from "tailwind-merge";
3 |
4 | export function cn(...inputs: ClassValue[]) {
5 | return twMerge(clsx(inputs));
6 | }
7 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/core/utils.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any utilities you want to use in the playground
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/_blank/db.ts:
--------------------------------------------------------------------------------
1 | // Do not commit this file, it is replaced by the template db file
2 | // This file is only used to type-check the preset
3 |
4 | export const db = {};
5 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/_blank/db.ts:
--------------------------------------------------------------------------------
1 | // Do not commit this file, it is replaced by the template db file
2 | // This file is only used to type-check the preset
3 |
4 | export const db = {};
5 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/starter-01/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../../manifest.schema.json",
3 | "name": "Simple example",
4 | "description": "A simple example to start with"
5 | }
6 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/cn.ts:
--------------------------------------------------------------------------------
1 | import { type ClassValue, clsx } from "clsx";
2 | import { twMerge } from "tailwind-merge";
3 |
4 | export function cn(...inputs: ClassValue[]) {
5 | return twMerge(clsx(inputs));
6 | }
7 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/starter-01/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../../manifest.schema.json",
3 | "name": "Simple example",
4 | "description": "A simple example to start with"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/visualizer/src/lib/utils.ts:
--------------------------------------------------------------------------------
1 | import { type ClassValue, clsx } from "clsx";
2 | import { twMerge } from "tailwind-merge";
3 |
4 | export function cn(...inputs: ClassValue[]) {
5 | return twMerge(clsx(inputs));
6 | }
7 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/core/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Write your code here
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
6 | import { db } from "./db";
7 | import {} from "./schema";
8 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/core/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Write your code here
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
6 | import { db } from "./db";
7 | import {} from "./schema";
8 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/_blank/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Write your code here
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
6 | import { db } from "./db";
7 | import {} from "./schema";
8 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/_blank/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Write your code here
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
6 | import { db } from "./db";
7 | import {} from "./schema";
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .turbo
3 | **/.cache
4 | build/
5 | dist
6 | *.env*
7 | !*.env.example
8 |
9 | templates/*/drizzle
10 | container
11 | *.wasm
12 | .drizzle/
13 | *.vsix
14 | *.tgz
15 |
16 | # React Router
17 | **/.react-router/
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/rls/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../../manifest.schema.json",
3 | "name": "(Experimental) Row Level Security (RLS)",
4 | "description": "A demo of RLS with a Supabase emulator"
5 | }
6 |
--------------------------------------------------------------------------------
/vscode-extension/.vscodeignore:
--------------------------------------------------------------------------------
1 | ..
2 | ../../
3 | vsc-extension-quickstart.md
4 | .vscode/**
5 | .vscode-test/**
6 | .vscode-test*
7 | .gitignore
8 | tsconfig.json
9 | src
10 | .eslintignore
11 | .eslint*
12 | .prettierignore
13 | *.vsix
14 | node_modules
--------------------------------------------------------------------------------
/apps/cli/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@repo/typescript-config/node-library.json",
3 | "include": [
4 | "**/*.d.ts",
5 | "**/*.ts",
6 | "../../shared/typescript-config/reset.d.ts"
7 | ],
8 | "exclude": ["node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/shared/eslint-plugin-node-imports/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@repo/eslint-plugin-node-imports",
3 | "version": "0.0.0",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "description": "Prevent importing .node.ts files from non-.node.ts files except for type imports"
7 | }
8 |
--------------------------------------------------------------------------------
/vscode-extension/src/modules/visualizer/stop-visualizer/command.ts:
--------------------------------------------------------------------------------
1 | import { closeDrizzleVisualizerPanel } from "../panel";
2 |
3 | export const StopVisualizerCommand = "drizzle.visualizer:stop";
4 |
5 | export function StopVisualizer() {
6 | closeDrizzleVisualizerPanel();
7 | }
8 |
--------------------------------------------------------------------------------
/apps/cli/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import("eslint").Linter.Config} */
2 | module.exports = {
3 | root: true,
4 | extends: ["@repo/eslint-config/base.js"],
5 | parserOptions: {
6 | project: true,
7 | },
8 | ignorePatterns: ["app/registry/*/presets", "**/*/_blank"],
9 | };
10 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/x.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/apps/cli/tailwind.config.ts:
--------------------------------------------------------------------------------
1 | import preset from "@repo/ui/config/tailwind";
2 | import type { Config } from "tailwindcss";
3 |
4 | const config = {
5 | content: ["./visualizer/**/*.{ts,tsx}", ...preset.content],
6 | presets: [preset],
7 | } satisfies Config;
8 |
9 | export default config;
10 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/skeleton.tsx:
--------------------------------------------------------------------------------
1 | import { cn } from "~/utils/cn";
2 |
3 | function Skeleton({ className, ...props }: React.HTMLAttributes) {
4 | return ;
5 | }
6 |
7 | export { Skeleton };
8 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846
3 | // for the documentation about the extensions.json format
4 | "recommendations": [
5 | "connor4312.esbuild-problem-matchers",
6 | "ms-vscode.extension-test-runner",
7 | "biomejs.biome"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.client/migrations/meta/_journal.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "6",
3 | "dialect": "postgresql",
4 | "entries": [
5 | {
6 | "idx": 0,
7 | "version": "6",
8 | "when": 1719674623916,
9 | "tag": "0000_init",
10 | "breakpoints": true
11 | }
12 | ]
13 | }
--------------------------------------------------------------------------------
/shared/ui/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import("eslint").Linter.Config} */
2 | module.exports = {
3 | root: true,
4 | extends: ["@repo/eslint-config/base.js"],
5 | parser: "@typescript-eslint/parser",
6 | parserOptions: {
7 | project: true,
8 | },
9 | ignorePatterns: ["tailwind.config.ts"],
10 | };
11 |
--------------------------------------------------------------------------------
/shared/ui/other/sly.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://sly-cli.fly.dev/registry/config.json",
3 | "libraries": [
4 | {
5 | "name": "lucide-icons",
6 | "directory": "./other/svg-icons",
7 | "postinstall": ["pnpm", "run", "build:icons"],
8 | "transformers": []
9 | }
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/core/schema.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the schema for the database.
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | * Do not forget to `export` your tables 😅
5 | */
6 |
7 | import { relations } from "drizzle-orm";
8 | import {} from "drizzle-orm/pg-core";
9 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/_blank/schema.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the schema for the database.
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | * Do not forget to `export` your tables 😅
5 | */
6 |
7 | import {} from "drizzle-orm";
8 | import {} from "drizzle-orm/pg-core";
9 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/core/schema.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the schema for the database.
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | * Do not forget to `export` your tables 😅
5 | */
6 |
7 | import { relations } from "drizzle-orm";
8 | import {} from "drizzle-orm/sqlite-core";
9 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/_blank/schema.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the schema for the database.
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | * Do not forget to `export` your tables 😅
5 | */
6 |
7 | import {} from "drizzle-orm";
8 | import {} from "drizzle-orm/sqlite-core";
9 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/utils/query-logger.ts:
--------------------------------------------------------------------------------
1 | import type { Query } from "drizzle-orm/sql";
2 |
3 | export type QueryLog = Query & {
4 | type: "query-log";
5 | };
6 |
7 | export function isQueryLog(data: unknown): data is QueryLog {
8 | return data != null && (data as QueryLog).type === "query-log";
9 | }
10 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/sly.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://sly-cli.fly.dev/registry/config.json",
3 | "libraries": [
4 | {
5 | "name": "lucide-icons",
6 | "directory": "./other/svg-icons",
7 | "postinstall": ["pnpm", "run", "build:icons"],
8 | "transformers": []
9 | }
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/vscode-extension/src/modules/studio/stop-studio/command.ts:
--------------------------------------------------------------------------------
1 | import { closeDrizzleStudioPanel } from "../panel";
2 | import { stopStudio } from "../server";
3 |
4 | export const StopStudioCommand = "drizzle.studio:stop";
5 |
6 | export function StopStudio() {
7 | stopStudio();
8 | closeDrizzleStudioPanel();
9 | }
10 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/rls/db.ts:
--------------------------------------------------------------------------------
1 | // Do not commit this file, it is replaced by the template db file
2 | // This file is only used to type-check the preset
3 |
4 | import * as schema from "./schema";
5 | import { Database } from "../../core/db";
6 |
7 | export const db = await Database(schema);
8 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/starter-01/db.ts:
--------------------------------------------------------------------------------
1 | // Do not commit this file, it is replaced by the template db file
2 | // This file is only used to type-check the preset
3 |
4 | import * as schema from "./schema";
5 | import { Database } from "../../core/db";
6 |
7 | export const db = await Database(schema);
8 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/starter-01/db.ts:
--------------------------------------------------------------------------------
1 | // Do not commit this file, it is replaced by the template db file
2 | // This file is only used to type-check the preset
3 |
4 | import * as schema from "./schema";
5 | import { Database } from "../../core/db";
6 |
7 | export const db = await Database(schema);
8 |
--------------------------------------------------------------------------------
/shared/typescript-config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@repo/typescript-config",
3 | "version": "0.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "publishConfig": {
7 | "access": "public"
8 | },
9 | "devDependencies": {
10 | "@total-typescript/ts-reset": "^0.5.1"
11 | },
12 | "prettier": {}
13 | }
14 |
--------------------------------------------------------------------------------
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json",
3 | "changelog": "@changesets/cli/changelog",
4 | "commit": true,
5 | "fixed": [],
6 | "linked": [],
7 | "access": "public",
8 | "baseBranch": "main",
9 | "updateInternalDependencies": "patch",
10 | "ignore": []
11 | }
12 |
--------------------------------------------------------------------------------
/shared/ui/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@repo/typescript-config/react-library.json",
3 | "compilerOptions": {
4 | "outDir": "dist",
5 | "types": ["vite/client", "node"],
6 | "jsx": "react-jsx",
7 | "noEmit": true
8 | },
9 | "include": ["**/*.ts", "**/*.tsx"],
10 | "exclude": ["node_modules", "dist"]
11 | }
12 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | .git
4 | .idea
5 | .turbo
6 | .cache
7 | .DS_Store
8 | .dockerignore
9 | .gitignore
10 | .prettierignore
11 | .prettierrc
12 | .*.*
13 | !.*.client.*
14 |
15 | build/
16 | dist/
17 | *.env*
18 | !*.env.example
19 | supabase
20 | **/fly.*
21 | *.vsix
22 | vscode-extension
23 | drizzle-lab.tgz
24 | !.changeset/
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/robot.ts:
--------------------------------------------------------------------------------
1 | export const robot = {
2 | public: [
3 | { name: "robots", content: "index,follow" },
4 | { name: "googlebot", content: "index,follow" },
5 | ],
6 | private: [
7 | { name: "robots", content: "noindex,nofollow" },
8 | { name: "googlebot", content: "noindex,nofollow" },
9 | ],
10 | };
11 |
--------------------------------------------------------------------------------
/packages/visualizer/src/components/theme.ts:
--------------------------------------------------------------------------------
1 | import { createContext, useContext } from "react";
2 |
3 | export type Theme = "dark" | "light";
4 |
5 | const ThemeContext = createContext("dark");
6 |
7 | export const ThemeProvider = ThemeContext.Provider;
8 |
9 | export function useTheme() {
10 | return useContext(ThemeContext);
11 | }
12 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/entry.client.tsx:
--------------------------------------------------------------------------------
1 | import { StrictMode, startTransition } from "react";
2 | import { hydrateRoot } from "react-dom/client";
3 | import { HydratedRouter } from "react-router/dom";
4 |
5 | startTransition(() => {
6 | hydrateRoot(
7 | document,
8 |
9 |
10 |
11 | );
12 | });
13 |
--------------------------------------------------------------------------------
/shared/typescript-config/react-library.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "React Library",
4 | "extends": "./base",
5 | "include": ["**/*.ts", "**/*.tsx"],
6 | "exclude": ["node_modules"],
7 | "compilerOptions": {
8 | "lib": ["DOM", "DOM.Iterable", "ES2022"],
9 | "jsx": "react-jsx"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/shared/ui/src/components/skeleton.tsx:
--------------------------------------------------------------------------------
1 | import { cn } from "../utils/cn";
2 |
3 | function Skeleton({
4 | className,
5 | ...props
6 | }: React.HTMLAttributes) {
7 | return (
8 |
12 | );
13 | }
14 |
15 | export { Skeleton };
16 |
--------------------------------------------------------------------------------
/packages/api/src/pg/utils.ts:
--------------------------------------------------------------------------------
1 | export const vectorOps = [
2 | "vector_l2_ops",
3 | "vector_ip_ops",
4 | "vector_cosine_ops",
5 | "vector_l1_ops",
6 | "bit_hamming_ops",
7 | "bit_jaccard_ops",
8 | "halfvec_l2_ops",
9 | "sparsevec_l2_ops",
10 | ];
11 |
12 | export function isPgArrayType(sqlType: string) {
13 | return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
14 | }
15 |
--------------------------------------------------------------------------------
/packages/visualizer/demo/main.tsx:
--------------------------------------------------------------------------------
1 | import { StrictMode } from "react";
2 | import { createRoot } from "react-dom/client";
3 | import App from "./app.tsx";
4 |
5 | const root = document.getElementById("root");
6 |
7 | if (!root) {
8 | throw new Error("Root element not found");
9 | }
10 |
11 | createRoot(root).render(
12 |
13 |
14 |
15 | );
16 |
--------------------------------------------------------------------------------
/packages/visualizer/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.client/migrations/0000_init.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS "playground" (
2 | "id" text PRIMARY KEY NOT NULL,
3 | "name" text NOT NULL,
4 | "description" text,
5 | "dialect" text NOT NULL,
6 | "content" jsonb NOT NULL,
7 | "creator_id" uuid,
8 | "created_at" timestamp(3) DEFAULT NOW() NOT NULL,
9 | "updated_at" timestamp(3) NOT NULL,
10 | "forked_from_id" text
11 | );
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files/schemas/users.ts:
--------------------------------------------------------------------------------
1 | import { explain } from "@drizzle-lab/api/extensions";
2 | import { pgTable, serial, text } from "drizzle-orm/pg-core";
3 |
4 | export const users = pgTable("users", {
5 | id: serial("id").primaryKey(),
6 | name: text("name"),
7 | });
8 |
9 | explain(users, {
10 | description: "My super Users table",
11 | columns: {
12 | id: "Auto incrementing ID",
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.client/schema.ts:
--------------------------------------------------------------------------------
1 | import { pgTable } from "drizzle-orm/pg-core";
2 |
3 | import { playgroundColumns } from "~/database/shared";
4 |
5 | /**
6 | * These schemas are used by PGLite in the browser (IndexedDB)
7 | */
8 |
9 | /* -- Drizzle Run -- */
10 | /* -- Playground -- */
11 |
12 | const playground = pgTable("playground", {
13 | ...playgroundColumns,
14 | });
15 |
16 | export { playground };
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/chevron-right.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/play.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files-barrel/schemas/users.ts:
--------------------------------------------------------------------------------
1 | import { explain } from "@drizzle-lab/api/extensions";
2 | import { pgTable, serial, text } from "drizzle-orm/pg-core";
3 |
4 | export const users = pgTable("users", {
5 | id: serial("id").primaryKey(),
6 | name: text("name"),
7 | });
8 |
9 | explain(users, {
10 | description: "My super Users table",
11 | columns: {
12 | id: "Auto incrementing ID",
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/chevron-right.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/play.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-packages/package-users/database/schema.ts:
--------------------------------------------------------------------------------
1 | import { explain } from "@drizzle-lab/api/extensions";
2 | import { pgTable, serial, text } from "drizzle-orm/pg-core";
3 |
4 | export const users = pgTable("users", {
5 | id: serial("id").primaryKey(),
6 | name: text("name"),
7 | });
8 |
9 | explain(users, {
10 | description: "My super Users table",
11 | columns: {
12 | id: "Auto incrementing ID",
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/starter-01/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Write your code here
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
6 | import { db } from "./db";
7 | import {} from "./schema";
8 |
9 | // 💡 This playground run a seed code in the Seed tab
10 |
11 | const result = await db.query.users.findMany({
12 | with: {
13 | posts: true,
14 | },
15 | });
16 |
17 | console.log(result);
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/starter-01/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Write your code here
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | */
5 |
6 | import { db } from "./db";
7 | import {} from "./schema";
8 |
9 | // 💡 This playground run a seed code in the Seed tab
10 |
11 | const result = await db.query.users.findMany({
12 | with: {
13 | posts: true,
14 | },
15 | });
16 |
17 | console.log(result);
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/cloud.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/cloud.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/chevrons-up-down.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/chevrons-up-down.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/components.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://ui.shadcn.com/schema.json",
3 | "style": "new-york",
4 | "rsc": false,
5 | "tsx": true,
6 | "tailwind": {
7 | "config": "tailwind.config.ts",
8 | "css": "css/base.css",
9 | "baseColor": "zinc",
10 | "cssVariables": true,
11 | "prefix": ""
12 | },
13 | "aliases": {
14 | "ui": "src/components",
15 | "components": "src/components",
16 | "utils": "src/utils/cn"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/user-round.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/drizzle.client.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the client-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./app/database/.client";
8 | const migrationsFolder = `${base}/migrations`;
9 |
10 | export default defineConfig({
11 | dialect: "postgresql",
12 | schema: `${base}/schema.ts`,
13 | out: migrationsFolder,
14 | verbose: false,
15 | });
16 |
17 | export { migrationsFolder };
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/code.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/panel-top.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/code.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/user-round.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/panel-top.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/info.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.server/migrations/meta/_journal.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "6",
3 | "dialect": "postgresql",
4 | "entries": [
5 | {
6 | "idx": 0,
7 | "version": "6",
8 | "when": 1719674631347,
9 | "tag": "0000_init",
10 | "breakpoints": true
11 | },
12 | {
13 | "idx": 1,
14 | "version": "7",
15 | "when": 1724449193516,
16 | "tag": "0001_unknown_unicorn",
17 | "breakpoints": true
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/core/seed.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any seeding code you want to use in the playground
3 | * It will be executed first before your playground code
4 | * 💡Tip: you can use the `$` global variable to access goodies
5 | */
6 |
7 | import { seed } from "drizzle-seed";
8 |
9 | import { db } from "./db";
10 | import * as schema from "./schema";
11 |
12 | // doc: https://orm.drizzle.team/docs/seed-overview
13 | await seed(db, schema);
14 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/core/seed.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any seeding code you want to use in the playground
3 | * It will be executed first before your playground code
4 | * 💡Tip: you can use the `$` global variable to access goodies
5 | */
6 |
7 | import { seed } from "drizzle-seed";
8 |
9 | import { db } from "./db";
10 | import * as schema from "./schema";
11 |
12 | // doc: https://orm.drizzle.team/docs/seed-overview
13 | await seed(db, schema);
14 |
--------------------------------------------------------------------------------
/apps/drizzle-run/drizzle.server.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./app/database/.server";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.DATABASE_URL_MIGRATE!,
13 | },
14 | schema: [`${base}/schema.ts`, `${base}/relations.ts`],
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | });
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/info.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/lock.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/routes/auth.sign-out/route.tsx:
--------------------------------------------------------------------------------
1 | import { type MetaFunction, redirect } from "react-router";
2 | import { robot } from "~/utils/robot";
3 | import type { Route } from "./+types/route";
4 |
5 | export const meta: MetaFunction = () => {
6 | return robot.private;
7 | };
8 |
9 | export function action({ context }: Route.ActionArgs) {
10 | context.destroyAuthSession();
11 |
12 | throw redirect("/");
13 | }
14 |
15 | export default function View() {
16 | return null;
17 | }
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/captions.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/captions.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/lock.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.client/migrations/export.json:
--------------------------------------------------------------------------------
1 | [{"sql":["CREATE TABLE IF NOT EXISTS \"playground\" (\n\t\"id\" text PRIMARY KEY NOT NULL,\n\t\"name\" text NOT NULL,\n\t\"description\" text,\n\t\"dialect\" text NOT NULL,\n\t\"content\" jsonb NOT NULL,\n\t\"creator_id\" uuid,\n\t\"created_at\" timestamp(3) DEFAULT NOW() NOT NULL,\n\t\"updated_at\" timestamp(3) NOT NULL,\n\t\"forked_from_id\" text\n);"],"bps":true,"folderMillis":1719674623916,"hash":"54675cacaaab25d18f193421b4102e6fa3d0bcf6a26d365831db457e0757c5f7"}]
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/ellipsis-vertical.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/arrow-right-left.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/circle-user-round.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/history.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/modules/playground/highlighter.ts:
--------------------------------------------------------------------------------
1 | import { createHighlighter } from "shiki/bundle/web";
2 | import tokyoNight from "shiki/themes/tokyo-night.mjs";
3 |
4 | export const highlighter = await createHighlighter({
5 | themes: [
6 | {
7 | ...tokyoNight,
8 | colors: {
9 | ...tokyoNight.colors,
10 | "editor.background": "transparent",
11 | "editorGutter.background": "#00000000",
12 | },
13 | },
14 | ],
15 | langs: ["typescript", "json", "sql"],
16 | });
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/ellipsis-vertical.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/history.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/database.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/diamond.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/settings-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/square-terminal.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/arrow-right-left.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/circle-user-round.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/database.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/square-terminal.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/book-text.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/book-text.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/diamond.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/settings-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/cloud-upload.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/external-link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/scripts/export-local-db-migrations.ts:
--------------------------------------------------------------------------------
1 | import fs from "node:fs/promises";
2 |
3 | import { readMigrationFiles } from "drizzle-orm/migrator";
4 |
5 | import { migrationsFolder } from "../../../drizzle.client.config";
6 |
7 | const file = "app/database/.client/migrations/export.json";
8 |
9 | await fs.writeFile(
10 | `${file}`,
11 | JSON.stringify(
12 | readMigrationFiles({
13 | migrationsFolder,
14 | }),
15 | null,
16 | 0,
17 | ),
18 | {
19 | flag: "w",
20 | },
21 | );
22 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/meta.schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-07/schema#",
3 | "id": "meta.schema.json",
4 | "description": "A schema for the meta.json file in a preset",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "type": "string",
9 | "description": "The name of the preset"
10 | },
11 | "description": {
12 | "type": "string",
13 | "description": "A description of the preset"
14 | }
15 | },
16 | "required": ["name", "description"]
17 | }
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/cloud-upload.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/external-link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/camera.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/log-out.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/share.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/.changeset/README.md:
--------------------------------------------------------------------------------
1 | # Changesets
2 |
3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4 | with multi-package repos, or single-package repos to help you version and publish your code. You can
5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6 |
7 | We have a quick list of common questions to get you started engaging with this project in
8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 |
--------------------------------------------------------------------------------
/apps/cli/example/sqlite/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/sqlite";
8 |
9 | export default defineConfig({
10 | dialect: "sqlite",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: `${base}/schema.ts`,
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | casing: "snake_case",
18 | migrations: {
19 | prefix: "timestamp",
20 | },
21 | });
22 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/camera.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/share.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/clipboard.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/eye.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/ghost.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/triangle-alert.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/ghost.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/log-out.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/packages/visualizer/components.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://ui.shadcn.com/schema.json",
3 | "style": "new-york",
4 | "rsc": false,
5 | "tsx": true,
6 | "tailwind": {
7 | "config": "",
8 | "css": "src/styles.css",
9 | "baseColor": "zinc",
10 | "cssVariables": true,
11 | "prefix": ""
12 | },
13 | "aliases": {
14 | "components": "~/components",
15 | "utils": "~/lib/utils",
16 | "ui": "~/components/ui",
17 | "lib": "~/lib",
18 | "hooks": "~/hooks"
19 | },
20 | "iconLibrary": "lucide"
21 | }
22 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/eraser.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/manifest.schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-07/schema#",
3 | "id": "meta.schema.json",
4 | "description": "A schema for the meta.json file in a preset",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "type": "string",
9 | "description": "The name of the preset"
10 | },
11 | "description": {
12 | "type": "string",
13 | "description": "A description of the preset"
14 | }
15 | },
16 | "required": ["name", "description"]
17 | }
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/clipboard.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/eye.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/triangle-alert.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - apps/drizzle-run
3 | - packages/*
4 | - vscode-extension
5 |
6 | catalog:
7 | "@tailwindcss/vite": ^4.1.12
8 | "@types/node": ^22.18.0
9 | "@types/react": ^19.1.12
10 | "@types/react-dom": ^19.1.9
11 | class-variance-authority: ^0.7.1
12 | clsx: ^2.1.1
13 | react: ^19.1.1
14 | react-dom: ^19.1.1
15 | tailwind-merge: ^3.3.1
16 | tailwindcss: ^4.1.12
17 | tailwindcss-animate: ^1.0.7
18 | tw-animate-css: ^1.3.7
19 | typescript: ^5.9.2
20 | vite: ^7.1.3
21 | vite-tsconfig-paths: ^5.1.4
22 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/types.ts:
--------------------------------------------------------------------------------
1 | import type * as clientSchema from "~/database/.client/schema";
2 | import type * as serverSchema from "~/database/.server/schema";
3 |
4 | /* -- Brands -- */
5 | export type UserId = Brand;
6 | export type PlaygroundId = Brand;
7 |
8 | /* -- Models -- */
9 | export type User = typeof serverSchema.user.$inferSelect;
10 | export type Playground = Omit<
11 | typeof serverSchema.playground.$inferSelect,
12 | "fts"
13 | > &
14 | typeof clientSchema.playground.$inferSelect;
15 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/eraser.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/file-pen-line.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/wrench.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/wrench.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/presets/starter-01/seed.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any seeding code you want to use in the playground
3 | * It will be executed first before your playground code
4 | * 💡Tip: you can use the `$` global variable to access goodies
5 | */
6 |
7 | import { seed } from "drizzle-seed";
8 |
9 | import { db } from "./db";
10 | import { posts, users } from "./schema";
11 |
12 | // doc: https://orm.drizzle.team/docs/seed-overview
13 | // @ts-ignore - temporary fix for drizzle-seed
14 | await seed(db, { posts, users });
15 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/file-pen-line.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/braces.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/shield.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/cli/example/mysql/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/mysql";
8 |
9 | export default defineConfig({
10 | dialect: "mysql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: `${base}/schema.ts`,
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | });
23 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/braces.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/shield.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/shared/typescript-config/remix.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "Remix",
4 | "extends": "./base",
5 | "include": [
6 | "**/*.ts",
7 | "**/*.tsx",
8 | "**/.server/**/*.ts",
9 | "**/.server/**/*.tsx",
10 | "**/.client/**/*.ts",
11 | "**/.client/**/*.tsx"
12 | ],
13 | "exclude": ["node_modules"],
14 | "compilerOptions": {
15 | "lib": ["DOM", "DOM.Iterable", "ES2022"],
16 | "jsx": "react-jsx",
17 | "types": ["@remix-run/node", "vite/client"],
18 | "noEmit": true
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.server/migrations/0001_unknown_unicorn.sql:
--------------------------------------------------------------------------------
1 | ALTER TABLE "playground" ADD COLUMN "fts" "tsvector" GENERATED ALWAYS AS (to_tsvector('english',coalesce("playground"."name", '') || ' ' || coalesce("playground"."description", ''))) STORED;--> statement-breakpoint
2 | CREATE INDEX IF NOT EXISTS "dialect_idx" ON "playground" USING btree ("dialect");--> statement-breakpoint
3 | CREATE INDEX IF NOT EXISTS "playground_search_index" ON "playground" USING gin ("fts");--> statement-breakpoint
4 | CREATE INDEX IF NOT EXISTS "username_idx" ON "user" USING btree ("username");
--------------------------------------------------------------------------------
/packages/visualizer/demo/app.tsx:
--------------------------------------------------------------------------------
1 | import { DrizzleVisualizer, DrizzleVisualizerLegend } from "../src";
2 | import * as schema from "./schema";
3 |
4 | import "../src/style.css";
5 |
6 | export default function App() {
7 | return (
8 |
16 |
17 |
18 |
19 | );
20 | }
21 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/shrink.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/shrink.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/clipboard-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/cloud-off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/cloud-off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/box.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/folder-open.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/clipboard-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/folder-open.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/packages/visualizer/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 | Vite + React + TS
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/book-image.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/git-fork.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/box.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/assert.ts:
--------------------------------------------------------------------------------
1 | import type { ErrorActorEvent, EventObject } from "xstate";
2 |
3 | function assertNonNull(
4 | value: T | null | undefined,
5 | ): asserts value is NonNullable {
6 | if (!value) {
7 | throw new Error("Value is null or undefined");
8 | }
9 | }
10 |
11 | function assertIsActorError(
12 | event: EventObject,
13 | ): asserts event is ErrorActorEvent {
14 | if (!event.type.startsWith("xstate.error.actor")) {
15 | throw new Error("Event is not an actor error");
16 | }
17 | }
18 |
19 | export { assertNonNull, assertIsActorError };
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/book-image.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/git-fork.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/badge-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/list-restart.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/list-restart.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/image-down.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/save.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/shield-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/badge-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/save.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/shield-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/image-down.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/typescript-config/base.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "Default",
4 | "compilerOptions": {
5 | "lib": ["ES2022"],
6 | "isolatedModules": true,
7 | "esModuleInterop": true,
8 | "module": "ESNext",
9 | "moduleResolution": "Bundler",
10 | "resolveJsonModule": true,
11 | "target": "ES2022",
12 | "strict": true,
13 | "allowJs": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "skipLibCheck": true,
16 | "noEmit": true
17 | },
18 | "includes": ["./reset.d.ts"],
19 | "exclude": ["node_modules"]
20 | }
21 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/captions-off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/starter-01/seed.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any seeding code you want to use in the playground
3 | * It will be executed first before your playground code
4 | * 💡Tip: you can use the `$` global variable to access goodies
5 | */
6 |
7 | import { drizzle } from "drizzle-orm/pglite";
8 | import { seed } from "drizzle-seed";
9 |
10 | import { db } from "./db";
11 | import { posts, users } from "./schema";
12 |
13 | // doc: https://orm.drizzle.team/docs/seed-overview
14 | // @ts-ignore - temporary fix for drizzle-seed
15 | await seed(db, { posts, users });
16 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/share-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/trash-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/captions-off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/share-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/trash-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/packages/api/src/mysql/index.ts:
--------------------------------------------------------------------------------
1 | export { importFromDatabase } from "./loader/database";
2 | export type { DrizzleObjects } from "./serializer/drizzle-objects";
3 | export { schemaToDrizzleObjects } from "./serializer/drizzle-objects";
4 | export {
5 | drizzleObjectsToSnapshot,
6 | schemaToSnapshot,
7 | } from "./serializer/snapshot";
8 | export {
9 | drizzleObjectsToSql,
10 | schemaToSql,
11 | schemaToSqlStatements,
12 | snapshotToSql,
13 | snapshotToSqlStatements,
14 | } from "./serializer/sql";
15 | export { snapshotToTypeScript } from "./serializer/typescript";
16 | export type { Snapshot } from "./schema";
17 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/loader-pinwheel.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/loader-pinwheel.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/sheet.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/sheet.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/key-round.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.server/db.ts:
--------------------------------------------------------------------------------
1 | import { drizzle } from "drizzle-orm/postgres-js";
2 | import postgres from "postgres";
3 |
4 | import { env } from "~/utils/env";
5 |
6 | import * as relations from "./relations";
7 | import * as schema from "./schema";
8 |
9 | const client = postgres(env.DATABASE_URL, { prepare: false, max: 10 });
10 |
11 | const db = drizzle({
12 | client,
13 | schema: {
14 | ...schema,
15 | ...relations,
16 | },
17 | casing: "snake_case",
18 | logger: env.NODE_ENV === "development",
19 | });
20 |
21 | const serverDb = Object.assign(db, {
22 | schema,
23 | });
24 |
25 | export { serverDb };
26 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/key-round.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/rls/seed.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Here you can write any seeding code you want to use in the playground
3 | * It will be executed first before your playground code
4 | * 💡Tip: you can use the `$` global variable to access goodies
5 | */
6 |
7 | import { sql } from "drizzle-orm";
8 |
9 | import { db } from "./db";
10 |
11 | await db.execute(sql`
12 | create or replace function auth.uid() returns uuid as $$
13 | select nullif(current_setting('request.jwt.claim.sub', true), '')::uuid;
14 | $$ language sql stable;
15 | `);
16 |
17 | await db.execute(sql`
18 | GRANT postgres TO authenticated;
19 | `);
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/presets.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from "vitest";
2 |
3 | import { type Dialect, getCoreFiles, getPresetFiles, getPresetsManifest } from ".";
4 |
5 | test("Registry presets are valid", async () => {
6 | const presetsManifest = getPresetsManifest();
7 | const dialects = Object.keys(presetsManifest) as Dialect[];
8 | const promises = [];
9 |
10 | for (const dialect of dialects) {
11 | promises.push(getCoreFiles(dialect));
12 |
13 | for (const preset of presetsManifest[dialect]) {
14 | promises.push(getPresetFiles(dialect, preset.id));
15 | }
16 | }
17 |
18 | await Promise.all(promises);
19 | });
20 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/view.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/view.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/box-plus.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/apps/cli/visualizer/entry.client.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * By default, Remix will handle hydrating your app on the client for you.
3 | * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
4 | * For more information, see https://remix.run/file-conventions/entry.client
5 | */
6 |
7 | import { startTransition, StrictMode } from "react";
8 |
9 | import { RemixBrowser } from "@remix-run/react";
10 | import { hydrateRoot } from "react-dom/client";
11 |
12 | startTransition(() => {
13 | hydrateRoot(
14 | document,
15 |
16 |
17 | ,
18 | );
19 | });
20 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/toolbar.tsx:
--------------------------------------------------------------------------------
1 | import { createPortal } from "react-dom";
2 | import { Separator } from "./ui/separator";
3 |
4 | const id = "toolbar";
5 |
6 | export function Toolbar({ children }: { children: React.ReactNode }) {
7 | const outlet = document.getElementById(id);
8 |
9 | if (!outlet) {
10 | return null;
11 | }
12 |
13 | return createPortal(
14 | <>
15 | {children}
16 |
17 | >,
18 | outlet
19 | );
20 | }
21 |
22 | export function ToolbarOutlet({ className }: { className?: string }) {
23 | return ;
24 | }
25 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/box-plus.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/sprout.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/sprout.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/cable.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/docs-template.yaml:
--------------------------------------------------------------------------------
1 | name: "Documentation Enhancement"
2 | description: Suggest documentation improvements
3 | title: "[DOCS]:"
4 | labels: ["docs"]
5 |
6 | body:
7 | - type: checkboxes
8 | id: verified
9 | attributes:
10 | label: Enhancement hasn't been filed before.
11 | options:
12 | - label: I have verified this enhancement I'm about to request hasn't been suggested before.
13 | required: true
14 |
15 | - type: textarea
16 | attributes:
17 | label: Describe the enhancement you want to request
18 | description: What do you want to change or add to the documentation?
19 | validations:
20 | required: true
21 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/database/.server/relations.ts:
--------------------------------------------------------------------------------
1 | import { relations } from "drizzle-orm";
2 |
3 | import { playground, user } from "./schema";
4 |
5 | /* -- User -- */
6 |
7 | const userRelations = relations(user, ({ many }) => ({
8 | playgrounds: many(playground),
9 | }));
10 |
11 | /* -- Playground -- */
12 |
13 | const playgroundRelations = relations(playground, ({ one }) => ({
14 | creator: one(user, {
15 | fields: [playground.creatorId],
16 | references: [user.id],
17 | }),
18 | forkedFrom: one(playground, {
19 | fields: [playground.forkedFromId],
20 | references: [playground.id],
21 | }),
22 | }));
23 |
24 | export { userRelations, playgroundRelations };
25 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/cable.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/github.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/github.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-template.yaml:
--------------------------------------------------------------------------------
1 | name: "Feature Request"
2 | description: Suggest new feature
3 | title: "[FEATURE]:"
4 | labels: ["enhancement"]
5 |
6 | body:
7 | - type: checkboxes
8 | id: verified
9 | attributes:
10 | label: Feature hasn't been suggested before.
11 | options:
12 | - label: I have verified this feature I'm about to request hasn't been suggested before.
13 | required: true
14 |
15 | - type: textarea
16 | attributes:
17 | label: Describe the enhancement you want to request
18 | description: What do you want to change or add? What are the benefits of implementing this?
19 | validations:
20 | required: true
21 |
--------------------------------------------------------------------------------
/packages/api/src/pg/index.ts:
--------------------------------------------------------------------------------
1 | export type { DrizzleObjects } from "./serializer/drizzle-objects";
2 | export { importFromDatabase } from "./loader/database";
3 | export { schemaToDrizzleObjects } from "./serializer/drizzle-objects";
4 | export {
5 | drizzleObjectsToSnapshot,
6 | schemaToSnapshot,
7 | } from "./serializer/snapshot";
8 | export { sqlToSnapshot } from "./serializer/sql-to-snapshot";
9 | export {
10 | drizzleObjectsToSql,
11 | schemaToSql,
12 | schemaToSqlStatements,
13 | snapshotToSql,
14 | snapshotToSqlStatements,
15 | } from "./serializer/sql";
16 | export { snapshotToTypeScript, sqlToTypescript } from "./serializer/typescript";
17 | export type { Snapshot } from "./schema";
18 |
--------------------------------------------------------------------------------
/apps/cli/example/pg/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/pg";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: `${base}/schema.ts`,
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | entities: {
23 | roles: {
24 | provider: "supabase",
25 | exclude: ["supabase_auth_admin"],
26 | },
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/packages/api/src/sqlite/index.ts:
--------------------------------------------------------------------------------
1 | export { importFromDatabase } from "./loader/database";
2 | export type { DrizzleObjects } from "./serializer/drizzle-objects";
3 | export { schemaToDrizzleObjects } from "./serializer/drizzle-objects";
4 | export {
5 | drizzleObjectsToSnapshot,
6 | schemaToSnapshot,
7 | } from "./serializer/snapshot";
8 | export { sqlToSnapshot } from "./serializer/sql-to-snapshot";
9 | export {
10 | drizzleObjectsToSql,
11 | schemaToSql,
12 | schemaToSqlStatements,
13 | snapshotToSql,
14 | snapshotToSqlStatements,
15 | } from "./serializer/sql";
16 | export { snapshotToTypeScript, sqlToTypescript } from "./serializer/typescript";
17 | export type { Snapshot } from "./schema";
18 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false, // set this to true to hide the "out" folder with the compiled JS files
5 | "dist": false // set this to true to hide the "dist" folder with the compiled JS files
6 | },
7 | "search.exclude": {
8 | "out": true, // set this to false to include "out" folder in search results
9 | "dist": true // set this to false to include "dist" folder in search results
10 | },
11 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
12 | "typescript.tsc.autoDetect": "off",
13 | "editor.defaultFormatter": "biomejs.biome"
14 | }
15 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/routes/healthcheck.tsx:
--------------------------------------------------------------------------------
1 | // learn more: https://fly.io/docs/reference/configuration/#services-http_checks
2 | import { sql } from "drizzle-orm";
3 |
4 | import { serverDb } from "~/database/.server/db";
5 | import { AppError } from "~/utils/error";
6 | import { failure, success } from "~/utils/http";
7 |
8 | export async function loader() {
9 | try {
10 | await serverDb.execute(sql`select count(*) from ${serverDb.schema.user}`);
11 | return success({ status: "ok" });
12 | } catch (cause) {
13 | return failure(
14 | new AppError({
15 | cause,
16 | message: "Healthcheck failed",
17 | label: "Healthcheck 🏥",
18 | })
19 | );
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/multi-files";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: `${base}/schemas`,
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | entities: {
23 | roles: {
24 | provider: "supabase",
25 | exclude: ["supabase_auth_admin"],
26 | },
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/shared/typescript-config/node-library.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "Node Library",
4 | "extends": "./base",
5 | "include": ["**/*.ts", "**/*.node.ts", "**/*.tsx"],
6 | "exclude": ["node_modules"],
7 | "compilerOptions": {
8 | "esModuleInterop": true,
9 | "skipLibCheck": true,
10 | "target": "ESNext",
11 | "allowJs": true,
12 | "resolveJsonModule": true,
13 | "moduleDetection": "force",
14 | "isolatedModules": true,
15 | "verbatimModuleSyntax": true,
16 |
17 | "strict": true,
18 | "noUncheckedIndexedAccess": false,
19 | "noImplicitOverride": true,
20 |
21 | "module": "ESNext",
22 | "noEmit": true
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files/schemas/relations.ts:
--------------------------------------------------------------------------------
1 | import { relations } from "drizzle-orm";
2 |
3 | import { posts } from "./posts";
4 | import { users } from "./users";
5 |
6 | export const usersRelations = relations(users, ({ many }) => ({
7 | author: many(posts, { relationName: "author" }),
8 | reviewer: many(posts, { relationName: "reviewer" }),
9 | }));
10 |
11 | export const postsRelations = relations(posts, ({ one }) => ({
12 | author: one(users, {
13 | fields: [posts.authorId],
14 | references: [users.id],
15 | relationName: "author",
16 | }),
17 | reviewer: one(users, {
18 | fields: [posts.reviewerId],
19 | references: [users.id],
20 | relationName: "reviewer",
21 | }),
22 | }));
23 |
--------------------------------------------------------------------------------
/apps/drizzle-run/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Drizzle Run
2 | APP_URL=http://localhost:3000
3 | DATABASE_URL=postgresql://postgres:postgres@localhost:54322/postgres
4 | DATABASE_URL_MIGRATE=postgresql://postgres:postgres@localhost:54322/postgres
5 | SENTRY_DSN=
6 | SESSION_SECRET=super-duper-s3cret
7 | SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
8 | SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
9 | SUPABASE_URL=http://127.0.0.1:54321
10 | TZ=UTC
11 | NODE_ENV=development
--------------------------------------------------------------------------------
/apps/cli/example/multi-files-barrel/schemas/relations.ts:
--------------------------------------------------------------------------------
1 | import { relations } from "drizzle-orm";
2 |
3 | import { posts } from "./posts";
4 | import { users } from "./users";
5 |
6 | export const usersRelations = relations(users, ({ many }) => ({
7 | author: many(posts, { relationName: "author" }),
8 | reviewer: many(posts, { relationName: "reviewer" }),
9 | }));
10 |
11 | export const postsRelations = relations(posts, ({ one }) => ({
12 | author: one(users, {
13 | fields: [posts.authorId],
14 | references: [users.id],
15 | relationName: "author",
16 | }),
17 | reviewer: one(users, {
18 | fields: [posts.reviewerId],
19 | references: [users.id],
20 | relationName: "reviewer",
21 | }),
22 | }));
23 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-files-barrel/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/multi-files-barrel";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: `${base}/schemas`,
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | entities: {
23 | roles: {
24 | provider: "supabase",
25 | exclude: ["supabase_auth_admin"],
26 | },
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/wand-sparkles.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
23 |
--------------------------------------------------------------------------------
/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://turborepo.com/schema.json",
3 | "tasks": {
4 | "build": {
5 | "dependsOn": ["^build"],
6 | "inputs": ["$TURBO_DEFAULT$", ".env*"],
7 | "outputs": ["dist/**", "build/**"]
8 | },
9 | "format": {
10 | "dependsOn": ["^format"]
11 | },
12 | "check": {
13 | "dependsOn": ["^check"]
14 | },
15 | "check:fix": {
16 | "dependsOn": ["^check:fix"]
17 | },
18 | "typecheck": {
19 | "dependsOn": ["^typecheck"]
20 | },
21 | "dev": {
22 | "with": ["dev:watch"],
23 | "persistent": true,
24 | "cache": false
25 | },
26 | "dev:watch": {
27 | "persistent": true,
28 | "cache": false
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/wand-sparkles.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
23 |
--------------------------------------------------------------------------------
/apps/cli/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/pg";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: `${base}/schema.ts`,
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | entities: {
23 | roles: {
24 | provider: "supabase",
25 | exclude: ["supabase_auth_admin"],
26 | },
27 | },
28 | // lab: {
29 | // projectId: "drizzle-lab-cli",
30 | // },
31 | });
32 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/bug-off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
24 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Fixes #
2 |
3 | # Description
4 |
5 | Please include a summary of the change and which issue is fixed, if any. Please also include relevant motivation and context.
6 | List any dependencies that are required for this change.
7 |
8 | ## Type of change
9 |
10 | Please mark relevant options with an `x` in the brackets.
11 |
12 | - [ ] Bug fix (non-breaking change which fixes an issue)
13 | - [ ] New feature (non-breaking change which adds functionality)
14 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
15 |
16 | # Reviewer checklist
17 |
18 | You have tested the changes and they are working as expected.
19 |
20 | # Screenshots (if appropriate):
21 |
22 | # Questions (if appropriate):
23 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-packages/drizzle.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/multi-packages";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: [`${base}/**/database/schema.ts`, `${base}/**/database/relations.ts`],
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | entities: {
23 | roles: {
24 | provider: "supabase",
25 | exclude: ["supabase_auth_admin"],
26 | },
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-packages/drizzle.config.dev.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the configuration for the server-side database.
3 | */
4 |
5 | import { defineConfig } from "drizzle-kit";
6 |
7 | const base = "./example/multi-packages";
8 |
9 | export default defineConfig({
10 | dialect: "postgresql",
11 | dbCredentials: {
12 | url: process.env.ADMIN_DATABASE_URL!,
13 | },
14 | schema: [`${base}/**/database/schema.ts`, `${base}/**/database/relations.ts`],
15 | out: `${base}/migrations`,
16 | verbose: false,
17 | schemaFilter: ["public"],
18 | casing: "snake_case",
19 | migrations: {
20 | prefix: "timestamp",
21 | },
22 | entities: {
23 | roles: {
24 | provider: "supabase",
25 | exclude: ["supabase_auth_admin"],
26 | },
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/bug-off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
24 |
--------------------------------------------------------------------------------
/apps/cli/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@repo/typescript-config/remix.json",
3 | "include": [
4 | "**/*.d.ts",
5 | "**/*.ts",
6 | "**/*.tsx",
7 | "**/.server/**/*.ts",
8 | "**/.server/**/*.tsx",
9 | "**/.client/**/*.ts",
10 | "**/.client/**/*.tsx",
11 | "../../shared/typescript-config/reset.d.ts"
12 | ],
13 | "exclude": ["node_modules"],
14 | "compilerOptions": {
15 | "allowImportingTsExtensions": true,
16 | "baseUrl": ".",
17 | "paths": {
18 | "@/*": ["./*"],
19 | "~/*": ["visualizer/*"],
20 | "@drizzle-lab/api/*/node": ["../../packages/api/src/*/index.node"],
21 | "@drizzle-lab/api/*": ["../../packages/api/src/*"],
22 | "@drizzle-lab/visualizer/*": ["../../packages/visualizer/src/*"]
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/nav-item.tsx:
--------------------------------------------------------------------------------
1 | import { Button } from "./ui/button";
2 | import { Icon, type IconName } from "./ui/icon";
3 | import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
4 |
5 | export function NavItem({
6 | tooltip,
7 | icon,
8 | onClick,
9 | }: {
10 | tooltip: string;
11 | icon: IconName;
12 | onClick?: () => void;
13 | }) {
14 | return (
15 |
16 |
17 |
20 |
21 |
22 | {tooltip}
23 |
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/apps/cli/example/multi-packages/package-relations/database/relations.ts:
--------------------------------------------------------------------------------
1 | import { relations } from "drizzle-orm";
2 |
3 | import { posts } from "../../package-posts/database/schema";
4 | import { users } from "../../package-users/database/schema";
5 |
6 | export const usersRelations = relations(users, ({ many }) => ({
7 | author: many(posts, { relationName: "author" }),
8 | reviewer: many(posts, { relationName: "reviewer" }),
9 | }));
10 |
11 | export const postsRelations = relations(posts, ({ one }) => ({
12 | author: one(users, {
13 | fields: [posts.authorId],
14 | references: [users.id],
15 | relationName: "author",
16 | }),
17 | reviewer: one(users, {
18 | fields: [posts.reviewerId],
19 | references: [users.id],
20 | relationName: "reviewer",
21 | }),
22 | }));
23 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/label.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as LabelPrimitive from "@radix-ui/react-label";
4 | import { type VariantProps, cva } from "class-variance-authority";
5 |
6 | import { cn } from "~/utils/cn";
7 |
8 | const labelVariants = cva("peer-disabled:opacity-70 font-medium text-sm leading-none peer-disabled:cursor-not-allowed");
9 |
10 | const Label = React.forwardRef<
11 | React.ElementRef,
12 | React.ComponentPropsWithoutRef & VariantProps
13 | >(({ className, ...props }, ref) => (
14 |
15 | ));
16 | Label.displayName = LabelPrimitive.Root.displayName;
17 |
18 | export { Label };
19 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that compiles the extension and then opens it inside a new window
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | {
6 | "version": "0.2.0",
7 | "configurations": [
8 | {
9 | "name": "Run Extension",
10 | "type": "extensionHost",
11 | "request": "launch",
12 | "args": [
13 | "--extensionDevelopmentPath=${workspaceFolder}/vscode-extension"
14 | ],
15 | "outFiles": ["${workspaceFolder}/vscode-extension/dist/**/*.js"],
16 | "preLaunchTask": "${defaultBuildTask}",
17 | "env": {
18 | "NODE_ENV": "development"
19 | }
20 | }
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/separator.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as SeparatorPrimitive from "@radix-ui/react-separator";
4 |
5 | import { cn } from "~/utils/cn";
6 |
7 | const Separator = React.forwardRef<
8 | React.ElementRef,
9 | React.ComponentPropsWithoutRef
10 | >(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
11 |
18 | ));
19 | Separator.displayName = SeparatorPrimitive.Root.displayName;
20 |
21 | export { Separator };
22 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/textarea.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import { cn } from "~/utils/cn";
4 |
5 | export interface TextareaProps extends React.TextareaHTMLAttributes {}
6 |
7 | const Textarea = React.forwardRef(({ className, ...props }, ref) => {
8 | return (
9 |
17 | );
18 | });
19 | Textarea.displayName = "Textarea";
20 |
21 | export { Textarea };
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 👋 Welcome to Drizzle Lab!
2 |
3 | 
4 |
5 |
6 | > [!NOTE]
7 | > Documentation is WIP
8 |
9 | ## As promised, here's a list of projects I am open-sourcing:
10 |
11 | - [Drizzle Run](./apps/drizzle-run)
12 | - [Try it out](https://drizzle.run)
13 | - [Drizzle Lab (CLI + Visualizer)](./apps/cli)
14 | - [Try it out](https://www.npmjs.com/package/drizzle-lab)
15 | - [Drizzle VSCode extension](./vscode-extension)
16 | - [Try it out](https://marketplace.visualstudio.com/items?itemName=rphlmr.vscode-drizzle-orm)
17 | - [Drizzle Lab API (Kit fork)](./packages/api)
18 | - [Try it out](https://www.npmjs.com/package/@drizzle-lab/api)
19 | - [Drizzle Lab Visualizer](./packages/visualizer)
20 |
21 |
22 | I will try to add more documentation to each project.
--------------------------------------------------------------------------------
/apps/drizzle-run/app/server/session.ts:
--------------------------------------------------------------------------------
1 | import { createCookieSessionStorage } from "react-router";
2 | import type { AuthSession } from "~/modules/auth/service.server";
3 | import { env } from "~/utils/env";
4 |
5 | export const authSessionKey = "auth";
6 | export const codeVerifierKey = "code-verifier";
7 |
8 | export type SessionData = {
9 | [authSessionKey]: AuthSession;
10 | [codeVerifierKey]: string | null;
11 | };
12 |
13 | export type FlashData = { errorMessage: string };
14 |
15 | /** Creates a session storage */
16 | export function createSessionStorage() {
17 | return createCookieSessionStorage({
18 | cookie: {
19 | name: "session",
20 | httpOnly: true,
21 | path: "/",
22 | sameSite: "lax",
23 | secrets: [env.SESSION_SECRET],
24 | secure: env.NODE_ENV === "production",
25 | },
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/use-is-mobile-app-layout.ts:
--------------------------------------------------------------------------------
1 | import { useSyncExternalStore } from "react";
2 |
3 | const breakingPoint = "(max-width: 768px)"; // lower than md
4 |
5 | function subscribe(callback: (event: MediaQueryListEvent) => void) {
6 | window.matchMedia(breakingPoint).addEventListener("change", callback);
7 |
8 | return () => {
9 | window.matchMedia(breakingPoint).removeEventListener("change", callback);
10 | };
11 | }
12 |
13 | /**
14 | * Check if the app should use the mobile app layout
15 | *
16 | * @returns true if the app is installed as a PWA
17 | */
18 | export function useIsMobileAppLayout() {
19 | return useSyncExternalStore(
20 | subscribe,
21 | () => window.matchMedia(breakingPoint).matches, // How to get the value on the client
22 | () => false, // How to get the value on the server
23 | );
24 | }
25 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/telescope.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
22 |
--------------------------------------------------------------------------------
/shared/ui/src/components/label.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as LabelPrimitive from "@radix-ui/react-label";
4 | import { cva, type VariantProps } from "class-variance-authority";
5 |
6 | import { cn } from "../utils/cn";
7 |
8 | const labelVariants = cva(
9 | "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
10 | );
11 |
12 | const Label = React.forwardRef<
13 | React.ElementRef,
14 | React.ComponentPropsWithoutRef &
15 | VariantProps
16 | >(({ className, ...props }, ref) => (
17 |
22 | ));
23 | Label.displayName = LabelPrimitive.Root.displayName;
24 |
25 | export { Label };
26 |
--------------------------------------------------------------------------------
/vscode-extension/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2022",
4 | "lib": ["ES2022", "DOM", "DOM.Iterable"],
5 | "module": "ESNext",
6 | "skipLibCheck": true,
7 | "moduleResolution": "bundler",
8 | "allowImportingTsExtensions": true,
9 | "isolatedModules": true,
10 | "esModuleInterop": true,
11 | "moduleDetection": "force",
12 | "verbatimModuleSyntax": true,
13 | "noEmit": true,
14 | "outDir": "dist",
15 | "jsx": "react-jsx",
16 | "sourceMap": true,
17 | "strict": true /* enable all strict type-checking options */,
18 | "resolveJsonModule": true,
19 |
20 | "baseUrl": ".",
21 | "paths": {
22 | "@drizzle-lab/visualizer": ["../packages/visualizer/dist"]
23 | }
24 | },
25 | "include": ["./src", "build.ts"],
26 | "exclude": ["node_modules", "dist"]
27 | }
28 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/telescope.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
22 |
--------------------------------------------------------------------------------
/vscode-extension/src/modules/studio/panel.ts:
--------------------------------------------------------------------------------
1 | import type { WebviewPanel } from "vscode";
2 |
3 | import { createPanel, render } from "../../utils";
4 |
5 | /* Local state */
6 | let $panel: WebviewPanel | undefined;
7 |
8 | export function createDrizzleStudioPanel() {
9 | if ($panel) {
10 | return $panel;
11 | }
12 |
13 | $panel = createPanel({
14 | id: "DrizzleStudio",
15 | title: "Drizzle Studio",
16 | onDispose: () => {
17 | $panel = undefined;
18 | },
19 | });
20 |
21 | $panel.webview.html = render(`
22 |
23 | Starting Drizzle Studio...
24 |
25 | `);
26 |
27 | return $panel;
28 | }
29 |
30 | export function closeDrizzleStudioPanel() {
31 | $panel?.dispose();
32 | }
33 |
--------------------------------------------------------------------------------
/apps/drizzle-run/types/global.d.ts:
--------------------------------------------------------------------------------
1 | import type { href } from "react-router";
2 |
3 | interface RouteComponentProps {
4 | matches: Array<{ id: string; data: unknown } | undefined>;
5 | }
6 |
7 | declare global {
8 | type Prettify = {
9 | [K in keyof T]: T[K];
10 | } & {};
11 |
12 | type RoutePath = Parameters[0];
13 |
14 | /**
15 | * Helper type to extract matching route IDs from a Route type.
16 | * Usage: RouteIdMatch
17 | */
18 | type RouteIdMatch = Extract<
19 | NonNullable,
20 | { id: string } & { data: {} }
21 | >["id"];
22 |
23 | type DeepPartial = {
24 | [P in keyof T]?: T[P] extends object ? DeepPartial : T[P];
25 | };
26 |
27 | type PartialValues = {
28 | [P in keyof T]: DeepPartial;
29 | };
30 | }
31 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/bug-play.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
24 |
--------------------------------------------------------------------------------
/shared/ui/src/components/textarea.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import { cn } from "../utils/cn";
4 |
5 | export interface TextareaProps
6 | extends React.TextareaHTMLAttributes {}
7 |
8 | const Textarea = React.forwardRef(
9 | ({ className, ...props }, ref) => {
10 | return (
11 |
19 | );
20 | },
21 | );
22 | Textarea.displayName = "Textarea";
23 |
24 | export { Textarea };
25 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/bug-play.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
24 |
--------------------------------------------------------------------------------
/shared/ui/other/svg-icons/bug.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
--------------------------------------------------------------------------------
/apps/drizzle-run/other/svg-icons/bug.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
--------------------------------------------------------------------------------
/packages/api/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "Node Library",
4 | "include": ["**/*.ts", "**/*.node.ts", "**/*.tsx"],
5 | "exclude": ["node_modules", "dist"],
6 | "compilerOptions": {
7 | "lib": ["ES2022"],
8 | "moduleResolution": "Bundler",
9 | "forceConsistentCasingInFileNames": true,
10 | "esModuleInterop": true,
11 | "noImplicitAny": false,
12 | "allowImportingTsExtensions": true,
13 | "skipLibCheck": true,
14 | "target": "ESNext",
15 | "allowJs": true,
16 | "resolveJsonModule": true,
17 | "moduleDetection": "force",
18 | "isolatedModules": true,
19 | "verbatimModuleSyntax": true,
20 |
21 | "strict": true,
22 | "noUncheckedIndexedAccess": false,
23 | "noImplicitOverride": true,
24 |
25 | "module": "ESNext",
26 | "noEmit": true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/vscode-extension/src/modules/visualizer/panel.ts:
--------------------------------------------------------------------------------
1 | import type { WebviewPanel } from "vscode";
2 |
3 | import { createPanel, render } from "../../utils";
4 |
5 | /* Local state */
6 | let $panel: WebviewPanel | undefined;
7 |
8 | export function createDrizzleVisualizerPanel() {
9 | if ($panel) {
10 | return $panel;
11 | }
12 |
13 | $panel = createPanel({
14 | id: "DrizzleVisualizer",
15 | title: "Drizzle Visualizer",
16 | onDispose: () => {
17 | $panel = undefined;
18 | },
19 | });
20 |
21 | $panel.webview.html = render(`
22 |
23 | Starting Drizzle Visualizer...
24 |
25 | `);
26 |
27 | return $panel;
28 | }
29 |
30 | export function closeDrizzleVisualizerPanel() {
31 | $panel?.dispose();
32 | }
33 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/input.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import { cn } from "~/utils/cn";
4 |
5 | export interface InputProps extends React.InputHTMLAttributes {}
6 |
7 | const Input = React.forwardRef(({ className, type, ...props }, ref) => {
8 | return (
9 |
18 | );
19 | });
20 | Input.displayName = "Input";
21 |
22 | export { Input };
23 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/use-form.ts:
--------------------------------------------------------------------------------
1 | import { useForm as useFormBase } from "@conform-to/react";
2 | import { parseWithZod } from "@conform-to/zod";
3 | import type { ZodTypeAny, z } from "zod/v3";
4 |
5 | import type { LoaderOrActionResponse } from "~/utils/http";
6 |
7 | type FormOption = Omit<
8 | Parameters>>[number],
9 | "lastResult"
10 | > & {
11 | schema: Schema;
12 | lastResult: LoaderOrActionResponse | undefined;
13 | };
14 |
15 | export function useForm({ schema, lastResult, ...options }: FormOption) {
16 | return useFormBase({
17 | lastResult: lastResult?.failure?.additionalData?.submissionResult,
18 | onValidate({ formData }) {
19 | return parseWithZod(formData, { schema });
20 | },
21 | shouldValidate: "onBlur",
22 | ...options,
23 | });
24 | }
25 |
--------------------------------------------------------------------------------
/shared/eslint-config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@repo/eslint-config",
3 | "version": "0.0.0",
4 | "private": true,
5 | "files": [
6 | "base.js"
7 | ],
8 | "dependencies": {
9 | "@remix-run/eslint-config": "^2.10.3",
10 | "@repo/eslint-plugin-node-imports": "../eslint-plugin-node-imports",
11 | "@typescript-eslint/eslint-plugin": "^7.17.0",
12 | "@typescript-eslint/parser": "^7.17.0",
13 | "@typescript-eslint/utils": "^7.17.0",
14 | "eslint": "^8.57.0",
15 | "eslint-config-prettier": "^9.1.0",
16 | "eslint-plugin-drizzle": "^0.2.3",
17 | "eslint-plugin-import": "^2.29.1",
18 | "eslint-plugin-jsx-a11y": "^6.9.0",
19 | "eslint-plugin-n": "^17.12.0",
20 | "eslint-plugin-react": "^7.35.0",
21 | "eslint-plugin-react-hooks": "^4.6.2",
22 | "eslint-plugin-tailwindcss": "^3.17.4",
23 | "typescript": "^5.3.3"
24 | },
25 | "prettier": {}
26 | }
27 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/utils/use-dialog.ts:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export type Closable = {
4 | close: (cb?: Function | unknown) => void;
5 | };
6 |
7 | export type Openable = {
8 | open: () => void;
9 | };
10 |
11 | export function useDialog() {
12 | const [type, setType] = React.useState(null);
13 | const [isOpen, setIsOpen] = React.useState(false);
14 |
15 | const open = React.useCallback((actionType: DialogType) => {
16 | setType(actionType);
17 | setIsOpen(true);
18 | }, []);
19 |
20 | const close = React.useCallback((cb) => {
21 | if (cb && typeof cb === "function") {
22 | cb();
23 | }
24 | setType(null);
25 | setIsOpen(false);
26 | }, []);
27 |
28 | const toggle = React.useCallback(() => {
29 | setIsOpen((open) => !open);
30 | }, []);
31 |
32 | return { isOpen, open, close, toggle, type };
33 | }
34 |
--------------------------------------------------------------------------------
/vscode-extension/src/modules/visualizer/open-visualizer/codelens.ts:
--------------------------------------------------------------------------------
1 | import * as vscode from "vscode";
2 |
3 | import { findDrizzleConfigLines } from "../../../utils";
4 | import { SelectEnvCommand } from "../../internal/select-env.command";
5 | import { OpenVisualizerCommand } from "./command";
6 |
7 | export class OpenVisualizerCodeLens implements vscode.CodeLensProvider {
8 | provideCodeLenses(document: vscode.TextDocument): vscode.CodeLens[] {
9 | return findDrizzleConfigLines(document.getText()).map(({ index }) => {
10 | const range = new vscode.Range(new vscode.Position(index, 0), new vscode.Position(index, 0));
11 |
12 | return new vscode.CodeLens(range, {
13 | title: "🌧️ Open Drizzle Visualizer",
14 | command: SelectEnvCommand,
15 | tooltip: "Open Drizzle Schema Visualizer",
16 | arguments: [document.uri.fsPath, OpenVisualizerCommand],
17 | });
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/shared/ui/src/components/input.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import { cn } from "../utils/cn";
4 |
5 | export interface InputProps
6 | extends React.InputHTMLAttributes {}
7 |
8 | const Input = React.forwardRef(
9 | ({ className, type, ...props }, ref) => {
10 | return (
11 |
20 | );
21 | },
22 | );
23 | Input.displayName = "Input";
24 |
25 | export { Input };
26 |
--------------------------------------------------------------------------------
/apps/drizzle-run/fly.toml:
--------------------------------------------------------------------------------
1 | # fly.toml app configuration file generated for drizzle-run on 2024-06-29T17:47:20+02:00
2 | #
3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4 | #
5 |
6 | app = 'drizzle-run'
7 | primary_region = 'cdg'
8 | swap_size_mb = 512
9 |
10 | [deploy]
11 | strategy = "bluegreen"
12 |
13 | [env]
14 | NODE_ENV = "production"
15 | PORT = "3000"
16 |
17 | [build]
18 |
19 | [http_service]
20 | internal_port = 3000
21 | force_https = true
22 | auto_stop_machines = true
23 | auto_start_machines = true
24 | min_machines_running = 1
25 | processes = ['app']
26 |
27 | [http_service.concurrency]
28 | type = "requests"
29 | soft_limit = 125
30 | hard_limit = 150
31 |
32 | [[http_service.checks]]
33 | grace_period = "10s"
34 | interval = "30s"
35 | method = "GET"
36 | timeout = "5s"
37 | path = "/healthcheck"
38 |
39 | [[vm]]
40 | memory = '1024mb'
41 | cpu_kind = 'shared'
42 | cpus = 1
43 |
--------------------------------------------------------------------------------
/packages/api/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import fs from "node:fs/promises";
2 | import { defineConfig, type Options } from "tsup";
3 |
4 | await fs.rm("dist", { recursive: true }).catch(() => {});
5 |
6 | const options: Options = {
7 | entry: [
8 | "src/config/index.node.ts",
9 | "src/extensions/index.ts",
10 | "src/pg/index.ts",
11 | "src/pg/index.node.ts",
12 | "src/pg/index.web.ts",
13 | "src/sqlite/index.ts",
14 | "src/sqlite/index.node.ts",
15 | "src/sqlite/index.web.ts",
16 | "src/mysql/index.ts",
17 | "src/mysql/index.node.ts",
18 | "src/mysql/index.web.ts",
19 | "src/relations/index.ts",
20 | "src/sql/index.ts",
21 | ],
22 | outDir: "dist",
23 | dts: true,
24 | sourcemap: false,
25 | minify: false,
26 | };
27 |
28 | export default defineConfig([
29 | {
30 | ...options,
31 | format: "esm",
32 | },
33 | {
34 | ...options,
35 | format: "cjs",
36 | shims: true,
37 | },
38 | ]);
39 |
--------------------------------------------------------------------------------
/shared/ui/src/components/separator.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as SeparatorPrimitive from "@radix-ui/react-separator";
4 |
5 | import { cn } from "../utils/cn";
6 |
7 | const Separator = React.forwardRef<
8 | React.ElementRef,
9 | React.ComponentPropsWithoutRef
10 | >(
11 | (
12 | { className, orientation = "horizontal", decorative = true, ...props },
13 | ref,
14 | ) => (
15 |
28 | ),
29 | );
30 | Separator.displayName = SeparatorPrimitive.Root.displayName;
31 |
32 | export { Separator };
33 |
--------------------------------------------------------------------------------
/packages/api/src/config/env.node.ts:
--------------------------------------------------------------------------------
1 | export const DRIZZLE_LAB_ENV_KEY = {
2 | DEBUG: "DRIZZLE_LAB_DEBUG",
3 | CWD: "DRIZZLE_LAB_CWD",
4 | CONFIG_PATH: "DRIZZLE_LAB_CONFIG_PATH",
5 | SAVE_DIR: "DRIZZLE_LAB_SAVE_DIR",
6 | PROJECT_ID: "DRIZZLE_LAB_PROJECT_ID",
7 | TS_CONFIG_PATH: "TS_CONFIG_PATH",
8 | ENV_FILE_PATH: "DRIZZLE_LAB_ENV_FILE_PATH",
9 | } as const;
10 |
11 | export function getEnv() {
12 | return {
13 | DRIZZLE_LAB_DEBUG: process.env[DRIZZLE_LAB_ENV_KEY.DEBUG] === "true",
14 | DRIZZLE_LAB_CWD: process.env[DRIZZLE_LAB_ENV_KEY.CWD]
15 | ? `${process.env[DRIZZLE_LAB_ENV_KEY.CWD]}/`
16 | : "",
17 | DRIZZLE_LAB_CONFIG_PATH: process.env[DRIZZLE_LAB_ENV_KEY.CONFIG_PATH],
18 | DRIZZLE_LAB_PROJECT_ID: process.env[DRIZZLE_LAB_ENV_KEY.PROJECT_ID],
19 | DRIZZLE_LAB_TS_CONFIG_PATH:
20 | process.env[DRIZZLE_LAB_ENV_KEY.TS_CONFIG_PATH] || "./tsconfig.json",
21 | DRIZZLE_LAB_ENV_FILE_PATH: process.env[DRIZZLE_LAB_ENV_KEY.ENV_FILE_PATH],
22 | };
23 | }
24 |
--------------------------------------------------------------------------------
/packages/visualizer/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2022",
4 | "lib": ["ES2022", "DOM", "DOM.Iterable"],
5 | "types": ["vite/client"],
6 | "module": "ESNext",
7 | "skipLibCheck": true,
8 | "noImplicitAny": false,
9 |
10 | "moduleResolution": "bundler",
11 | "resolveJsonModule": true,
12 | "allowImportingTsExtensions": true,
13 | "isolatedModules": true,
14 | "esModuleInterop": true,
15 | "moduleDetection": "force",
16 | "noEmit": true,
17 | "jsx": "react-jsx",
18 |
19 | "strict": true,
20 | "noUnusedLocals": true,
21 | "noUnusedParameters": true,
22 | "noFallthroughCasesInSwitch": true,
23 | "noUncheckedSideEffectImports": true,
24 | "verbatimModuleSyntax": true,
25 |
26 | "baseUrl": ".",
27 | "paths": {
28 | "~/*": ["./src/*"],
29 | "@drizzle-lab/api/*/web": ["../api/src/*/index.web"]
30 | }
31 | },
32 | "include": ["demo", "src"],
33 | "exclude": ["node_modules"]
34 | }
35 |
--------------------------------------------------------------------------------
/shared/ui/src/components/sonner.tsx:
--------------------------------------------------------------------------------
1 | import { useTheme } from "next-themes";
2 | import { Toaster as Sonner } from "sonner";
3 |
4 | type ToasterProps = React.ComponentProps;
5 |
6 | const Toaster = ({ ...props }: ToasterProps) => {
7 | const { theme = "system" } = useTheme();
8 |
9 | return (
10 |
26 | );
27 | };
28 |
29 | export { Toaster };
30 |
--------------------------------------------------------------------------------
/packages/visualizer/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { dirname, resolve } from "node:path";
2 | import { fileURLToPath } from "node:url";
3 | import tailwindcss from "@tailwindcss/vite";
4 | import react from "@vitejs/plugin-react";
5 | import { defineConfig } from "vite";
6 | import dts from "vite-plugin-dts";
7 | import tsconfigPaths from "vite-tsconfig-paths";
8 |
9 | const __dirname = dirname(fileURLToPath(import.meta.url));
10 |
11 | export default defineConfig({
12 | plugins: [
13 | react(),
14 | tailwindcss(),
15 | dts({
16 | rollupTypes: true,
17 | }),
18 | tsconfigPaths(),
19 | ],
20 | build: {
21 | lib: {
22 | entry: resolve(__dirname, "src/index.ts"),
23 | fileName: "index",
24 | formats: ["es"],
25 | cssFileName: "style",
26 | },
27 | copyPublicDir: false,
28 | minify: false,
29 | rollupOptions: {
30 | // make sure to externalize deps that shouldn't be bundled
31 | external: ["react", "react/jsx-runtime", "drizzle-orm"],
32 | },
33 | },
34 | });
35 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/sonner.tsx:
--------------------------------------------------------------------------------
1 | import { useTheme } from "next-themes";
2 | import { Toaster as Sonner } from "sonner";
3 |
4 | type ToasterProps = React.ComponentProps;
5 |
6 | const Toaster = ({ ...props }: ToasterProps) => {
7 | const { theme = "system" } = useTheme();
8 |
9 | return (
10 |
26 | );
27 | };
28 |
29 | export { Toaster };
30 |
--------------------------------------------------------------------------------
/packages/visualizer/src/components/ui/separator.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 |
3 | import type * as React from "react";
4 |
5 | import * as SeparatorPrimitive from "@radix-ui/react-separator";
6 |
7 | import { cn } from "~/lib/utils";
8 | import { useTheme } from "../theme";
9 |
10 | function Separator({
11 | className,
12 | orientation = "horizontal",
13 | decorative = true,
14 | ...props
15 | }: React.ComponentProps) {
16 | const theme = useTheme();
17 | return (
18 |
30 | );
31 | }
32 |
33 | export { Separator };
34 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/server/index.ts:
--------------------------------------------------------------------------------
1 | import { createHonoServer } from "react-router-hono-server/node";
2 | import { session } from "remix-hono/session";
3 |
4 | import { getLoadContext } from "./context";
5 | import { refreshSession } from "./middleware";
6 | import { createSessionStorage } from "./session";
7 |
8 | export default createHonoServer({
9 | getLoadContext,
10 | configure(server) {
11 | server.use(
12 | session({
13 | autoCommit: true,
14 | createSessionStorage() {
15 | const sessionStorage = createSessionStorage();
16 |
17 | return {
18 | ...sessionStorage,
19 | // If a user doesn't come back to the app within 30 days, their session will be deleted.
20 | commitSession(session) {
21 | return sessionStorage.commitSession(session, {
22 | maxAge: 60 * 60 * 24 * 365, // 1 year
23 | });
24 | },
25 | };
26 | },
27 | })
28 | );
29 |
30 | server.use(refreshSession());
31 | },
32 | });
33 |
--------------------------------------------------------------------------------
/packages/api/src/sql/utils.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Split SQL statements from a SQL dump
3 | * @param sqlDump - SQL dump
4 | * @returns SQL statements
5 | */
6 | export function splitSqlStatements(sqlDump: string): string[] {
7 | const statements: string[] = [];
8 | let currentStatement = "";
9 | let inBlock = false;
10 |
11 | for (const line of sqlDump.split("\n")) {
12 | currentStatement += line + "\n";
13 |
14 | if (line.trim().startsWith("DO $$")) {
15 | inBlock = true;
16 | }
17 |
18 | if (inBlock && line.trim() === "END $$;") {
19 | inBlock = false;
20 | statements.push(currentStatement.trim());
21 | currentStatement = "";
22 | } else if (!inBlock && line.trim().endsWith(";")) {
23 | statements.push(currentStatement.trim());
24 | currentStatement = "";
25 | }
26 | }
27 |
28 | if (currentStatement.trim()) {
29 | statements.push(currentStatement.trim());
30 | }
31 |
32 | return statements;
33 | }
34 |
35 | export function escapeSingleQuotes(str: string) {
36 | return str.replace(/'/g, "''");
37 | }
38 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/anonymous-cta.tsx:
--------------------------------------------------------------------------------
1 | import { Link, useLocation } from "react-router";
2 |
3 | import { DrizzleLogo } from "~/components/logo";
4 | import { path, QUERY_KEY } from "~/utils/http";
5 | import { Typography } from "./ui/typography";
6 | import { buttonVariants } from "./ui/button";
7 | import { Icon } from "./ui/icon";
8 |
9 | export function AnonymousCTA() {
10 | const location = useLocation();
11 |
12 | return (
13 |
14 |
15 |
16 |
17 | Run
18 |
19 |
20 |
26 |
27 | Sign in with GitHub
28 |
29 |
30 |
31 | );
32 | }
33 |
--------------------------------------------------------------------------------
/packages/api/src/sqlite/serializer/sql-to-snapshot.ts:
--------------------------------------------------------------------------------
1 | import { splitSqlStatements } from "../../sql/utils";
2 | import { importFromDatabase } from "../loader/database";
3 |
4 | // fork: drizzle-kit/src/serializer/sqliteSerializer.ts
5 |
6 | /**
7 | * Convert the schema SQL dump to a Drizzle snapshot
8 | *
9 | * **It requires `@libsql/client-wasm` to be installed**
10 | *
11 | * @param sqlDump - SQL dump
12 | * @returns Drizzle snapshot
13 | */
14 | export async function sqlToSnapshot(sqlDump: string) {
15 | const { createClient } = await import("@libsql/client-wasm").catch(() => {
16 | throw new Error("Please install @libsql/client-wasm to use this feature");
17 | });
18 |
19 | const client = createClient({ url: ":memory:" });
20 |
21 | const statements = splitSqlStatements(sqlDump);
22 | for (const statement of statements) {
23 | await client.execute(statement);
24 | }
25 |
26 | return importFromDatabase({
27 | query: async (sql, args = []) => {
28 | const res = await client.execute({ sql, args });
29 | return res.rows as any;
30 | },
31 | });
32 | }
33 |
--------------------------------------------------------------------------------
/packages/api/src/internal/relations.ts:
--------------------------------------------------------------------------------
1 | import { is } from "drizzle-orm";
2 | import {
3 | createTableRelationsHelpers,
4 | extractTablesRelationalConfig,
5 | Relations as DrizzleRelation,
6 | } from "drizzle-orm/relations";
7 | import { object, enum as enumType, string, type TypeOf } from "zod";
8 |
9 | import type { DrizzleSchema } from "./global";
10 |
11 | export type TableRelationConfig = ReturnType<
12 | typeof extractTablesRelationsConfig
13 | >[number];
14 |
15 | export function extractTablesRelationsConfig(schema: DrizzleSchema) {
16 | return Object.values(
17 | extractTablesRelationalConfig(schema, createTableRelationsHelpers).tables,
18 | );
19 | }
20 |
21 | export type { DrizzleRelation };
22 |
23 | export function isRelation(value: unknown) {
24 | return is(value, DrizzleRelation);
25 | }
26 |
27 | /* lab extension */
28 | export const relation = object({
29 | type: enumType(["many", "one"]),
30 | fieldName: string(),
31 | relationName: string(),
32 | referencedTableName: string(),
33 | }).strict();
34 |
35 | /* lab extension */
36 | export type Relation = TypeOf;
37 |
--------------------------------------------------------------------------------
/vscode-extension/src/modules/studio/open-studio/codelens.ts:
--------------------------------------------------------------------------------
1 | import * as vscode from "vscode";
2 |
3 | import { findDrizzleConfigLines } from "../../../utils";
4 | import { SelectEnvCommand } from "../../internal/select-env.command";
5 | import { findDrizzleKitPath } from "../server";
6 | import { OpenStudioCommand } from "./command";
7 |
8 | export class OpenStudioCodeLens implements vscode.CodeLensProvider {
9 | provideCodeLenses(document: vscode.TextDocument): vscode.CodeLens[] {
10 | const drizzleKitPath = findDrizzleKitPath(document.uri.fsPath);
11 |
12 | if (!drizzleKitPath) {
13 | return [];
14 | }
15 |
16 | return findDrizzleConfigLines(document.getText(), { requireDb: true }).map(({ index }) => {
17 | const range = new vscode.Range(new vscode.Position(index, 0), new vscode.Position(index, 0));
18 |
19 | return new vscode.CodeLens(range, {
20 | title: "🌧️ Open Drizzle Studio",
21 | command: SelectEnvCommand,
22 | tooltip: "Open Drizzle Studio",
23 | arguments: [document.uri.fsPath, OpenStudioCommand],
24 | });
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/visualizer/README.md:
--------------------------------------------------------------------------------
1 | # @drizzle-lab/visualizer
2 |
3 | Visualizer for Drizzle Kit.
4 |
5 | ## Installation
6 |
7 | ```bash
8 | npm install @drizzle-lab/visualizer@latest
9 | ```
10 |
11 | ## Usage
12 |
13 | > [!IMPORTANT]
14 | > Do not forget to import the CSS file.
15 | >
16 | > ```tsx
17 | > import "@drizzle-lab/visualizer/dist/style.css";
18 | > ```
19 |
20 | ```tsx
21 | "use client";
22 |
23 | import {
24 | DrizzleVisualizer,
25 | DrizzleVisualizerLegend,
26 | } from "@drizzle-lab/visualizer";
27 |
28 | import "@drizzle-lab/visualizer/dist/style.css";
29 |
30 | import * as schema from "../database/schema";
31 |
32 | export function Visualizer() {
33 | return (
34 |
35 |
36 |
37 |
38 | );
39 | }
40 | ```
41 |
42 | ### Theme
43 |
44 | The Drizzle Visualizer supports two themes: `dark` and `light`. You can specify the theme using the `theme` prop.
45 |
46 | ```tsx
47 |
48 | ```
--------------------------------------------------------------------------------
/apps/cli/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 rphlmr
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vscode-extension/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 rphlmr
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/sqlite/core/db.ts:
--------------------------------------------------------------------------------
1 | import { schemaToSqlStatements } from "@drizzle-lab/api/sqlite";
2 | import { createClient } from "@libsql/client-wasm";
3 | import { sql } from "drizzle-orm";
4 | import { drizzle } from "drizzle-orm/libsql";
5 | import type { Logger } from "drizzle-orm/logger";
6 |
7 | import type { QueryLog } from "~/registry/utils/query-logger";
8 |
9 | import * as $schema from "./schema";
10 |
11 | class QueryLogger implements Logger {
12 | logQuery(sql: string, params: unknown[]): void {
13 | console.log({
14 | type: "query-log",
15 | sql,
16 | params,
17 | } satisfies QueryLog);
18 | }
19 | }
20 |
21 | export async function Database = Record>(schema: TSchema) {
22 | const client = createClient({ url: ":memory:" });
23 | const db = drizzle({ client, schema, casing: "snake_case", logger: new QueryLogger() });
24 |
25 | for (const statement of schemaToSqlStatements(schema, { casing: "snake_case" })) {
26 | await db.run(sql.raw(statement));
27 | }
28 | return db;
29 | }
30 |
31 | export const db = await Database($schema);
32 |
--------------------------------------------------------------------------------
/packages/api/src/internal/style.ts:
--------------------------------------------------------------------------------
1 | const colors = {
2 | red: (str: string) => `\x1b[31m${str}\x1b[0m`,
3 | white: (str: string) => `\x1b[37m${str}\x1b[0m`,
4 | gray: (str: string) => `\x1b[90m${str}\x1b[0m`,
5 | black: (str: string) => `\x1b[30m${str}\x1b[0m`,
6 | yellow: (str: string) => `\x1b[33m${str}\x1b[0m`,
7 | bold: (str: string) => `\x1b[1m${str}\x1b[0m`,
8 | };
9 |
10 | const bg = {
11 | red: (str: string) => `\x1b[41m${str}\x1b[0m`,
12 | gray: (str: string) => `\x1b[100m${str}\x1b[0m`,
13 | yellow: (str: string) => `\x1b[43m${str}\x1b[0m`,
14 | };
15 |
16 | export const withStyle = {
17 | error: (str: string) =>
18 | `${colors.red(`${bg.red(colors.white(" Invalid input "))} ${str}`)}`,
19 | warning: (str: string) => `${bg.gray(colors.white(" Warning "))} ${str}`,
20 | errorWarning: (str: string) =>
21 | `${colors.red(`${bg.red(colors.white(" Warning "))} ${str}`)}`,
22 | fullWarning: (str: string) =>
23 | `${bg.yellow(colors.black(" Warning "))} ${colors.bold(str)}`,
24 | suggestion: (str: string) =>
25 | `${bg.gray(colors.white(" Suggestion "))} ${str}`,
26 | info: (str: string) => `${colors.gray(str)}`,
27 | };
28 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/checkbox.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4 | import { CheckIcon } from "@radix-ui/react-icons";
5 |
6 | import { cn } from "~/utils/cn";
7 |
8 | const Checkbox = React.forwardRef<
9 | React.ElementRef,
10 | React.ComponentPropsWithoutRef
11 | >(({ className, ...props }, ref) => (
12 |
20 |
21 |
22 |
23 |
24 | ));
25 | Checkbox.displayName = CheckboxPrimitive.Root.displayName;
26 |
27 | export { Checkbox };
28 |
--------------------------------------------------------------------------------
/shared/ui/src/components/checkbox.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4 | import { CheckIcon } from "@radix-ui/react-icons";
5 |
6 | import { cn } from "../utils/cn";
7 |
8 | const Checkbox = React.forwardRef<
9 | React.ElementRef,
10 | React.ComponentPropsWithoutRef
11 | >(({ className, ...props }, ref) => (
12 |
20 |
23 |
24 |
25 |
26 | ));
27 | Checkbox.displayName = CheckboxPrimitive.Root.displayName;
28 |
29 | export { Checkbox };
30 |
--------------------------------------------------------------------------------
/apps/drizzle-run/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "**/*.d.ts",
4 | "**/*.ts",
5 | "**/*.tsx",
6 | "**/.server/**/*.ts",
7 | "**/.server/**/*.tsx",
8 | "**/.client/**/*.ts",
9 | "**/.client/**/*.tsx",
10 | ".react-router/types/**/*"
11 | ],
12 | "exclude": ["node_modules"],
13 | "compilerOptions": {
14 | "lib": ["DOM", "DOM.Iterable", "ES2022"],
15 | "types": ["node", "vite/client"],
16 | "target": "ES2022",
17 | "module": "ES2022",
18 | "moduleResolution": "bundler",
19 | "jsx": "react-jsx",
20 | "rootDirs": [".", "./.react-router/types"],
21 | "esModuleInterop": true,
22 | "forceConsistentCasingInFileNames": true,
23 | "verbatimModuleSyntax": true,
24 | "noEmit": true,
25 | "resolveJsonModule": true,
26 | "skipLibCheck": true,
27 | "strict": true,
28 | "strictNullChecks": true,
29 | "noUncheckedIndexedAccess": true,
30 | "baseUrl": ".",
31 | "paths": {
32 | "~/*": ["./app/*"],
33 | "registry/*": ["./registry/*"],
34 | "@drizzle-lab/api/*/node": ["../../packages/api/src/*/index.node"],
35 | "@drizzle-lab/api/*": ["../../packages/api/src/*"]
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/presets/starter-01/schema.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the schema for the database.
3 | * 💡Tip: you can use the `$` global variable to access goodies
4 | * Do not forget to `export` your tables 😅
5 | */
6 |
7 | import { relations } from "drizzle-orm";
8 | import { type AnyPgColumn, integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
9 |
10 | export const users = pgTable("users", {
11 | id: integer().primaryKey().generatedByDefaultAsIdentity(),
12 | name: text().notNull(),
13 | createdAt: timestamp({ precision: 3 }).notNull().defaultNow(),
14 | });
15 |
16 | export const usersRelations = relations(users, ({ many }) => ({
17 | posts: many(posts),
18 | }));
19 |
20 | export const posts = pgTable("posts", {
21 | id: integer().primaryKey().generatedByDefaultAsIdentity(),
22 | content: text().notNull(),
23 | authorId: integer()
24 | .notNull()
25 | .references((): AnyPgColumn => users.id),
26 | createdAt: timestamp({ precision: 3 }).notNull().defaultNow(),
27 | });
28 |
29 | export const postsRelations = relations(posts, ({ one }) => ({
30 | author: one(users, { fields: [posts.authorId], references: [users.id] }),
31 | }));
32 |
--------------------------------------------------------------------------------
/vscode-extension/src/views/index.tsx:
--------------------------------------------------------------------------------
1 | import { DrizzleVisualizer } from "@drizzle-lab/visualizer";
2 | import "@drizzle-lab/visualizer/style.css";
3 | import React from "react";
4 | import { createRoot } from "react-dom/client";
5 |
6 | declare global {
7 | interface Window {
8 | vscode: any;
9 | initialData: {
10 | snapshot: any;
11 | };
12 | }
13 | }
14 |
15 | function App() {
16 | const [data, setData] = React.useState(window.initialData);
17 |
18 | React.useEffect(() => {
19 | const handleMessage = (event: MessageEvent) => {
20 | const message = event.data;
21 | if (message.type === "reload") {
22 | setData((prev) => ({
23 | ...prev,
24 | snapshot: message.snapshot,
25 | }));
26 | }
27 | };
28 |
29 | window.addEventListener("message", handleMessage);
30 | return () => window.removeEventListener("message", handleMessage);
31 | }, []);
32 |
33 | return ;
34 | }
35 |
36 | const container = document.getElementById("root");
37 |
38 | if (!container) {
39 | throw new Error("Failed to find the root container");
40 | }
41 |
42 | const root = createRoot(container);
43 | root.render();
44 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/registry/dialects/postgresql/core/db.ts:
--------------------------------------------------------------------------------
1 | import { schemaToSqlStatements } from "@drizzle-lab/api/pg";
2 | import { PGlite } from "@electric-sql/pglite";
3 | import { vector } from "@electric-sql/pglite/vector";
4 | import { sql } from "drizzle-orm";
5 | import type { Logger } from "drizzle-orm/logger";
6 | import { drizzle } from "drizzle-orm/pglite";
7 |
8 | import type { QueryLog } from "~/registry/utils/query-logger";
9 |
10 | import * as $schema from "./schema";
11 |
12 | class QueryLogger implements Logger {
13 | logQuery(sql: string, params: unknown[]): void {
14 | console.log({
15 | type: "query-log",
16 | sql,
17 | params,
18 | } satisfies QueryLog);
19 | }
20 | }
21 |
22 | export async function Database = Record>(schema: TSchema) {
23 | const client = await PGlite.create({ extensions: { vector } });
24 | const db = drizzle({ client, schema, casing: "snake_case", logger: new QueryLogger() });
25 |
26 | for (const statement of schemaToSqlStatements(schema, { casing: "snake_case" })) {
27 | await db.execute(sql.raw(statement));
28 | }
29 |
30 | return db;
31 | }
32 |
33 | export const db = await Database($schema);
34 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/badge.tsx:
--------------------------------------------------------------------------------
1 | import type * as React from "react";
2 |
3 | import { type VariantProps, cva } from "class-variance-authority";
4 |
5 | import { cn } from "~/utils/cn";
6 |
7 | const badgeVariants = cva(
8 | "inline-flex items-center px-2.5 py-0.5 border rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 font-semibold text-xs transition-colors",
9 | {
10 | variants: {
11 | variant: {
12 | default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
13 | secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
14 | destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
15 | outline: "text-foreground",
16 | },
17 | },
18 | defaultVariants: {
19 | variant: "default",
20 | },
21 | }
22 | );
23 |
24 | export interface BadgeProps extends React.HTMLAttributes, VariantProps {}
25 |
26 | function Badge({ className, variant, ...props }: BadgeProps) {
27 | return ;
28 | }
29 |
30 | export { Badge, badgeVariants };
31 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/server/middleware.ts:
--------------------------------------------------------------------------------
1 | import { createMiddleware } from "hono/factory";
2 | import { getSession } from "remix-hono/session";
3 |
4 | import { refreshAccessToken } from "~/modules/auth/service.server";
5 |
6 | import { authSessionKey, type FlashData, type SessionData } from "./session";
7 |
8 | function isExpiringSoon(expiresAt: number | undefined) {
9 | if (!expiresAt) {
10 | return true;
11 | }
12 |
13 | return (expiresAt - 60 * 0.1) * 1000 < Date.now(); // 1 minute left before token expires
14 | }
15 |
16 | /**
17 | * Refresh access token middleware
18 | *
19 | */
20 | export function refreshSession() {
21 | return createMiddleware(async (c, next) => {
22 | const session = getSession(c);
23 | const auth = session.get(authSessionKey);
24 |
25 | if (!auth || !isExpiringSoon(auth.expiresAt)) {
26 | return next();
27 | }
28 |
29 | try {
30 | session.set(authSessionKey, await refreshAccessToken(auth.refreshToken));
31 | } catch (cause) {
32 | session.flash(
33 | "errorMessage",
34 | "You have been logged out. Please log in again.",
35 | );
36 |
37 | session.unset(authSessionKey);
38 | }
39 |
40 | return next();
41 | });
42 | }
43 |
--------------------------------------------------------------------------------
/apps/drizzle-run/app/components/ui/tooltip.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as TooltipPrimitive from "@radix-ui/react-tooltip";
4 |
5 | import { cn } from "~/utils/cn";
6 |
7 | const TooltipProvider = TooltipPrimitive.Provider;
8 |
9 | const Tooltip = TooltipPrimitive.Root;
10 |
11 | const TooltipTrigger = TooltipPrimitive.Trigger;
12 |
13 | const TooltipContent = React.forwardRef<
14 | React.ElementRef,
15 | React.ComponentPropsWithoutRef
16 | >(({ className, sideOffset = 4, ...props }, ref) => (
17 |
26 | ));
27 | TooltipContent.displayName = TooltipPrimitive.Content.displayName;
28 |
29 | export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
30 |
--------------------------------------------------------------------------------
/shared/ui/src/components/switch.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as SwitchPrimitives from "@radix-ui/react-switch";
4 |
5 | import { cn } from "../utils/cn";
6 |
7 | const Switch = React.forwardRef<
8 | React.ElementRef,
9 | React.ComponentPropsWithoutRef
10 | >(({ className, ...props }, ref) => (
11 |
19 |
24 |
25 | ));
26 | Switch.displayName = SwitchPrimitives.Root.displayName;
27 |
28 | export { Switch };
29 |
--------------------------------------------------------------------------------