├── .eslintignore ├── .eslintrc.yaml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-template.yaml │ ├── config.yml │ ├── docs-template.yaml │ └── feature-template.yaml └── workflows │ ├── codeql.yml │ ├── release-feature-branch.yaml │ ├── release-latest.yaml │ └── unpublish-release-feature-branch.yaml ├── .gitignore ├── .markdownlint.yaml ├── .npmrc ├── .nvmrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── changelogs ├── README.md ├── drizzle-arktype │ ├── 0.1.2.md │ └── 0.1.3.md ├── drizzle-kit │ ├── 0.23.2.md │ ├── 0.24.0.md │ ├── 0.24.1.md │ ├── 0.24.2.md │ ├── 0.25.0.md │ ├── 0.26.0.md │ ├── 0.26.1.md │ ├── 0.26.2.md │ ├── 0.27.0.md │ ├── 0.27.1.md │ ├── 0.27.2.md │ ├── 0.28.0.md │ ├── 0.28.1.md │ ├── 0.29.0.md │ ├── 0.29.1.md │ ├── 0.30.0.md │ ├── 0.30.1.md │ ├── 0.30.2.md │ ├── 0.30.3.md │ ├── 0.30.4.md │ ├── 0.30.5.md │ ├── 0.30.6.md │ ├── 0.31.0.md │ └── 0.31.1.md ├── drizzle-orm-mysql │ ├── 0.14.1.md │ ├── 0.14.2.md │ ├── 0.14.3.md │ ├── 0.15.0.md │ ├── 0.15.1.md │ ├── 0.15.2.md │ ├── 0.15.3.md │ ├── 0.16.0.md │ ├── 0.16.1.md │ └── 0.16.2.md ├── drizzle-orm-pg │ ├── 0.12.0-beta.40.md │ ├── 0.13.0.md │ ├── 0.13.1.md │ ├── 0.13.2.md │ ├── 0.13.3.md │ ├── 0.13.4.md │ ├── 0.14.0.md │ ├── 0.14.1.md │ ├── 0.14.2.md │ ├── 0.14.3.md │ ├── 0.14.4.md │ ├── 0.15.0.md │ ├── 0.15.1.md │ ├── 0.15.2.md │ ├── 0.15.3.md │ ├── 0.16.0.md │ ├── 0.16.1.md │ ├── 0.16.2.md │ └── 0.16.3.md ├── drizzle-orm-sqlite │ ├── 0.12.0-beta.17.md │ ├── 0.12.0-beta.18.md │ ├── 0.12.0-beta.19.md │ ├── 0.12.0-beta.20.md │ ├── 0.12.0-beta.21.md │ ├── 0.13.0.md │ ├── 0.14.1.md │ ├── 0.14.2.md │ ├── 0.14.3.md │ ├── 0.14.4.md │ ├── 0.14.5.md │ ├── 0.15.0.md │ ├── 0.15.2.md │ ├── 0.15.3.md │ ├── 0.15.4.md │ ├── 0.16.0.md │ └── 0.16.1.md ├── drizzle-orm │ ├── 0.12.0-beta.23.md │ ├── 0.12.0-beta.24.md │ ├── 0.13.0.md │ ├── 0.13.1.md │ ├── 0.14.1.md │ ├── 0.14.2.md │ ├── 0.15.0.md │ ├── 0.15.1.md │ ├── 0.15.2.md │ ├── 0.15.3.md │ ├── 0.16.0.md │ ├── 0.16.1.md │ ├── 0.17.0.md │ ├── 0.17.1.md │ ├── 0.17.2.md │ ├── 0.17.3.md │ ├── 0.17.4.md │ ├── 0.17.5.md │ ├── 0.17.6.md │ ├── 0.17.7.md │ ├── 0.18.0.md │ ├── 0.19.0.md │ ├── 0.19.1.md │ ├── 0.20.0.md │ ├── 0.20.1.md │ ├── 0.20.2.md │ ├── 0.20.3.md │ ├── 0.21.0.md │ ├── 0.21.1.md │ ├── 0.22.0.md │ ├── 0.23.0.md │ ├── 0.23.1.md │ ├── 0.23.10.md │ ├── 0.23.11.md │ ├── 0.23.12.md │ ├── 0.23.13.md │ ├── 0.23.2.md │ ├── 0.23.3.md │ ├── 0.23.4.md │ ├── 0.23.5.md │ ├── 0.23.6.md │ ├── 0.23.7.md │ ├── 0.23.8.md │ ├── 0.23.9.md │ ├── 0.24.0.md │ ├── 0.24.1.md │ ├── 0.24.2.md │ ├── 0.24.3.md │ ├── 0.24.4.md │ ├── 0.24.5.md │ ├── 0.25.0.md │ ├── 0.25.1.md │ ├── 0.25.2.md │ ├── 0.25.3.md │ ├── 0.25.4.md │ ├── 0.26.0.md │ ├── 0.26.1.md │ ├── 0.26.2.md │ ├── 0.26.3.md │ ├── 0.26.4.md │ ├── 0.26.5.md │ ├── 0.27.0.md │ ├── 0.27.1.md │ ├── 0.27.2.md │ ├── 0.28.0.md │ ├── 0.28.1.md │ ├── 0.28.2.md │ ├── 0.28.3.md │ ├── 0.28.4.md │ ├── 0.28.5.md │ ├── 0.28.6.md │ ├── 0.29.0.md │ ├── 0.29.1.md │ ├── 0.29.2.md │ ├── 0.29.3.md │ ├── 0.29.4.md │ ├── 0.29.5.md │ ├── 0.30.0.md │ ├── 0.30.1.md │ ├── 0.30.10.md │ ├── 0.30.2.md │ ├── 0.30.3.md │ ├── 0.30.4.md │ ├── 0.30.5.md │ ├── 0.30.6.md │ ├── 0.30.7-preview.md │ ├── 0.30.7.md │ ├── 0.30.8.md │ ├── 0.30.9.md │ ├── 0.31.0-beta.md │ ├── 0.31.0.md │ ├── 0.31.1.md │ ├── 0.31.2.md │ ├── 0.31.3.md │ ├── 0.31.4.md │ ├── 0.32.0-beta.md │ ├── 0.32.0.md │ ├── 0.32.1.md │ ├── 0.32.2.md │ ├── 0.33.0.md │ ├── 0.34.0.md │ ├── 0.34.1.md │ ├── 0.35.0.md │ ├── 0.35.1.md │ ├── 0.35.2.md │ ├── 0.35.3.md │ ├── 0.36.0.md │ ├── 0.36.1.md │ ├── 0.36.2.md │ ├── 0.36.3.md │ ├── 0.36.4.md │ ├── 0.37.0.md │ ├── 0.38.0.md │ ├── 0.38.1.md │ ├── 0.38.2.md │ ├── 0.38.3.md │ ├── 0.38.4.md │ ├── 0.39.0.md │ ├── 0.39.1.md │ ├── 0.39.2.md │ ├── 0.39.3.md │ ├── 0.40.0.md │ ├── 0.40.1.md │ ├── 0.41.0.md │ ├── 0.42.0.md │ ├── 0.43.0.md │ ├── 0.43.1.md │ ├── 0.44.0.md │ └── 0.44.1.md ├── drizzle-seed │ ├── 0.1.1.md │ ├── 0.1.2.md │ ├── 0.1.3.md │ ├── 0.2.1.md │ ├── 0.3.0.md │ └── 0.3.1.md ├── drizzle-typebox │ ├── 0.1.0.md │ ├── 0.1.1.md │ ├── 0.2.0.md │ ├── 0.2.1.md │ ├── 0.3.0.md │ ├── 0.3.1.md │ ├── 0.3.2.md │ └── 0.3.3.md ├── drizzle-valibot │ ├── 0.1.0.md │ ├── 0.1.1.md │ ├── 0.2.0.md │ ├── 0.3.0.md │ ├── 0.3.1.md │ ├── 0.4.0.md │ ├── 0.4.1.md │ └── 0.4.2.md ├── drizzle-zod │ ├── 0.1.0.md │ ├── 0.1.1.md │ ├── 0.1.2.md │ ├── 0.1.3.md │ ├── 0.1.4.md │ ├── 0.2.0.md │ ├── 0.2.1.md │ ├── 0.3.0.md │ ├── 0.3.1.md │ ├── 0.3.2.md │ ├── 0.4.0.md │ ├── 0.4.1.md │ ├── 0.4.2.md │ ├── 0.4.3.md │ ├── 0.4.4.md │ ├── 0.5.0.md │ ├── 0.5.1.md │ ├── 0.6.0.md │ ├── 0.6.1.md │ ├── 0.7.0.md │ ├── 0.7.1.md │ ├── 0.8.0.md │ ├── 0.8.1.md │ └── 0.8.2.md ├── eslint-plugin-drizzle │ ├── 0.2.0.md │ ├── 0.2.1.md │ ├── 0.2.2.md │ └── 0.2.3.md └── media │ ├── drop.gif │ ├── introspect_mysql.gif │ └── up_mysql.gif ├── docs ├── custom-types.lite.md ├── custom-types.md ├── joins.md └── table-introspect-api.md ├── dprint.json ├── drizzle-arktype ├── README.md ├── benchmarks │ └── types.ts ├── package.json ├── rollup.config.ts ├── scripts │ ├── build.ts │ └── fix-imports.ts ├── src │ ├── column.ts │ ├── column.types.ts │ ├── constants.ts │ ├── index.ts │ ├── schema.ts │ ├── schema.types.internal.ts │ ├── schema.types.ts │ └── utils.ts ├── tests │ ├── mysql.test.ts │ ├── pg.test.ts │ ├── singlestore.test.ts │ ├── sqlite.test.ts │ ├── tsconfig.json │ └── utils.ts ├── tsconfig.build.json ├── tsconfig.json └── vitest.config.ts ├── drizzle-kit ├── .gitignore ├── README.md ├── build.dev.ts ├── build.ts ├── imports-checker │ ├── analyze.ts │ ├── checker.ts │ ├── grammar │ │ ├── grammar.ohm │ │ ├── grammar.ohm-bundle.d.ts │ │ └── grammar.ohm-bundle.js │ └── index.ts ├── package.json ├── patches │ └── difflib@0.2.4.patch ├── src │ ├── @types │ │ └── utils.ts │ ├── api.ts │ ├── cli │ │ ├── commands │ │ │ ├── _es5.ts │ │ │ ├── check.ts │ │ │ ├── drop.ts │ │ │ ├── introspect.ts │ │ │ ├── libSqlPushUtils.ts │ │ │ ├── migrate.ts │ │ │ ├── mysqlIntrospect.ts │ │ │ ├── mysqlPushUtils.ts │ │ │ ├── mysqlUp.ts │ │ │ ├── pgIntrospect.ts │ │ │ ├── pgPushUtils.ts │ │ │ ├── pgUp.ts │ │ │ ├── push.ts │ │ │ ├── singlestoreIntrospect.ts │ │ │ ├── singlestorePushUtils.ts │ │ │ ├── singlestoreUp.ts │ │ │ ├── sqliteIntrospect.ts │ │ │ ├── sqlitePushUtils.ts │ │ │ ├── sqliteUp.ts │ │ │ └── utils.ts │ │ ├── connections.ts │ │ ├── index.ts │ │ ├── schema.ts │ │ ├── selector-ui.ts │ │ ├── utils.ts │ │ ├── validations │ │ │ ├── cli.ts │ │ │ ├── common.ts │ │ │ ├── gel.ts │ │ │ ├── libsql.ts │ │ │ ├── mysql.ts │ │ │ ├── outputs.ts │ │ │ ├── postgres.ts │ │ │ ├── singlestore.ts │ │ │ ├── sqlite.ts │ │ │ └── studio.ts │ │ └── views.ts │ ├── extensions │ │ ├── getTablesFilterByExtensions.ts │ │ └── vector.ts │ ├── global.ts │ ├── index.ts │ ├── introspect-gel.ts │ ├── introspect-mysql.ts │ ├── introspect-pg.ts │ ├── introspect-singlestore.ts │ ├── introspect-sqlite.ts │ ├── jsonDiffer.js │ ├── jsonStatements.ts │ ├── loader.mjs │ ├── migrationPreparator.ts │ ├── schemaValidator.ts │ ├── serializer │ │ ├── gelSchema.ts │ │ ├── gelSerializer.ts │ │ ├── index.ts │ │ ├── mysqlImports.ts │ │ ├── mysqlSchema.ts │ │ ├── mysqlSerializer.ts │ │ ├── pgImports.ts │ │ ├── pgSchema.ts │ │ ├── pgSerializer.ts │ │ ├── singlestoreImports.ts │ │ ├── singlestoreSchema.ts │ │ ├── singlestoreSerializer.ts │ │ ├── sqliteImports.ts │ │ ├── sqliteSchema.ts │ │ ├── sqliteSerializer.ts │ │ ├── studio.ts │ │ └── utils.ts │ ├── simulator.ts │ ├── snapshotsDiffer.ts │ ├── sqlgenerator.ts │ ├── statementCombiner.ts │ ├── utils.ts │ └── utils │ │ ├── certs.ts │ │ └── words.ts ├── tests │ ├── bin.test.ts │ ├── cli-export.test.ts │ ├── cli-generate.test.ts │ ├── cli-migrate.test.ts │ ├── cli-push.test.ts │ ├── cli │ │ ├── d1http.config.ts │ │ ├── drizzle.config.ts │ │ ├── durable-sqlite.config.ts │ │ ├── expo.config.ts │ │ ├── postgres.config.ts │ │ ├── postgres2.config.ts │ │ ├── schema.ts │ │ └── turso.config.ts │ ├── common.ts │ ├── indexes │ │ ├── common.ts │ │ └── pg.test.ts │ ├── introspect │ │ ├── gel.ext.test.ts │ │ ├── gel.test.ts │ │ ├── libsql.test.ts │ │ ├── mysql.test.ts │ │ ├── pg.test.ts │ │ ├── singlestore.test.ts │ │ └── sqlite.test.ts │ ├── libsql-checks.test.ts │ ├── libsql-statements.test.ts │ ├── libsql-views.test.ts │ ├── migrate │ │ ├── libsq-schema.ts │ │ ├── libsql-migrate.test.ts │ │ └── migrations │ │ │ ├── 0000_little_blizzard.sql │ │ │ ├── 0001_nebulous_storm.sql │ │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ ├── 0001_snapshot.json │ │ │ └── _journal.json │ ├── mysql-checks.test.ts │ ├── mysql-generated.test.ts │ ├── mysql-schemas.test.ts │ ├── mysql-views.test.ts │ ├── mysql.test.ts │ ├── pg-array.test.ts │ ├── pg-checks.test.ts │ ├── pg-columns.test.ts │ ├── pg-enums.test.ts │ ├── pg-generated.test.ts │ ├── pg-identity.test.ts │ ├── pg-schemas.test.ts │ ├── pg-sequences.test.ts │ ├── pg-tables.test.ts │ ├── pg-views.test.ts │ ├── push │ │ ├── common.ts │ │ ├── libsql.test.ts │ │ ├── mysql-push.test.ts │ │ ├── mysql.test.ts │ │ ├── pg.test.ts │ │ ├── singlestore-push.test.ts │ │ ├── singlestore.test.ts │ │ └── sqlite.test.ts │ ├── rls │ │ ├── pg-policy.test.ts │ │ └── pg-role.test.ts │ ├── schemaDiffer.ts │ ├── singlestore-generated.test.ts │ ├── singlestore-schemas.test.ts │ ├── singlestore.test.ts │ ├── sqlite-checks.test.ts │ ├── sqlite-columns.test.ts │ ├── sqlite-generated.test.ts │ ├── sqlite-tables.test.ts │ ├── sqlite-views.test.ts │ ├── statements-combiner │ │ ├── libsql-statements-combiner.test.ts │ │ ├── singlestore-statements-combiner.test.ts │ │ └── sqlite-statements-combiner.test.ts │ ├── test │ │ └── sqlite.test.ts │ ├── testsinglestore.ts │ ├── validations.test.ts │ └── wrap-param.test.ts ├── tsconfig.build.json ├── tsconfig.cli-types.json ├── tsconfig.json └── vitest.config.ts ├── drizzle-orm ├── .madgerc ├── package.json ├── scripts │ ├── build.ts │ └── fix-imports.ts ├── src │ ├── alias.ts │ ├── aws-data-api │ │ ├── common │ │ │ └── index.ts │ │ └── pg │ │ │ ├── driver.ts │ │ │ ├── index.ts │ │ │ ├── migrator.ts │ │ │ └── session.ts │ ├── batch.ts │ ├── better-sqlite3 │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── bun-sql │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── bun-sqlite │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── cache │ │ ├── core │ │ │ ├── cache.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── readme.md │ │ └── upstash │ │ │ ├── cache.ts │ │ │ └── index.ts │ ├── casing.ts │ ├── column-builder.ts │ ├── column.ts │ ├── d1 │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── durable-sqlite │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── entity.ts │ ├── errors.ts │ ├── errors │ │ └── index.ts │ ├── expo-sqlite │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ ├── query.ts │ │ └── session.ts │ ├── gel-core │ │ ├── alias.ts │ │ ├── checks.ts │ │ ├── columns │ │ │ ├── all.ts │ │ │ ├── bigint.ts │ │ │ ├── bigintT.ts │ │ │ ├── boolean.ts │ │ │ ├── bytes.ts │ │ │ ├── common.ts │ │ │ ├── custom.ts │ │ │ ├── date-duration.ts │ │ │ ├── date.common.ts │ │ │ ├── decimal.ts │ │ │ ├── double-precision.ts │ │ │ ├── duration.ts │ │ │ ├── index.ts │ │ │ ├── int.common.ts │ │ │ ├── integer.ts │ │ │ ├── json.ts │ │ │ ├── localdate.ts │ │ │ ├── localtime.ts │ │ │ ├── real.ts │ │ │ ├── relative-duration.ts │ │ │ ├── smallint.ts │ │ │ ├── text.ts │ │ │ ├── timestamp.ts │ │ │ ├── timestamptz.ts │ │ │ └── uuid.ts │ │ ├── db.ts │ │ ├── dialect.ts │ │ ├── expressions.ts │ │ ├── foreign-keys.ts │ │ ├── index.ts │ │ ├── indexes.ts │ │ ├── policies.ts │ │ ├── primary-keys.ts │ │ ├── query-builders │ │ │ ├── count.ts │ │ │ ├── delete.ts │ │ │ ├── index.ts │ │ │ ├── insert.ts │ │ │ ├── query-builder.ts │ │ │ ├── query.ts │ │ │ ├── raw.ts │ │ │ ├── refresh-materialized-view.ts │ │ │ ├── select.ts │ │ │ ├── select.types.ts │ │ │ └── update.ts │ │ ├── roles.ts │ │ ├── schema.ts │ │ ├── sequence.ts │ │ ├── session.ts │ │ ├── subquery.ts │ │ ├── table.ts │ │ ├── unique-constraint.ts │ │ ├── utils.ts │ │ ├── view-base.ts │ │ ├── view-common.ts │ │ └── view.ts │ ├── gel │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── index.ts │ ├── knex │ │ ├── README.md │ │ └── index.ts │ ├── kysely │ │ ├── README.md │ │ └── index.ts │ ├── libsql │ │ ├── driver-core.ts │ │ ├── driver.ts │ │ ├── http │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ ├── node │ │ │ └── index.ts │ │ ├── session.ts │ │ ├── sqlite3 │ │ │ └── index.ts │ │ ├── wasm │ │ │ └── index.ts │ │ ├── web │ │ │ └── index.ts │ │ └── ws │ │ │ └── index.ts │ ├── logger.ts │ ├── migrator.ts │ ├── mysql-core │ │ ├── alias.ts │ │ ├── checks.ts │ │ ├── columns │ │ │ ├── all.ts │ │ │ ├── bigint.ts │ │ │ ├── binary.ts │ │ │ ├── boolean.ts │ │ │ ├── char.ts │ │ │ ├── common.ts │ │ │ ├── custom.ts │ │ │ ├── date.common.ts │ │ │ ├── date.ts │ │ │ ├── datetime.ts │ │ │ ├── decimal.ts │ │ │ ├── double.ts │ │ │ ├── enum.ts │ │ │ ├── float.ts │ │ │ ├── index.ts │ │ │ ├── int.ts │ │ │ ├── json.ts │ │ │ ├── mediumint.ts │ │ │ ├── real.ts │ │ │ ├── serial.ts │ │ │ ├── smallint.ts │ │ │ ├── text.ts │ │ │ ├── time.ts │ │ │ ├── timestamp.ts │ │ │ ├── tinyint.ts │ │ │ ├── varbinary.ts │ │ │ ├── varchar.ts │ │ │ └── year.ts │ │ ├── db.ts │ │ ├── dialect.ts │ │ ├── expressions.ts │ │ ├── foreign-keys.ts │ │ ├── index.ts │ │ ├── indexes.ts │ │ ├── primary-keys.ts │ │ ├── query-builders │ │ │ ├── count.ts │ │ │ ├── delete.ts │ │ │ ├── index.ts │ │ │ ├── insert.ts │ │ │ ├── query-builder.ts │ │ │ ├── query.ts │ │ │ ├── select.ts │ │ │ ├── select.types.ts │ │ │ └── update.ts │ │ ├── schema.ts │ │ ├── session.ts │ │ ├── subquery.ts │ │ ├── table.ts │ │ ├── unique-constraint.ts │ │ ├── utils.ts │ │ ├── view-base.ts │ │ ├── view-common.ts │ │ └── view.ts │ ├── mysql-proxy │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── mysql2 │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── neon-http │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── neon-serverless │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── neon │ │ ├── index.ts │ │ ├── neon-identity.ts │ │ └── rls.ts │ ├── node-postgres │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── op-sqlite │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── operations.ts │ ├── pg-core │ │ ├── alias.ts │ │ ├── checks.ts │ │ ├── columns │ │ │ ├── all.ts │ │ │ ├── bigint.ts │ │ │ ├── bigserial.ts │ │ │ ├── boolean.ts │ │ │ ├── char.ts │ │ │ ├── cidr.ts │ │ │ ├── common.ts │ │ │ ├── custom.ts │ │ │ ├── date.common.ts │ │ │ ├── date.ts │ │ │ ├── double-precision.ts │ │ │ ├── enum.ts │ │ │ ├── index.ts │ │ │ ├── inet.ts │ │ │ ├── int.common.ts │ │ │ ├── integer.ts │ │ │ ├── interval.ts │ │ │ ├── json.ts │ │ │ ├── jsonb.ts │ │ │ ├── line.ts │ │ │ ├── macaddr.ts │ │ │ ├── macaddr8.ts │ │ │ ├── numeric.ts │ │ │ ├── point.ts │ │ │ ├── postgis_extension │ │ │ │ ├── geometry.ts │ │ │ │ └── utils.ts │ │ │ ├── real.ts │ │ │ ├── serial.ts │ │ │ ├── smallint.ts │ │ │ ├── smallserial.ts │ │ │ ├── text.ts │ │ │ ├── time.ts │ │ │ ├── timestamp.ts │ │ │ ├── uuid.ts │ │ │ ├── varchar.ts │ │ │ └── vector_extension │ │ │ │ ├── bit.ts │ │ │ │ ├── halfvec.ts │ │ │ │ ├── sparsevec.ts │ │ │ │ └── vector.ts │ │ ├── db.ts │ │ ├── dialect.ts │ │ ├── expressions.ts │ │ ├── foreign-keys.ts │ │ ├── index.ts │ │ ├── indexes.ts │ │ ├── policies.ts │ │ ├── primary-keys.ts │ │ ├── query-builders │ │ │ ├── count.ts │ │ │ ├── delete.ts │ │ │ ├── index.ts │ │ │ ├── insert.ts │ │ │ ├── query-builder.ts │ │ │ ├── query.ts │ │ │ ├── raw.ts │ │ │ ├── refresh-materialized-view.ts │ │ │ ├── select.ts │ │ │ ├── select.types.ts │ │ │ └── update.ts │ │ ├── roles.ts │ │ ├── schema.ts │ │ ├── sequence.ts │ │ ├── session.ts │ │ ├── subquery.ts │ │ ├── table.ts │ │ ├── unique-constraint.ts │ │ ├── utils.ts │ │ ├── utils │ │ │ ├── array.ts │ │ │ └── index.ts │ │ ├── view-base.ts │ │ ├── view-common.ts │ │ └── view.ts │ ├── pg-proxy │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── pglite │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── planetscale-serverless │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── postgres-js │ │ ├── README.md │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── primary-key.ts │ ├── prisma │ │ ├── mysql │ │ │ ├── driver.ts │ │ │ ├── index.ts │ │ │ └── session.ts │ │ ├── pg │ │ │ ├── driver.ts │ │ │ ├── index.ts │ │ │ └── session.ts │ │ ├── schema.prisma │ │ └── sqlite │ │ │ ├── driver.ts │ │ │ ├── index.ts │ │ │ └── session.ts │ ├── query-builders │ │ ├── query-builder.ts │ │ └── select.types.ts │ ├── query-promise.ts │ ├── relations.ts │ ├── runnable-query.ts │ ├── selection-proxy.ts │ ├── session.ts │ ├── singlestore-core │ │ ├── alias.ts │ │ ├── columns │ │ │ ├── all.ts │ │ │ ├── bigint.ts │ │ │ ├── binary.ts │ │ │ ├── boolean.ts │ │ │ ├── char.ts │ │ │ ├── common.ts │ │ │ ├── custom.ts │ │ │ ├── date.common.ts │ │ │ ├── date.ts │ │ │ ├── datetime.ts │ │ │ ├── decimal.ts │ │ │ ├── double.ts │ │ │ ├── enum.ts │ │ │ ├── float.ts │ │ │ ├── index.ts │ │ │ ├── int.ts │ │ │ ├── json.ts │ │ │ ├── mediumint.ts │ │ │ ├── real.ts │ │ │ ├── serial.ts │ │ │ ├── smallint.ts │ │ │ ├── text.ts │ │ │ ├── time.ts │ │ │ ├── timestamp.ts │ │ │ ├── tinyint.ts │ │ │ ├── varbinary.ts │ │ │ ├── varchar.ts │ │ │ ├── vector.ts │ │ │ └── year.ts │ │ ├── db.ts │ │ ├── dialect.ts │ │ ├── expressions.ts │ │ ├── index.ts │ │ ├── indexes.ts │ │ ├── primary-keys.ts │ │ ├── query-builders │ │ │ ├── count.ts │ │ │ ├── delete.ts │ │ │ ├── index.ts │ │ │ ├── insert.ts │ │ │ ├── query-builder.ts │ │ │ ├── query.ts │ │ │ ├── select.ts │ │ │ ├── select.types.ts │ │ │ └── update.ts │ │ ├── schema.ts │ │ ├── session.ts │ │ ├── subquery.ts │ │ ├── table.ts │ │ ├── unique-constraint.ts │ │ ├── utils.ts │ │ ├── view-base.ts │ │ ├── view-common.ts │ │ └── view.ts │ ├── singlestore-proxy │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── singlestore │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── sql-js │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── sql │ │ ├── expressions │ │ │ ├── conditions.ts │ │ │ ├── index.ts │ │ │ └── select.ts │ │ ├── functions │ │ │ ├── aggregate.ts │ │ │ ├── index.ts │ │ │ └── vector.ts │ │ ├── index.ts │ │ └── sql.ts │ ├── sqlite-core │ │ ├── README.md │ │ ├── alias.ts │ │ ├── checks.ts │ │ ├── columns │ │ │ ├── all.ts │ │ │ ├── blob.ts │ │ │ ├── common.ts │ │ │ ├── custom.ts │ │ │ ├── index.ts │ │ │ ├── integer.ts │ │ │ ├── numeric.ts │ │ │ ├── real.ts │ │ │ └── text.ts │ │ ├── db.ts │ │ ├── dialect.ts │ │ ├── expressions.ts │ │ ├── foreign-keys.ts │ │ ├── index.ts │ │ ├── indexes.ts │ │ ├── primary-keys.ts │ │ ├── query-builders │ │ │ ├── count.ts │ │ │ ├── delete.ts │ │ │ ├── index.ts │ │ │ ├── insert.ts │ │ │ ├── query-builder.ts │ │ │ ├── query.ts │ │ │ ├── raw.ts │ │ │ ├── select.ts │ │ │ ├── select.types.ts │ │ │ └── update.ts │ │ ├── session.ts │ │ ├── subquery.ts │ │ ├── table.ts │ │ ├── unique-constraint.ts │ │ ├── utils.ts │ │ ├── view-base.ts │ │ ├── view-common.ts │ │ └── view.ts │ ├── sqlite-proxy │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── subquery.ts │ ├── supabase │ │ ├── index.ts │ │ └── rls.ts │ ├── table.ts │ ├── table.utils.ts │ ├── tidb-serverless │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── tracing-utils.ts │ ├── tracing.ts │ ├── utils.ts │ ├── vercel-postgres │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts │ ├── version.ts │ ├── view-common.ts │ └── xata-http │ │ ├── driver.ts │ │ ├── index.ts │ │ ├── migrator.ts │ │ └── session.ts ├── tests │ ├── casing │ │ ├── casing.test.ts │ │ ├── mysql-to-camel.test.ts │ │ ├── mysql-to-snake.test.ts │ │ ├── pg-to-camel.test.ts │ │ ├── pg-to-snake.test.ts │ │ ├── sqlite-to-camel.test.ts │ │ └── sqlite-to-snake.test.ts │ ├── exports.test.ts │ ├── is.test.ts │ ├── makePgArray.test.ts │ ├── parsePgArray.test.ts │ ├── relation.test.ts │ ├── tsconfig.json │ └── type-hints.test.ts ├── tsconfig.build.json ├── tsconfig.dts.json ├── tsconfig.json ├── tsup.config.ts ├── type-tests │ ├── common │ │ └── aliased-table.ts │ ├── geldb │ │ ├── 1-to-1-fk.ts │ │ ├── array.ts │ │ ├── count.ts │ │ ├── db-rel.ts │ │ ├── db.ts │ │ ├── delete.ts │ │ ├── generated-columns.ts │ │ ├── insert.ts │ │ ├── no-strict-null-checks │ │ │ ├── test.ts │ │ │ └── tsconfig.json │ │ ├── other.ts │ │ ├── select.ts │ │ ├── set-operators.ts │ │ ├── subquery.ts │ │ ├── tables-rel.ts │ │ ├── tables.ts │ │ ├── update.ts │ │ └── with.ts │ ├── knex │ │ └── index.ts │ ├── kysely │ │ └── index.ts │ ├── mysql │ │ ├── 1-to-1-fk.ts │ │ ├── 1000columns.ts │ │ ├── count.ts │ │ ├── db-rel.ts │ │ ├── db.ts │ │ ├── delete.ts │ │ ├── generated-columns.ts │ │ ├── insert.ts │ │ ├── no-strict-null-checks │ │ │ ├── test.ts │ │ │ └── tsconfig.json │ │ ├── select.ts │ │ ├── set-operators.ts │ │ ├── subquery.ts │ │ ├── tables-rel.ts │ │ ├── tables.ts │ │ ├── update.ts │ │ └── with.ts │ ├── pg │ │ ├── 1-to-1-fk.ts │ │ ├── array.ts │ │ ├── count.ts │ │ ├── db-rel.ts │ │ ├── db.ts │ │ ├── delete.ts │ │ ├── generated-columns.ts │ │ ├── insert.ts │ │ ├── no-strict-null-checks │ │ │ ├── test.ts │ │ │ └── tsconfig.json │ │ ├── other.ts │ │ ├── select.ts │ │ ├── set-operators.ts │ │ ├── subquery.ts │ │ ├── tables-rel.ts │ │ ├── tables.ts │ │ ├── update.ts │ │ └── with.ts │ ├── singlestore │ │ ├── 1000columns.ts │ │ ├── count.ts │ │ ├── db.ts │ │ ├── delete.ts │ │ ├── insert.ts │ │ ├── no-strict-null-checks │ │ │ ├── test.ts │ │ │ └── tsconfig.json │ │ ├── select.ts │ │ ├── set-operators.ts │ │ ├── subquery.ts │ │ ├── tables.ts │ │ ├── update.ts │ │ └── with.ts │ ├── sqlite │ │ ├── .gitignore │ │ ├── count.ts │ │ ├── db.ts │ │ ├── delete.ts │ │ ├── generated-columns.ts │ │ ├── insert.ts │ │ ├── no-strict-null-checks │ │ │ ├── test.ts │ │ │ └── tsconfig.json │ │ ├── other.ts │ │ ├── select.ts │ │ ├── set-operators.ts │ │ ├── subquery.ts │ │ ├── tables.ts │ │ ├── update.ts │ │ └── with.ts │ ├── tsconfig.json │ ├── utils.ts │ └── utils │ │ └── neon-auth-token.ts └── vitest.config.ts ├── drizzle-seed ├── README.md ├── package.json ├── rollup.config.ts ├── scripts │ └── build.ts ├── src │ ├── datasets │ │ ├── adjectives.ts │ │ ├── cityNames.ts │ │ ├── companyNameSuffixes.ts │ │ ├── countries.ts │ │ ├── emailDomains.ts │ │ ├── firstNames.ts │ │ ├── jobsTitles.ts │ │ ├── lastNames.ts │ │ ├── loremIpsumSentences.ts │ │ ├── phonesInfo.ts │ │ ├── states.ts │ │ └── streetSuffix.ts │ ├── index.ts │ ├── services │ │ ├── GeneratorFuncs.ts │ │ ├── Generators.ts │ │ ├── SeedService.ts │ │ ├── apiVersion.ts │ │ ├── utils.ts │ │ └── versioning │ │ │ └── v2.ts │ └── types │ │ ├── drizzleStudio.ts │ │ ├── seedService.ts │ │ └── tables.ts ├── tests │ ├── benchmarks │ │ └── generatorsBenchmark.ts │ ├── mysql │ │ ├── allDataTypesTest │ │ │ ├── mysqlSchema.ts │ │ │ └── mysql_all_data_types.test.ts │ │ ├── cyclicTables │ │ │ ├── cyclicTables.test.ts │ │ │ └── mysqlSchema.ts │ │ ├── generatorsTest │ │ │ ├── generators.test.ts │ │ │ └── mysqlSchema.ts │ │ ├── mysql.test.ts │ │ ├── mysqlSchema.ts │ │ └── softRelationsTest │ │ │ ├── mysqlSchema.ts │ │ │ └── softRelations.test.ts │ ├── northwind │ │ ├── mysqlSchema.ts │ │ ├── mysqlTest.ts │ │ ├── pgSchema.ts │ │ ├── pgTest.ts │ │ ├── sqliteSchema.ts │ │ └── sqliteTest.ts │ ├── pg │ │ ├── allDataTypesTest │ │ │ ├── pgSchema.ts │ │ │ └── pg_all_data_types.test.ts │ │ ├── cyclicTables │ │ │ ├── cyclicTables.test.ts │ │ │ └── pgSchema.ts │ │ ├── generatorsTest │ │ │ ├── generators.test.ts │ │ │ └── pgSchema.ts │ │ ├── pg.test.ts │ │ ├── pgSchema.ts │ │ └── softRelationsTest │ │ │ ├── pgSchema.ts │ │ │ └── softRelations.test.ts │ └── sqlite │ │ ├── allDataTypesTest │ │ ├── sqliteSchema.ts │ │ └── sqlite_all_data_types.test.ts │ │ ├── cyclicTables │ │ ├── cyclicTables.test.ts │ │ └── sqliteSchema.ts │ │ ├── softRelationsTest │ │ ├── softRelations.test.ts │ │ └── sqliteSchema.ts │ │ ├── sqlite.test.ts │ │ └── sqliteSchema.ts ├── tsconfig.build.json ├── tsconfig.json ├── type-tests │ ├── mysql.ts │ ├── pg.ts │ ├── sqlite.ts │ └── tsconfig.json └── vitest.config.ts ├── drizzle-typebox ├── README.md ├── package.json ├── rollup.config.ts ├── scripts │ ├── build.ts │ └── fix-imports.ts ├── src │ ├── column.ts │ ├── column.types.ts │ ├── constants.ts │ ├── index.ts │ ├── schema.ts │ ├── schema.types.internal.ts │ ├── schema.types.ts │ └── utils.ts ├── tests │ ├── mysql.test.ts │ ├── pg.test.ts │ ├── singlestore.test.ts │ ├── sqlite.test.ts │ ├── tsconfig.json │ └── utils.ts ├── tsconfig.build.json ├── tsconfig.json └── vitest.config.ts ├── drizzle-valibot ├── README.md ├── package.json ├── rollup.config.ts ├── scripts │ ├── build.ts │ └── fix-imports.ts ├── src │ ├── column.ts │ ├── column.types.ts │ ├── constants.ts │ ├── index.ts │ ├── schema.ts │ ├── schema.types.internal.ts │ ├── schema.types.ts │ └── utils.ts ├── tests │ ├── mysql.test.ts │ ├── pg.test.ts │ ├── singlestore.test.ts │ ├── sqlite.test.ts │ ├── tsconfig.json │ └── utils.ts ├── tsconfig.build.json ├── tsconfig.json └── vitest.config.ts ├── drizzle-zod ├── README.md ├── package.json ├── rollup.config.ts ├── scripts │ ├── build.ts │ └── fix-imports.ts ├── src │ ├── column.ts │ ├── column.types.ts │ ├── constants.ts │ ├── index.ts │ ├── schema.ts │ ├── schema.types.internal.ts │ ├── schema.types.ts │ └── utils.ts ├── tests │ ├── mysql.test.ts │ ├── pg.test.ts │ ├── singlestore.test.ts │ ├── sqlite.test.ts │ ├── tsconfig.json │ └── utils.ts ├── tsconfig.build.json ├── tsconfig.json └── vitest.config.ts ├── eslint-plugin-drizzle ├── .gitignore ├── package.json ├── readme.md ├── src │ ├── configs │ │ ├── all.ts │ │ └── recommended.ts │ ├── enforce-delete-with-where.ts │ ├── enforce-update-with-where.ts │ ├── index.ts │ └── utils │ │ ├── ast.ts │ │ └── options.ts ├── tests │ ├── delete.test.ts │ └── update.test.ts ├── tsconfig.json └── vitest.config.ts ├── eslint └── eslint-plugin-drizzle-internal │ └── index.js ├── integration-tests ├── .env.example ├── .gitignore ├── .xata │ ├── migrations │ │ └── .ledger │ └── version │ │ └── compatibility.json ├── .xatarc ├── docker-neon.yml ├── drizzle2 │ ├── mysql-proxy │ │ ├── first │ │ │ ├── 0000_nostalgic_carnage.sql │ │ │ └── meta │ │ │ │ ├── 0000_snapshot.json │ │ │ │ └── _journal.json │ │ └── second │ │ │ ├── 0000_nostalgic_carnage.sql │ │ │ ├── 0001_test.sql │ │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ ├── 0001_snapshot.json │ │ │ └── _journal.json │ ├── mysql │ │ ├── 0000_nostalgic_carnage.sql │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ └── _journal.json │ ├── pg-proxy │ │ ├── first │ │ │ ├── 0000_puzzling_flatman.sql │ │ │ └── meta │ │ │ │ ├── 0000_snapshot.json │ │ │ │ └── _journal.json │ │ └── second │ │ │ ├── 0000_puzzling_flatman.sql │ │ │ ├── 0001_test.sql │ │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ ├── 0001_snapshot.json │ │ │ └── _journal.json │ ├── pg │ │ ├── 0000_puzzling_flatman.sql │ │ ├── 0001_test.sql │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ └── _journal.json │ ├── planetscale │ │ ├── 0000_nostalgic_carnage.sql │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ └── _journal.json │ ├── singlestore │ │ ├── 0000_nostalgic_carnage.sql │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ └── _journal.json │ └── sqlite │ │ ├── 0000_fancy_bug.sql │ │ └── meta │ │ ├── 0000_snapshot.json │ │ └── _journal.json ├── js-tests │ └── driver-init │ │ ├── commonjs │ │ ├── better-sqlite3.test.cjs │ │ ├── libsql.test.cjs │ │ ├── mysql2.test.cjs │ │ ├── neon-http.test.cjs │ │ ├── neon-ws.test.cjs │ │ ├── node-pg.test.cjs │ │ ├── pglite.test.cjs │ │ ├── planetscale.test.cjs │ │ ├── postgres-js.test.cjs │ │ ├── schema.cjs │ │ ├── tidb.test.cjs │ │ └── vercel.test.cjs │ │ └── module │ │ ├── better-sqlite3.test.mjs │ │ ├── libsql.test.mjs │ │ ├── mysql2.test.mjs │ │ ├── neon-http.test.mjs │ │ ├── neon-ws.test.mjs │ │ ├── node-pg.test.mjs │ │ ├── pglite.test.mjs │ │ ├── planetscale.test.mjs │ │ ├── postgres-js.test.mjs │ │ ├── schema.mjs │ │ ├── tidb.test.mjs │ │ └── vercel.test.mjs ├── package.json ├── sst-env.d.ts ├── sst.config.ts ├── tests │ ├── awsdatapi.alltypes.test.ts │ ├── bun │ │ ├── bun-sql.test.ts │ │ ├── sqlite-nw.test.ts │ │ └── sqlite.test.ts │ ├── common.ts │ ├── extensions │ │ ├── postgis │ │ │ ├── pg.test.ts │ │ │ └── postgres.test.ts │ │ └── vectors │ │ │ ├── pg.test.ts │ │ │ └── postgres.test.ts │ ├── gel │ │ ├── cache.ts │ │ ├── createInstance.ts │ │ ├── gel-custom.test.ts │ │ ├── gel-ext.test.ts │ │ └── gel.test.ts │ ├── imports │ │ └── index.test.ts │ ├── mysql-returning.test.ts │ ├── mysql │ │ ├── mysql-common-cache.ts │ │ ├── mysql-common.ts │ │ ├── mysql-custom.test.ts │ │ ├── mysql-planetscale.test.ts │ │ ├── mysql-prefixed.test.ts │ │ ├── mysql-proxy.test.ts │ │ ├── mysql.test.ts │ │ └── tidb-serverless.test.ts │ ├── pg │ │ ├── awsdatapi.test.ts │ │ ├── neon-http-batch.test.ts │ │ ├── neon-http-batch.ts │ │ ├── neon-http.test.ts │ │ ├── neon-serverless.test.ts │ │ ├── node-postgres.test.ts │ │ ├── pg-common-cache.ts │ │ ├── pg-common.ts │ │ ├── pg-custom.test.ts │ │ ├── pg-proxy.test.ts │ │ ├── pglite.test.ts │ │ ├── postgres-js.test.ts │ │ ├── rls │ │ │ └── rls.definition.test.ts │ │ ├── vercel-pg.test.ts │ │ └── xata-http.test.ts │ ├── relational │ │ ├── bettersqlite.test.ts │ │ ├── db.ts │ │ ├── issues-schemas │ │ │ ├── duplicates │ │ │ │ ├── mysql │ │ │ │ │ ├── mysql.duplicates.test.ts │ │ │ │ │ └── mysql.duplicates.ts │ │ │ │ └── pg │ │ │ │ │ ├── pg.duplicates.test.ts │ │ │ │ │ └── pg.duplicates.ts │ │ │ └── wrong-mapping │ │ │ │ ├── pg.schema.ts │ │ │ │ └── pg.test.ts │ │ ├── mysql.planetscale.test.ts │ │ ├── mysql.schema.ts │ │ ├── mysql.test.ts │ │ ├── pg.postgresjs.test.ts │ │ ├── pg.schema.ts │ │ ├── pg.test.ts │ │ ├── singlestore.schema.ts │ │ ├── singlestore.test.ts │ │ ├── sqlite.schema.ts │ │ ├── tables.ts │ │ ├── turso.test.ts │ │ └── vercel.test.ts │ ├── replicas │ │ ├── mysql.test.ts │ │ ├── postgres.test.ts │ │ ├── singlestore.test.ts │ │ └── sqlite.test.ts │ ├── seeder │ │ ├── mysql.test.ts │ │ ├── mysqlSchema.ts │ │ ├── pg.test.ts │ │ ├── pgSchema.ts │ │ ├── sqlite.test.ts │ │ └── sqliteSchema.ts │ ├── singlestore │ │ ├── singlestore-cache.ts │ │ ├── singlestore-common.ts │ │ ├── singlestore-custom.test.ts │ │ ├── singlestore-prefixed.test.ts │ │ ├── singlestore-proxy.test.ts │ │ └── singlestore.test.ts │ ├── sqlite │ │ ├── better-sqlite.test.ts │ │ ├── d1-batch.test.ts │ │ ├── d1.test.ts │ │ ├── durable-objects │ │ │ ├── drizzle │ │ │ │ ├── 0000_cuddly_black_bolt.sql │ │ │ │ ├── meta │ │ │ │ │ ├── 0000_snapshot.json │ │ │ │ │ └── _journal.json │ │ │ │ └── migrations.js │ │ │ ├── index.ts │ │ │ ├── worker-configuration.d.ts │ │ │ └── wrangler.toml │ │ ├── libsql-batch.test.ts │ │ ├── libsql-http.test.ts │ │ ├── libsql-node.test.ts │ │ ├── libsql-sqlite3.test.ts │ │ ├── libsql-ws.test.ts │ │ ├── libsql.test.ts │ │ ├── sql-js.test.ts │ │ ├── sqlite-common-cache.ts │ │ ├── sqlite-common.ts │ │ ├── sqlite-proxy-batch.test.ts │ │ └── sqlite-proxy.test.ts │ ├── utils.ts │ ├── utils │ │ └── is-config.test.ts │ ├── version.test.ts │ └── xata │ │ └── xata.ts ├── tsconfig.json ├── vitest-ci.config.ts └── vitest.config.ts ├── misc └── readme │ ├── logo-github-sq-dark.svg │ └── logo-github-sq-light.svg ├── package.json ├── patches └── typescript@5.6.3.patch ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── tsconfig.json └── turbo.json /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | dist-dts 4 | examples 5 | **/*.js 6 | **/*.mjs 7 | **/*.cjs 8 | **/playground 9 | integration-tests/tests/prisma/*/client 10 | integration-tests/tests/prisma/*/drizzle 11 | drizzle-kit/* 12 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: drizzle-team 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Ask a question 4 | url: https://discord.gg/JGrkEU4Scj 5 | about: Ask questions and discuss with other community members in Discord 6 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | dist 4 | dist.new 5 | *.tsbuildinfo 6 | *.tgz 7 | /*.sql 8 | .cache 9 | .turbo 10 | .rollup.cache 11 | dist-dts 12 | rollup.config-*.mjs 13 | *.log 14 | .DS_Store 15 | drizzle-seed/src/dev -------------------------------------------------------------------------------- /.markdownlint.yaml: -------------------------------------------------------------------------------- 1 | no-inline-html: false 2 | first-line-h1: false 3 | line-length: false 4 | MD010: 5 | spaces_per_tab: 2 6 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # prefer-workspace-packages = true 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 22 -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | If you have a security issue to report, please contact us at [security@drizzle.team](mailto:security@drizzle.team). 6 | -------------------------------------------------------------------------------- /changelogs/README.md: -------------------------------------------------------------------------------- 1 | # Release flow 2 | 3 | - Push feature branch 4 | - GitHub workflow publishes new feature tag to NPM 5 | - Bump package versions manually 6 | - (Optional) Create and merge PR to beta 7 | - (Optional) GitHub workflow publishes new beta version to NPM 8 | - Create PR to main 9 | - TODO: GitHub workflow checks if changelog is present for every package version 10 | - Resolve all conflicts, bump versions if necessary 11 | - Merge PR 12 | - GitHub workflow publishes new latest version to NPM and removes feature tag from NPM 13 | -------------------------------------------------------------------------------- /changelogs/drizzle-arktype/0.1.3.md: -------------------------------------------------------------------------------- 1 | - TS language server performance improvements 2 | - Fixed [Buffer is not defined using drizzle-arktype client side with vite](https://github.com/drizzle-team/drizzle-orm/issues/4383) 3 | - Fixed [[BUG]: drizzle-arktype Buffer is undefined](https://github.com/drizzle-team/drizzle-orm/issues/4371) -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.23.2.md: -------------------------------------------------------------------------------- 1 | - Fixed a bug in PostgreSQL with push and introspect where the `schemaFilter` object was passed. It was detecting enums even in schemas that were not defined in the schemaFilter. 2 | - Fixed the `drizzle-kit up` command to work as expected, starting from the sequences release. 3 | -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.24.2.md: -------------------------------------------------------------------------------- 1 | ## New Features 2 | 3 | ### 🎉 Support for `pglite` driver 4 | 5 | You can now use pglite with all drizzle-kit commands, including Drizzle Studio! 6 | 7 | ```ts 8 | import { defineConfig } from "drizzle-kit"; 9 | 10 | export default defineConfig({ 11 | dialect: "postgresql", 12 | driver: "pglite", 13 | schema: "./schema.ts", 14 | dbCredentials: { 15 | url: "local-pg.db", 16 | }, 17 | verbose: true, 18 | strict: true, 19 | }); 20 | ``` 21 | 22 | ## Bug fixes 23 | 24 | - mysql-kit: fix GENERATED ALWAYS AS ... NOT NULL - [#2824](https://github.com/drizzle-team/drizzle-orm/pull/2824) -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.26.1.md: -------------------------------------------------------------------------------- 1 | - Fix `data is malformed` for views -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.26.2.md: -------------------------------------------------------------------------------- 1 | - Updated internal versions for the drizzle-kit and drizzle-orm packages. Changes were introduced in the last minor release, and you are required to upgrade both packages to ensure they work as expected -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.27.1.md: -------------------------------------------------------------------------------- 1 | - Fix: [[BUG]: When using RLS policies and Views, the view is the last clause generated](https://github.com/drizzle-team/drizzle-orm/issues/3378) -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.27.2.md: -------------------------------------------------------------------------------- 1 | - Fix [[BUG]: Undefined properties when using drizzle-kit push](https://github.com/drizzle-team/drizzle-orm/issues/3391) 2 | - Fix TypeError: Cannot read properties of undefined (reading 'isRLSEnabled') 3 | - Fix push bugs, when pushing a schema with linked policy to a table from `drizzle-orm/supabase` 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.28.1.md: -------------------------------------------------------------------------------- 1 | # Bug fixes 2 | 3 | - Fixed typos in repository: thanks @armandsalle, @masto, @wackbyte, @Asher-JH, @MaxLeiter 4 | - [fix: wrong dialect set in mysql/sqlite introspect](https://github.com/drizzle-team/drizzle-orm/pull/2865) -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.29.1.md: -------------------------------------------------------------------------------- 1 | - Fix SingleStore generate migrations command -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.30.0.md: -------------------------------------------------------------------------------- 1 | Starting from this update, the PostgreSQL dialect will align with the behavior of all other dialects. It will no longer include `IF NOT EXISTS`, `$DO`, or similar statements, which could cause incorrect DDL statements to not fail when an object already exists in the database and should actually fail. 2 | 3 | This change marks our first step toward several major upgrades we are preparing: 4 | 5 | - An updated and improved migration workflow featuring commutative migrations, a revised folder structure, and enhanced collaboration capabilities for migrations. 6 | - Better support for Xata migrations. 7 | - Compatibility with CockroachDB (achieving full compatibility will only require removing serial fields from the migration folder). -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.30.2.md: -------------------------------------------------------------------------------- 1 | - Fix certificates generation utility for Drizzle Studio; [[BUG]: [drizzle-kit]: drizzle-kit dependency on drizzle-studio perms error](https://github.com/drizzle-team/drizzle-orm/issues/3729) -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.30.3.md: -------------------------------------------------------------------------------- 1 | # SingleStore `push` and `generate` improvements 2 | 3 | As SingleStore did not support certain DDL statements before this release, you might encounter an error indicating that some schema changes cannot be applied due to a database issue. Starting from this version, drizzle-kit will detect such cases and initiate table recreation with data transfer between the tables 4 | 5 | # Bug fixes 6 | 7 | - [[BUG] If the index name is the same as the generated name, it will be empty and a type error will occur](https://github.com/drizzle-team/drizzle-orm/issues/3420) -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.30.4.md: -------------------------------------------------------------------------------- 1 | - Fix bug that generates incorrect syntax when introspect in mysql 2 | - Fix a bug that caused incorrect syntax output when introspect in unsigned columns -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.30.6.md: -------------------------------------------------------------------------------- 1 | ### Bug fixes 2 | 3 | - [[BUG]: d1 push locally is not working](https://github.com/drizzle-team/drizzle-orm/issues/4099) - thanks @mabels and @RomanNabukhotnyi 4 | - [[BUG] Cloudflare D1: drizzle-kit push is not working (error 7500 SQLITE_AUTH)](https://github.com/drizzle-team/drizzle-orm/issues/3728) - thanks @mabels and @RomanNabukhotnyi -------------------------------------------------------------------------------- /changelogs/drizzle-kit/0.31.1.md: -------------------------------------------------------------------------------- 1 | ### Fixed `drizzle-kit pull` bugs when using Gel extensions. 2 | 3 | Because Gel extensions create schema names containing `::` (for example, `ext::auth`), Drizzle previously handled these names incorrectly. Starting with this release, you can use Gel extensions without any problems. Here’s what you should do: 4 | 5 | 1. Enable extensions schemas in `drizzle.config.ts` 6 | 7 | ```ts 8 | import { defineConfig } from "drizzle-kit"; 9 | 10 | export default defineConfig({ 11 | dialect: 'gel', 12 | schemaFilter: ['ext::auth', 'public'] 13 | }); 14 | ``` 15 | 16 | 2. Run `drizzle-kit pull` 17 | 18 | 3. Done! 19 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.14.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.14.1 2 | 3 | - Release support for mysql. Currently mysql module is up-to-date with `pg` and `sqlite` -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.14.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.14.2 2 | 3 | - Bumped everything to 0.14.2 -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.14.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.14.3 2 | 3 | - Fill author field in package.json 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.15.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.15.0 2 | 3 | - Bumped everything to 0.15.0 -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.15.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.15.2 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.15.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.15.3 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.16.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.16.0 2 | 3 | - Bump all packages to 0.16.0 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.16.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.16.1 2 | 3 | - Add possibility to define database custom data types 4 | 5 | Example usage: 6 | 7 | ```typescript 8 | const customText = customType<{ data: string }>({ 9 | dataType() { 10 | return 'text'; 11 | }, 12 | }); 13 | 14 | const usersTable = mysqlTable('users', { 15 | name: customText('name').notNull(), 16 | }); 17 | ``` 18 | 19 | For more examples please check [docs](https://github.com/drizzle-team/drizzle-orm/blob/main/docs/custom-types.lite.md) -------------------------------------------------------------------------------- /changelogs/drizzle-orm-mysql/0.16.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-mysql 0.16.2 2 | 3 | - Fix peer dependency error for >=0.16 drizzle packages 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.12.0-beta.40.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.12.0-beta.40 2 | 3 | - Added prepared statements and placeholders support. 4 | - Refactored `.select().fields()` to allow fields from joined tables and nested objects structure, removed partial selects from joins. 5 | - Allowed passing query builders to `db.execute`. 6 | - Optimized INSERT query generation for single values by skipping columns without values. 7 | - Exposed `table` property from index config. 8 | - Removed testing utils. 9 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.13.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.13.0 2 | 3 | - Release 🎉 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.13.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.13.1 2 | 3 | - Implemented node-pg prepared statements usage via adding `name` argument to `.prepare()` method. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.13.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.13.2 2 | 3 | - Fix prepared statements usage. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.13.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.13.3 2 | 3 | - Implemented NeonDB serverless driver support. 4 | - (internal) Added `session.all()` and `session.values()` methods. 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.13.4.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.13.4 2 | 3 | - Fixed types for IndexBuilder. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.14.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.14.0 2 | 3 | - Separated migrations functionality to a separate import: 4 | ```typescript 5 | import { migrate } from 'drizzle-orm-pg/node/migrate'; 6 | ``` 7 | - Replaced `await new PgConnector(client).connect()` with `drizzle(client)`. 8 | - `import { PgConnector } from 'drizzle-orm-pg` -> `import { drizzle } from 'drizzle-orm-pg/node`. 9 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.14.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.14.1 2 | 3 | - Bumped everything to 0.14.1. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.14.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.14.2 2 | 3 | - Bumped everything to 0.14.2 -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.14.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.14.3 2 | 3 | - Fixed `.onConflict` statement query builder. In previous versions target column was mapped together with table name 4 | - Added documentation examples for `onConflict` 5 | - Added documentation examples for returning statements for insert/update/delete 6 | - Add more tests for `onConflict` query builder -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.14.4.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.14.4 2 | 3 | - Fill author field in package.json 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.15.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.15.2 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.15.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.15.3 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.16.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.16.0 2 | 3 | - Implemented [postgres.js](https://github.com/porsager/postgres) driver support ([docs](/drizzle-orm-pg/src/postgres-js/README.md)) 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.16.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.16.1 2 | 3 | - Fix documentation links 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.16.2.md: -------------------------------------------------------------------------------- 1 | - Add possibility to define database custom data types 2 | 3 | Example usage: 4 | 5 | ```typescript 6 | const customText = customType<{ data: string }>({ 7 | dataType() { 8 | return 'text'; 9 | }, 10 | }); 11 | 12 | const usersTable = pgTable('users', { 13 | name: customText('name').notNull(), 14 | }); 15 | ``` 16 | 17 | For more examples please check [docs](https://github.com/drizzle-team/drizzle-orm/blob/main/docs/custom-types.lite.md) -------------------------------------------------------------------------------- /changelogs/drizzle-orm-pg/0.16.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-pg 0.16.3 2 | 3 | - Fix peer dependency error for >=0.16 drizzle packages 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.12.0-beta.17.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.12.0-beta.17 2 | 3 | - Refactored `.select().fields()` to allow fields from joined tables and nested objects structure, removed partial selects from joins. 4 | - Replaced `.execute()` in query builders and prepared statements with `.run()`, `.all()`, `.get()`, `.values()`. 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.12.0-beta.18.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.12.0-beta.18 2 | 3 | - Updated `better-sqlite3` and `@types/better-sqlite3` peer dependency from `<8` to `<9`. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.12.0-beta.19.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.12.0-beta.19 2 | 3 | - Fix bug with running migrations. `Error: SqliteError: near "SCHEMA": syntax error` was fixed 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.12.0-beta.20.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.12.0-beta.20 2 | 3 | - Fix bug with running migrations for async driver. `Error: SqliteError: near "SCHEMA": syntax error` was fixed 4 | - Fix `Statement does not return any data - use run()` error, when no fields were provided to prepared statement 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.12.0-beta.21.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.12.0-beta.21 2 | 3 | - Fixed `db.all` logic for all drivers. 4 | - Allowed passing query builders to raw query execution methods. 5 | - Optimized INSERT query generation for single values by skipping columns without values. 6 | - Exposed `table` property from index config. 7 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.13.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.13.0 2 | 3 | - Release 🎉 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.14.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.14.1 2 | 3 | - Separated migrations functionality to a separate import: 4 | ```typescript 5 | import { migrate } from 'drizzle-orm-sqlite/better-sqlite3/migrate'; 6 | ``` 7 | - Replaced `await new SQLiteConnector(client).connect()` with `drizzle(client)`. 8 | - `import { SQLiteConnector } from 'drizzle-orm-sqlite` -> `import { drizzle } from 'drizzle-orm-pg/better-sqlite3`. 9 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.14.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.14.2 2 | 3 | - Bumped everything to 0.14.2 -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.14.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.14.3 2 | 3 | - `RangeError: The supplied SQL string contains more than one statement` error on migrations was fixed 4 | 5 | Created `.exec()` method for session, that will run query without prepared statments 6 | 7 | - Fix `defaultNow()` method query generation by adding missin `"()"`. 8 | 9 | Previously default value was generated as 10 | ```sql 11 | cast((julianday('now') - 2440587.5)*86400000 as integer) 12 | ``` 13 | 14 | Currently default value looks like 15 | ```sql 16 | (cast((julianday('now') - 2440587.5)*86400000 as integer)) 17 | ``` 18 | 19 | - Create test cases for both issues -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.14.4.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.14.4 2 | 3 | - Fix adding autoincrement to `drizzle-kit` migrations -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.14.5.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.14.5 2 | 3 | - Remove upper bound restriction from `@cloudflare/workers-types` peer dependency 4 | - Fill author field in package.json 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.15.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.15.0 2 | 3 | - Add composite PK's on table schema definition 4 | 5 | #### Usage example 6 | ```typescript 7 | const pkExample = sqliteTable('pk_example', { 8 | id: integer('id'), 9 | name: text('name').notNull(), 10 | email: text('email').notNull(), 11 | }, (table) => ({ 12 | compositePk: primaryKey(table.id, table.name) 13 | })); 14 | ``` -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.15.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.15.2 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.15.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.15.3 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.15.4.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.15.4 2 | 3 | - Implemented [sql.js](https://github.com/sql-js/sql.js/) driver support (allows you to use SQLite in the browser) 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.16.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.16.0 2 | 3 | - Bump all packages to 0.16.0 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm-sqlite/0.16.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm-sqlite 0.16.1 2 | 3 | - Fix peer dependency error for >=0.16 drizzle packages 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.12.0-beta.23.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.12.0-beta.23 2 | 3 | - Added new row mapping mechanism as `mapResultRowV2`, `mapResultRow` will be replaced by it in the future. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.12.0-beta.24.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.12.0-beta.24 2 | 3 | - Made `.execute()` method public in query builders. 4 | - Added `name()` function for escaping entity names inside queries. 5 | - (internal) Removed old row mapper implementation. 6 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.13.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.13.0 2 | 3 | - Release 🎉 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.13.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.13.1 2 | 3 | - Fix mysql peer dependency range 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.14.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.14.1 2 | 3 | - Bumped everything to 0.14.1. 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.14.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.14.2 2 | 3 | - Bumped everything to 0.14.2 -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.15.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.15.0 2 | 3 | - Minor upgrade for all modules, due to adding version for api 4 | - Add internal version for ORM api and npm version -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.15.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.15.1 2 | 3 | - Add schema symbol to table 4 | - Append schema before table name in SQLWrapper if it exists -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.15.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.15.2 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.15.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.15.3 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.16.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.16.0 2 | 3 | - Bump all packages to 0.16.0 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.16.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-orm 0.16.0 2 | 3 | - Fix peer dependency error for >=0.16 drizzle packages 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.1.md: -------------------------------------------------------------------------------- 1 | - Added feature showcase section to README 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.2.md: -------------------------------------------------------------------------------- 1 | - Fixed package.json require path in 'drizzle-orm/version' 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.3.md: -------------------------------------------------------------------------------- 1 | We have released [AWS Data API support](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) for PostgreSQL 2 | 3 | --- 4 | 5 | Connection example 6 | 7 | ```typescript 8 | import { drizzle, migrate } from 'drizzle-orm/aws-data-api/pg'; 9 | 10 | const rdsClient = new RDSDataClient({}); 11 | 12 | const db = drizzle(rdsClient, { 13 | database: '', 14 | secretArn: '', 15 | resourceArn: '', 16 | }); 17 | 18 | await migrate(db, { migrationsFolder: '' }); 19 | ``` 20 | 21 | > **Note**: 22 | > All drizzle pg data types are working well with data api, except of `interval`. This type is not yet mapped in proper way -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.4.md: -------------------------------------------------------------------------------- 1 | We have released [SQLite Proxy Driver](https://github.com/drizzle-team/drizzle-orm/tree/main/examples/sqlite-proxy) 2 | 3 | --- 4 | 5 | Perfect way to setup custom logic for database calls instead of predefined drivers 6 | 7 | Should work well with serverless apps 🚀 8 | 9 | ```typescript 10 | // Custom Proxy HTTP driver 11 | const db = drizzle(async (sql, params, method) => { 12 | try { 13 | const rows = await axios.post('http://localhost:3000/query', { sql, params, method }); 14 | 15 | return { rows: rows.data }; 16 | } catch (e: any) { 17 | console.error('Error from sqlite proxy server: ', e.response.data) 18 | return { rows: [] }; 19 | } 20 | }); 21 | ``` 22 | 23 | > For more example you can check [full documentation](https://github.com/drizzle-team/drizzle-orm/tree/main/examples/sqlite-proxy) -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.5.md: -------------------------------------------------------------------------------- 1 | We have released [Planetscale Serverless](https://github.com/planetscale/database-js) driver support 2 | 3 | --- 4 | 5 | Usage example: 6 | 7 | ```typescript 8 | import { drizzle } from 'drizzle-orm/planetscale-serverless'; 9 | import { connect } from '@planetscale/database'; 10 | 11 | // create the connection 12 | const connection = connect({ 13 | host: process.env['DATABASE_HOST'], 14 | username: process.env['DATABASE_USERNAME'], 15 | password: process.env['DATABASE_PASSWORD'], 16 | }); 17 | 18 | const db = drizzle(connection); 19 | ``` 20 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.6.md: -------------------------------------------------------------------------------- 1 | Fix circular dependency for query building on all pg and mysql drivers 2 | 3 | Moved all aws data api typings specific logic to dialect from sql to prevent circular dependency issues -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.17.7.md: -------------------------------------------------------------------------------- 1 | - Fix [#158](https://github.com/drizzle-team/drizzle-orm/issues/158) issue. Method `.returning()` was working incorrectly with `.get()` method in sqlite dialect 2 | - Fix SQLite Proxy driver mapping bug 3 | - Add test cases for SQLite Proxy driver 4 | - Add additional example for SQLite Proxy Server setup to handle `.get()` as well -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.18.0.md: -------------------------------------------------------------------------------- 1 | - Improved join result types for partial selects (refer to the [docs](/docs/joins.md) page for more information) 2 | - Renamed import paths for Postgres.js and SQL.js drivers to avoid bundling errors: 3 | - `drizzle-orm/postgres.js` -> `drizzle-orm/postgres-js` 4 | - `drizzle-orm/sql.js` -> `drizzle-orm/sql-js` 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.19.0.md: -------------------------------------------------------------------------------- 1 | - Implemented selecting and joining a subquery. Example usage: 2 | 3 | ```ts 4 | const sq = db 5 | .select({ 6 | categoryId: courseCategoriesTable.id, 7 | category: courseCategoriesTable.name, 8 | total: sql`count(${courseCategoriesTable.id})`.as(), 9 | }) 10 | .from(courseCategoriesTable) 11 | .groupBy(courseCategoriesTable.id, courseCategoriesTable.name) 12 | .subquery('sq'); 13 | ``` 14 | 15 | After that, just use the subquery instead of a table as usual. 16 | 17 | - ❗ Replaced `db.select(table).fields({ ... })` syntax with `db.select({ ... }).from(table)` to look more like its SQL counterpart. 18 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.19.1.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | --- 4 | 5 | - Add `char` data type support for postgresql by @AlexandrLi in [#177](https://github.com/drizzle-team/drizzle-orm/pull/177) 6 | - Adding new section with `New Contributors` for release notes. Took this template from [bun](https://github.com/oven-sh/bun) release notes pattern 7 | 8 | ## New Contributors 9 | 10 | --- 11 | 12 | - @AlexandrLi made their first contribution in [#177](https://github.com/drizzle-team/drizzle-orm/pull/177) 13 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.20.0.md: -------------------------------------------------------------------------------- 1 | 2 | - 🎉 **Implemented support for WITH clause ([docs](/drizzle-orm/src/pg-core/README.md#with-clause)). Example usage:** 3 | 4 | ```ts 5 | const sq = db 6 | .select() 7 | .from(users) 8 | .prepareWithSubquery('sq'); 9 | 10 | const result = await db 11 | .with(sq) 12 | .select({ 13 | id: sq.id, 14 | name: sq.name, 15 | total: sql`count(${sq.id})::int`(), 16 | }) 17 | .from(sq) 18 | .groupBy(sq.id, sq.name); 19 | ``` 20 | 21 | - 🐛 Fixed various bugs with selecting/joining of subqueries. 22 | - ❗ Renamed `.subquery('alias')` to `.as('alias')`. 23 | - ❗ ``sql`query`.as()`` is now ``sql`query`()``. Old syntax is still supported, but is deprecated and will be removed in one of the next releases. 24 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.20.1.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added `{ logger: true }` shorthand to `drizzle()` to enable query logging. See [logging docs](/drizzle-orm/src/pg-core/README.md#logging) for detailed logging configuration. 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.20.2.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added PostgreSQL network data types: 2 | - `inet` 3 | - `cidr` 4 | - `macaddr` 5 | - `macaddr8` 6 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.20.3.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added support for locking clauses in SELECT (`SELECT ... FOR UPDATE`): 2 | 3 | PostgreSQL 4 | 5 | ```ts 6 | await db 7 | .select() 8 | .from(users) 9 | .for('update') 10 | .for('no key update', { of: users }) 11 | .for('no key update', { of: users, skipLocked: true }) 12 | .for('share', { of: users, noWait: true }); 13 | ``` 14 | 15 | MySQL 16 | 17 | ```ts 18 | await db.select().from(users).for('update'); 19 | await db.select().from(users).for('share', { skipLocked: true }); 20 | await db.select().from(users).for('update', { noWait: true }); 21 | ``` 22 | 23 | - 🎉🐛 Custom column types now support returning `SQL` from `toDriver()` method in addition to the `driverData` type from generic. 24 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.21.1.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added support for `HAVING` clause 2 | - 🎉 Added support for referencing selected fields in `.where()`, `.having()`, `.groupBy()` and `.orderBy()` using an optional callback: 3 | 4 | ```ts 5 | await db 6 | .select({ 7 | id: citiesTable.id, 8 | name: sql`upper(${citiesTable.name})`.as('upper_name'), 9 | usersCount: sql`count(${users2Table.id})::int`.as('users_count'), 10 | }) 11 | .from(citiesTable) 12 | .leftJoin(users2Table, eq(users2Table.cityId, citiesTable.id)) 13 | .where(({ name }) => sql`length(${name}) >= 3`) 14 | .groupBy(citiesTable.id) 15 | .having(({ usersCount }) => sql`${usersCount} > 0`) 16 | .orderBy(({ name }) => name); 17 | ``` 18 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Re-export `InferModel` from `drizzle-orm` 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.10.md: -------------------------------------------------------------------------------- 1 | - 🐛 Add missing config argument to transactions API 2 | - 🐛 Fix Postgres and MySQL schema declaration (#427) 3 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.11.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fix migrator function for PostgreSQL 2 | 3 | > Would suggest to upgrade to this version anyone who is using postgres dialect. `0.23.9` and `0.23.10` are broken for postgresql migrations 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.12.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed multi-level join results (e.g. joining a subquery with a nested join) 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.13.md: -------------------------------------------------------------------------------- 1 | - 🎉 All enum and text enum columns now have a properly typed `enumValues` property 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.2.md: -------------------------------------------------------------------------------- 1 | - 🐛 Rolled back some breaking changes for drizzle-kit 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.3.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added [libSQL](https://libsql.org/) support 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.4.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed broken types in Kysely and Knex adapters 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.5.md: -------------------------------------------------------------------------------- 1 | - 🐛 Various minor bugfixes 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.6.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed referencing the selected aliased field in the same query 2 | - 🐛 Fixed decimal column data type in MySQL 3 | - 🐛 Fixed mode autocompletion for integer column in SQLite 4 | - 🐛 Fixed extra parentheses in the generated SQL for the `IN` operator (#382) 5 | - 🐛 Fixed regression in `pgEnum.enumValues` type (#358) 6 | - 🎉 Allowed readonly arrays to be passed to `pgEnum` 7 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.7.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added `INSERT IGNORE` support for MySQL (#305) 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.8.md: -------------------------------------------------------------------------------- 1 | - 🎉 Fixed dates timezone differences for timestamps in Postgres and MySQL (contributed by @AppelBoomHD via #288) 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.23.9.md: -------------------------------------------------------------------------------- 1 | # Transactions support 🎉 2 | 3 | You can now use transactions with all the supported databases and drivers. 4 | 5 | `node-postgres` example: 6 | 7 | ```ts 8 | await db.transaction(async (tx) => { 9 | await tx.insert(users).values(newUser); 10 | await tx.update(users).set({ name: 'Mr. Dan' }).where(eq(users.name, 'Dan')); 11 | await tx.delete(users).where(eq(users.name, 'Dan')); 12 | }); 13 | ``` 14 | 15 | For more information, see transactions docs: 16 | 17 | - [PostgreSQL](/drizzle-orm/src/pg-core/README.md#transactions) 18 | - [MySQL](/drizzle-orm/src/mysql-core/README.md#transactions) 19 | - [SQLite](/drizzle-orm/src/sqlite-core/README.md#transactions) 20 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.24.0.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added iterator support to `mysql2` (sponsored by @rizen ❤) 2 | - ❗ `.prepare()` in MySQL no longer requires a name argument 3 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.24.1.md: -------------------------------------------------------------------------------- 1 | ### Bugs 2 | 3 | 🐛 Fix onConflict targets in [#475](https://github.com/drizzle-team/drizzle-orm/pull/475) - thanks @wkunert ❤️ 4 | 5 | ### Documentation 6 | 7 | > Thanks to @tmcw we have started our way to get JSDoc documentation 8 | 9 | 📄 JSDoc for conditions in [#467](https://github.com/drizzle-team/drizzle-orm/pull/467) - thanks @tmcw ❤️ -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.24.2.md: -------------------------------------------------------------------------------- 1 | - 🐛 Pool connections opened for transactions are now closed after the transaction is committed or rolled back 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.24.3.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed query generation when selecting from alias 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.24.4.md: -------------------------------------------------------------------------------- 1 | - 🐛 Added verbose error when .values() is called without values (#441) 2 | - 🐛 Fixed nested PG arrays mapping (#460) 3 | - ❗ Removed spread syntax in .values() (#269) 4 | - 🐛 Fixed passing undefined as field value to insert/update (#375) 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.24.5.md: -------------------------------------------------------------------------------- 1 | - Add possibility to have placeholders in `.limit()` and `.offset()` 2 | 3 | ```ts 4 | const stmt = db 5 | .select({ 6 | id: usersTable.id, 7 | name: usersTable.name, 8 | }) 9 | .from(usersTable) 10 | .limit(placeholder('limit')) 11 | .offset(placeholder('offset')) 12 | .prepare('stmt'); 13 | 14 | const result = await stmt.execute({ limit: 1, offset: 1 }); 15 | ``` 16 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.25.0.md: -------------------------------------------------------------------------------- 1 | # ESM support 2 | 3 | - 🎉 Added ESM support! You can now use `drizzle-orm` in both ESM and CJS environments. 4 | - 🎉 Added code minification and source maps. 5 | - ❗ Removed several nested import paths. Most notably, everything from `drizzle-orm/sql` and `drizzle-orm/expressions` should now be imported from `drizzle-orm` instead. 6 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.25.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fix package.json `exports` field 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.25.2.md: -------------------------------------------------------------------------------- 1 | - 🎉 Documentation improvements (#495, #507) 2 | - 🎉 Added `"sideEffects": false` to package.json (#515) 3 | - 🐛 Fixed AWS Data API driver migrations (#510) 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.25.3.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fix `pg` imports in ESM mode (#505) 2 | - 🐛 Add "types" and "default" fields to "exports" entries in package.json (#511) 3 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.25.4.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added support for [Vercel Postgres](https://vercel.com/docs/storage/vercel-postgres/quickstart) 2 | 3 | ```typescript 4 | import { drizzle } from 'drizzle-orm/vercel-postgres'; 5 | import { sql } from "@vercel/postgres"; 6 | 7 | const db = drizzle(sql); 8 | 9 | db.select(...) 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.26.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed including multiple relations on the same level in RQB (#599) 2 | - 🐛 Updated migrators for relational queries support (#601) 3 | - 🐛 Fixed invoking .findMany() without arguments 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.26.2.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed upsert targeting composite keys for SQLite (#521) 2 | - 🐛 AWS Data API+Postgres: fixed adding of typings when merging queries (#517) 3 | - 🐛 Fixed "on conflict" with "where" clause for Postgres (#651) 4 | - 🐛 Various GitHub docs community fixes and improvements ♥ (#547, #548, #587, #606, #609, #625) 5 | - **Experimental**: added OpenTelemetry support for Postgres 6 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.26.3.md: -------------------------------------------------------------------------------- 1 | - Disabled OTEL integration due to the top-level await issues 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.26.4.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed AWS Data API mapping in relational queries (#677, #681) 2 | - 🐛 Allowed using named self-relations (#678) 3 | - 🐛 Fixed querying relations with composite FKs (#683) 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.26.5.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added bigint mode to SQLite (#558) 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.27.1.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added support for [Neon HTTP driver](https://neon.tech/docs/serverless/serverless-driver) 2 | 3 | ```typescript 4 | import { neon, neonConfig } from '@neondatabase/serverless'; 5 | import { drizzle } from 'drizzle-orm/neon-http'; 6 | 7 | neonConfig.fetchConnectionCache = true; 8 | 9 | const sql = neon(process.env.DRIZZLE_DATABASE_URL!); 10 | const db = drizzle(sql); 11 | 12 | db.select(...) 13 | ``` -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.28.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed Postgres array-related issues introduced by 0.28.0 (#983, #992) 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.28.2.md: -------------------------------------------------------------------------------- 1 | ## The community contributions release 🎉 2 | 3 | ### Internal Features and Changes 4 | 1. Added a set of tests for d1. Thanks to @AdiRishi! 5 | 2. Fixed issues in internal documentation. Thanks to @balazsorban44 and @pyk! 6 | 7 | ### Bug Fixes 8 | 1. Resolved the issue of truncating timestamp milliseconds for MySQL. Thanks to @steviec! 9 | 2. Corrected the type of the get() method for sqlite-based dialects. Issue #565 has been closed. Thanks to @stefanmaric! 10 | 3. Rectified the sqlite-proxy bug that caused the query to execute twice. Thanks to @mosch! 11 | 12 | ### New packages 🎉 13 | 14 | Added a support for [Typebox](https://github.com/sinclairzx81/typebox) in [drizzle-typebox](https://orm.drizzle.team/docs/typebox) package. Thanks to @Bulbang! 15 | 16 | Please check documentation page for more usage examples: https://orm.drizzle.team/docs/typebox 17 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.28.4.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed imports in ESM-based projects (#1088) 2 | - 🐛 Fixed type error on Postgres table definitions (#1089) 3 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.28.5.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed incorrect OpenTelemetry type import that caused a runtime error 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.29.3.md: -------------------------------------------------------------------------------- 1 | - fix: make expo peer dependencies optional #1714 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.1.md: -------------------------------------------------------------------------------- 1 | ## New Features 2 | 3 | ### 🎉 OP-SQLite driver Support 4 | 5 | Usage Example 6 | 7 | ```ts 8 | import { open } from '@op-engineering/op-sqlite'; 9 | import { drizzle } from 'drizzle-orm/op-sqlite'; 10 | 11 | const opsqlite = open({ 12 | name: 'myDB', 13 | }); 14 | const db = drizzle(opsqlite); 15 | 16 | await db.select().from(users); 17 | ``` 18 | 19 | For more usage and setup details, please check our [op-sqlite docs](http://orm.drizzle.team/docs/get-started-sqlite#op-sqlite) 20 | 21 | ### Bug fixes 22 | 23 | - Migration hook fixed for Expo driver 24 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.10.md: -------------------------------------------------------------------------------- 1 | ## New Features 2 | 3 | ### 🎉 `.if()` function added to all WHERE expressions 4 | 5 | #### Select all users after cursors if a cursor value was provided 6 | 7 | ```ts 8 | function getUsersAfter(cursor?: number) { 9 | return db.select().from(users).where( 10 | gt(users.id, cursor).if(cursor) 11 | ); 12 | } 13 | ``` 14 | 15 | ## Bug Fixes 16 | 17 | - Fixed internal mappings for sessions `.all`, `.values`, `.execute` functions in AWS DataAPI 18 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.2.md: -------------------------------------------------------------------------------- 1 | ## Improvements 2 | 3 | LibSQL migrations have been updated to utilize batch execution instead of transactions. As stated in the [documentation](https://docs.turso.tech/sdk/ts/reference#batch-transactions), LibSQL now supports batch operations 4 | 5 | > A batch consists of multiple SQL statements executed sequentially within an implicit transaction. The backend handles the transaction: success commits all changes, while any failure results in a full rollback with no modifications. 6 | 7 | ## Bug fixed 8 | 9 | - [Sqlite] Fix findFirst query for bun:sqlite #1885 - thanks @shaileshaanand 10 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.3.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added raw query support (`db.execute(...)`) to batch API in Neon HTTP driver 2 | - 🐛 Fixed `@neondatabase/serverless` HTTP driver types issue (#1945, neondatabase/serverless#66) 3 | - 🐛 Fixed sqlite-proxy driver `.run()` result 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.7-preview.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added custom schema support to enums in Postgres: 2 | ```ts 3 | import { pgSchema } from 'drizzle-orm/pg-core'; 4 | 5 | const mySchema = pgSchema('mySchema'); 6 | const colors = mySchema.enum('colors', ['red', 'green', 'blue']); 7 | ``` 8 | 9 | - 🐛 Split `where` clause in Postgres `.onConflictDoUpdate` method into `setWhere` and `targetWhere` clauses, to support both `where` cases in `on conflict ...` clause (#1628, #1302) 10 | - 🐛 Fix query generation for `where` clause in Postgres `.onConflictDoNothing` method, as it was placed in a wrong spot (#1628) -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.7.md: -------------------------------------------------------------------------------- 1 | ## Bug fixes 2 | 3 | - Add mappings for `@vercel/postgres` package 4 | - Fix interval mapping for `neon` drivers - #1542 -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.8.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added custom schema support to enums in Postgres (fixes #669 via #2048): 2 | 3 | ```ts 4 | import { pgSchema } from 'drizzle-orm/pg-core'; 5 | 6 | const mySchema = pgSchema('mySchema'); 7 | const colors = mySchema.enum('colors', ['red', 'green', 'blue']); 8 | ``` 9 | 10 | - 🎉 Changed D1 `migrate()` function to use batch API (#2137) 11 | - 🐛 Split `where` clause in Postgres `.onConflictDoUpdate` method into `setWhere` and `targetWhere` clauses, to support both `where` cases in `on conflict ...` clause (fixes #1628, #1302 via #2056) 12 | - 🐛 Fixed query generation for `where` clause in Postgres `.onConflictDoNothing` method, as it was placed in a wrong spot (fixes #1628 via #2056) 13 | - 🐛 Fixed multiple issues with AWS Data API driver (fixes #1931, #1932, #1934, #1936 via #2119) 14 | - 🐛 Fix inserting and updating array values in AWS Data API (fixes #1912 via #1911) 15 | 16 | Thanks @hugo082 and @livingforjesus! 17 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.30.9.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed migrator in AWS Data API 2 | - Added `setWhere` and `targetWhere` fields to `.onConflictDoUpdate()` config in SQLite instead of single `where` field 3 | - 🛠️ Added schema information to Drizzle instances via `db._.fullSchema` 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.31.2.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added support for TiDB Cloud Serverless driver: 2 | 3 | ```ts 4 | import { connect } from '@tidbcloud/serverless'; 5 | import { drizzle } from 'drizzle-orm/tidb-serverless'; 6 | 7 | const client = connect({ url: '...' }); 8 | const db = drizzle(client); 9 | await db.select().from(...); 10 | ``` 11 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.31.3.md: -------------------------------------------------------------------------------- 1 | ### Bug fixed 2 | 3 | - 🛠️ Fixed RQB behavior for tables with same names in different schemas 4 | - 🛠️ Fixed [BUG]: Mismatched type hints when using RDS Data API - #2097 5 | 6 | ### New Prisma-Drizzle extension 7 | 8 | ```ts 9 | import { PrismaClient } from '@prisma/client'; 10 | import { drizzle } from 'drizzle-orm/prisma/pg'; 11 | import { User } from './drizzle'; 12 | 13 | const prisma = new PrismaClient().$extends(drizzle()); 14 | const users = await prisma.$drizzle.select().from(User); 15 | ``` 16 | 17 | For more info, check docs: https://orm.drizzle.team/docs/prisma 18 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.31.4.md: -------------------------------------------------------------------------------- 1 | - Mark prisma clients package as optional - thanks @Cherry -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.32.1.md: -------------------------------------------------------------------------------- 1 | - Fix typings for indexes and allow creating indexes on 3+ columns mixing columns and expressions - thanks @lbguilherme! 2 | - Added support for "limit 0" in all dialects - closes [#2011](https://github.com/drizzle-team/drizzle-orm/issues/2011) - thanks @sillvva! 3 | - Make inArray and notInArray accept empty list, closes [#1295](https://github.com/drizzle-team/drizzle-orm/issues/1295) - thanks @RemiPeruto! 4 | - fix typo in lt typedoc - thanks @dalechyn! 5 | - fix wrong example in README.md - thanks @7flash! -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.32.2.md: -------------------------------------------------------------------------------- 1 | - Fix AWS Data API type hints bugs in RQB 2 | - Fix set transactions in MySQL bug - thanks @roguesherlock 3 | - Add forwaring dependencies within useLiveQuery, fixes [#2651](https://github.com/drizzle-team/drizzle-orm/issues/2651) - thanks @anstapol 4 | - Export additional types from SQLite package, like `AnySQLiteUpdate` - thanks @veloii -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.34.1.md: -------------------------------------------------------------------------------- 1 | - Fixed dynamic imports for CJS and MJS in the `/connect` module -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.35.1.md: -------------------------------------------------------------------------------- 1 | - Updated internal versions for the drizzle-kit and drizzle-orm packages. Changes were introduced in the last minor release, and you are required to upgrade both packages to ensure they work as expected -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.35.2.md: -------------------------------------------------------------------------------- 1 | - Fix issues with importing in several environments after updating the Drizzle driver implementation 2 | 3 | We've added approximately 240 tests to check the ESM and CJS builds for all the drivers we have. You can check them [here](https://github.com/drizzle-team/drizzle-orm/tree/main/integration-tests/js-tests/driver-init) 4 | 5 | - Fixed [[BUG]: Type Error in PgTransaction Missing $client Property After Upgrading to drizzle-orm@0.35.1](https://github.com/drizzle-team/drizzle-orm/issues/3140) 6 | - Fixed [[BUG]: New critical Build error drizzle 0.35.0 deploying on Cloudflare ](https://github.com/drizzle-team/drizzle-orm/issues/3137) -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.36.1.md: -------------------------------------------------------------------------------- 1 | # Bug Fixes 2 | 3 | - [[BUG]: Using sql.placeholder with limit and/or offset for a prepared statement produces TS error](https://github.com/drizzle-team/drizzle-orm/issues/2146) - thanks @L-Mario564 4 | - [[BUG] If a query I am trying to modify with a dynamic query (....$dynamic()) contains any placeholders, I'm getting an error that says No value for placeholder.... provided](https://github.com/drizzle-team/drizzle-orm/issues/2272) - thanks @L-Mario564 5 | - [[BUG]: Error thrown when trying to insert an array of new rows using generatedAlwaysAsIdentity() for the id column](https://github.com/drizzle-team/drizzle-orm/issues/2849) - thanks @L-Mario564 6 | - [[BUG]: Unable to Use BigInt Types with Bun and Drizzle](https://github.com/drizzle-team/drizzle-orm/issues/2603) - thanks @L-Mario564 7 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.36.2.md: -------------------------------------------------------------------------------- 1 | # New Features 2 | 3 | - [Support more types in like, notLike, ilike and notIlike expressions](https://github.com/drizzle-team/drizzle-orm/pull/2805) 4 | 5 | 6 | # Bug and typo fixes 7 | 8 | - Fixed typos in repository: thanks @armandsalle, @masto, @wackbyte, @Asher-JH, @MaxLeiter 9 | 10 | - [Fixed .generated behavior with non-strict tsconfig](https://github.com/drizzle-team/drizzle-orm/pull/3542) 11 | - [Fix Drizzle ORM for expo-sqlite](https://github.com/drizzle-team/drizzle-orm/pull/3197) 12 | - [Fixed lack of schema name on columns in sql](https://github.com/drizzle-team/drizzle-orm/pull/3531) 13 | - [fix: Adjust neon http driver entity kind](https://github.com/drizzle-team/drizzle-orm/pull/3424) 14 | - [Export PgIntegerBuilderInitial type](https://github.com/drizzle-team/drizzle-orm/pull/2846) 15 | - [[MySQL] Correct $returningId() implementation to correctly store selected fields](https://github.com/drizzle-team/drizzle-orm/pull/2975) -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.38.1.md: -------------------------------------------------------------------------------- 1 | - Closed [[FEATURE]: Add more flexible typing for usage with exactOptionalPropertyTypes](https://github.com/drizzle-team/drizzle-orm/issues/2742) -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.38.3.md: -------------------------------------------------------------------------------- 1 | - Fix incorrect deprecation detection for table declarations -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.38.4.md: -------------------------------------------------------------------------------- 1 | - New SingleStore type `vector` - thanks @mitchwadair 2 | - Fix wrong DROP INDEX statement generation, [#3866](https://github.com/drizzle-team/drizzle-orm/pull/3866) - thanks @WaciX 3 | - Typo fixes - thanks @stephan281094 -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.39.1.md: -------------------------------------------------------------------------------- 1 | - Fixed SQLite onConflict clauses being overwritten instead of stacked - [#2276](https://github.com/drizzle-team/drizzle-orm/issues/2276) 2 | - Added view support to `aliasedTable()` 3 | - Fixed sql builder prefixing aliased views and tables with their schema -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.39.2.md: -------------------------------------------------------------------------------- 1 | - To be compatible with latest Neon Auth feature we renamed the pre-defined schema internally, from `neon_identity` to `neon_auth` - thanks @pffigueiredo -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.39.3.md: -------------------------------------------------------------------------------- 1 | - Remove `react` from peerDependencies 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.40.1.md: -------------------------------------------------------------------------------- 1 | #### Updates to `neon-http` for `@neondatabase/serverless@1.0.0` - thanks @jawj 2 | 3 | Starting from this version, drizzle-orm will be compatible with both `@neondatabase/serverless` <1.0 and >1.0 -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.43.1.md: -------------------------------------------------------------------------------- 1 | ## Fixes 2 | 3 | - [Fixed incorrect types of schema enums in PostgreSQL](https://github.com/drizzle-team/drizzle-orm/issues/4421) -------------------------------------------------------------------------------- /changelogs/drizzle-orm/0.44.1.md: -------------------------------------------------------------------------------- 1 | - [[BUG]: Drizzle can no longer run on Durable Objects](https://github.com/drizzle-team/drizzle-orm/issues/4586) -------------------------------------------------------------------------------- /changelogs/drizzle-seed/0.1.2.md: -------------------------------------------------------------------------------- 1 | - Fixed: [[BUG]: drizzle-seed reset fails without @electric-sql/pglite installed](https://github.com/drizzle-team/drizzle-orm/issues/3603) 2 | - Fixed: [[BUG]: TypeScript type error in drizzle-seed with schema passed to drizzle in IDE](https://github.com/drizzle-team/drizzle-orm/issues/3599) -------------------------------------------------------------------------------- /changelogs/drizzle-typebox/0.1.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-typebox 0.1.0 2 | 3 | - Initial release -------------------------------------------------------------------------------- /changelogs/drizzle-typebox/0.1.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed imports in ESM projects 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-typebox/0.3.0.md: -------------------------------------------------------------------------------- 1 | # Bug fixed and GitHub issue closed 2 | 3 | - [[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs](https://github.com/drizzle-team/drizzle-orm/issues/3732) 4 | - [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869) -------------------------------------------------------------------------------- /changelogs/drizzle-typebox/0.3.1.md: -------------------------------------------------------------------------------- 1 | - Exports all types, including internal ones to avoid type issues. 2 | - Properly handle infinitely recursive types in custom JSON column types. 3 | 4 | thanks @L-Mario564 -------------------------------------------------------------------------------- /changelogs/drizzle-typebox/0.3.2.md: -------------------------------------------------------------------------------- 1 | - Functions `getColumns`, `handleColumns` and `handleEnum` were exported from `drizzle-typebox` -------------------------------------------------------------------------------- /changelogs/drizzle-typebox/0.3.3.md: -------------------------------------------------------------------------------- 1 | - TS language server performance improvements -------------------------------------------------------------------------------- /changelogs/drizzle-valibot/0.1.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-valibot 0.1.0 2 | 3 | - Initial release -------------------------------------------------------------------------------- /changelogs/drizzle-valibot/0.1.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed imports in ESM projects 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-valibot/0.2.0.md: -------------------------------------------------------------------------------- 1 | Use updated types introduced in valibot `0.20.0`: 2 | 3 | - `enumType` -> `picklist` 4 | - `nullType` -> `null_` 5 | 6 | Minimum supported valibot version is now `0.20.0`. 7 | -------------------------------------------------------------------------------- /changelogs/drizzle-valibot/0.4.0.md: -------------------------------------------------------------------------------- 1 | # Bug fixed and GitHub issue closed 2 | 3 | - [[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs](https://github.com/drizzle-team/drizzle-orm/issues/3732) 4 | - [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869) -------------------------------------------------------------------------------- /changelogs/drizzle-valibot/0.4.1.md: -------------------------------------------------------------------------------- 1 | - Exports all types, including internal ones to avoid type issues. 2 | - Properly handle infinitely recursive types in custom JSON column types. 3 | 4 | thanks @L-Mario564 -------------------------------------------------------------------------------- /changelogs/drizzle-valibot/0.4.2.md: -------------------------------------------------------------------------------- 1 | - TS language server performance improvements -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.1.0.md: -------------------------------------------------------------------------------- 1 | # drizzle-zod 0.1.0 2 | 3 | - Initial release 4 | - Added insert schema generation for Postgres 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.1.1.md: -------------------------------------------------------------------------------- 1 | # drizzle-zod 0.1.1 2 | 3 | Internal release 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.1.2.md: -------------------------------------------------------------------------------- 1 | # drizzle-zod 0.1.2 2 | 3 | - Fix peer dependency error for >=0.16 drizzle packages 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.1.3.md: -------------------------------------------------------------------------------- 1 | # drizzle-zod 0.1.3 2 | 3 | - Fix import for 0.17 drizzle-orm -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.1.4.md: -------------------------------------------------------------------------------- 1 | - 🐛 Updated logic for drizzle-orm 0.23.2 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.2.0.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added select schema support 2 | - 🎉 Added SQLite support 3 | - ❗ Changed imports from `drizzle-zod/pg` to `drizzle-zod` for all dialects 4 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.2.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fix insert schemas generation 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.3.0.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added MySQL support 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.3.1.md: -------------------------------------------------------------------------------- 1 | - Fix drizzle-zod default refine type in [479](https://github.com/drizzle-team/drizzle-orm/pull/479) - thanks @hugo-clemente ❤️ -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.3.2.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed a bug in schema types inference 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.4.0.md: -------------------------------------------------------------------------------- 1 | # ESM support 2 | 3 | - 🎉 Added ESM support! You can now use `drizzle-zod` in both ESM and CJS environments. 4 | - 🎉 Added code minification and source maps. 5 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.4.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Add "exports" field to package.json 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.4.2.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed autoincrement columns not being optional in drizzle-zod (#652) 2 | - 🐛 Added length check for text fields in drizzle-zod (#658) 3 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.4.3.md: -------------------------------------------------------------------------------- 1 | - 🎉 Added PgDateString to drizzle-zod (#665) 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.4.4.md: -------------------------------------------------------------------------------- 1 | - Fixed drizzle-zod not enforcing string lengths (#691) by @TiltedToast 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.5.0.md: -------------------------------------------------------------------------------- 1 | - Added compatibility with Drizzle 0.28.0 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.5.1.md: -------------------------------------------------------------------------------- 1 | - 🐛 Fixed imports in ESM projects 2 | -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.7.1.md: -------------------------------------------------------------------------------- 1 | ### Bug fixes 2 | 3 | - [[BUG]: createInsertSchema from drizzle-zod@0.6.1 does not infer types correctly but returns unknown for every value](https://github.com/drizzle-team/drizzle-orm/issues/3907) 4 | - [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869) 5 | 6 | thanks @L-Mario564 -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.8.0.md: -------------------------------------------------------------------------------- 1 | - Support for Zod v4: Starting with this release, `drizzle-zod` now requires Zod v3.25 or later -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.8.1.md: -------------------------------------------------------------------------------- 1 | - Support for Zod v4: Starting with this release, `drizzle-zod` now requires Zod v3.25.1 or later 2 | 3 | This version was released to resolve several compatibility issues with the `ZodObject` type, which were fixed in `drizzle-orm@0.8.1`, so version `0.8.0` can be skipped -------------------------------------------------------------------------------- /changelogs/drizzle-zod/0.8.2.md: -------------------------------------------------------------------------------- 1 | - [[BUG]: drizzle-zod: incorrect inferred types for columns .generatedAlwaysAsIdentity()](https://github.com/drizzle-team/drizzle-orm/issues/4553) -------------------------------------------------------------------------------- /changelogs/eslint-plugin-drizzle/0.2.0.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-drizzle 0.1.0 2 | 3 | - Initial release 4 | - 2 rules available 5 | -------------------------------------------------------------------------------- /changelogs/eslint-plugin-drizzle/0.2.1.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-drizzle 0.2.1 2 | 3 | - Update README.md 4 | - Change error text message -------------------------------------------------------------------------------- /changelogs/eslint-plugin-drizzle/0.2.2.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-drizzle 0.2.2 2 | 3 | - fix: Correct detection of `drizzleObjectName` when it's a nested object 4 | -------------------------------------------------------------------------------- /changelogs/eslint-plugin-drizzle/0.2.3.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-drizzle 0.2.3 2 | 3 | - Added better context to the suggestion in the error message 4 | - fix: Correct detection of `drizzleObjectName` when it's retrieved from or is a function 5 | - chore: Refactored duplicate code in `utils/options.ts` into `isDrizzleObjName` function -------------------------------------------------------------------------------- /changelogs/media/drop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drizzle-team/drizzle-orm/9865e63f43074f19c31ca1e73850f13224d0d00e/changelogs/media/drop.gif -------------------------------------------------------------------------------- /changelogs/media/introspect_mysql.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drizzle-team/drizzle-orm/9865e63f43074f19c31ca1e73850f13224d0d00e/changelogs/media/introspect_mysql.gif -------------------------------------------------------------------------------- /changelogs/media/up_mysql.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drizzle-team/drizzle-orm/9865e63f43074f19c31ca1e73850f13224d0d00e/changelogs/media/up_mysql.gif -------------------------------------------------------------------------------- /docs/table-introspect-api.md: -------------------------------------------------------------------------------- 1 | # Table introspect API 2 | 3 | ## Get table information 4 | 5 | ```ts 6 | import { pgTable, getTableConfig } from 'drizzle-orm/pg-core'; 7 | 8 | const table = pgTable(...); 9 | 10 | const { 11 | columns, 12 | indexes, 13 | foreignKeys, 14 | checks, 15 | primaryKeys, 16 | name, 17 | schema, 18 | } = getTableConfig(table); 19 | ``` 20 | 21 | ## Get table columns map 22 | 23 | ```ts 24 | import { pgTable, getTableColumns } from 'drizzle-orm/pg-core'; 25 | 26 | const table = pgTable('table', { 27 | id: integer('id').primaryKey(), 28 | name: text('name'), 29 | }); 30 | 31 | const columns/*: { id: ..., name: ... } */ = getTableColumns(table); 32 | ``` 33 | -------------------------------------------------------------------------------- /dprint.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript": { 3 | "useTabs": true, 4 | "quoteStyle": "preferSingle", 5 | "quoteProps": "asNeeded", 6 | "arrowFunction.useParentheses": "force", 7 | "jsx.quoteStyle": "preferSingle" 8 | }, 9 | "json": { 10 | "useTabs": true 11 | }, 12 | "markdown": {}, 13 | "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json}"], 14 | "excludes": [ 15 | "**/node_modules", 16 | "dist", 17 | "dist-dts", 18 | "dist.new", 19 | "**/drizzle/**/meta", 20 | "**/drizzle2/**/meta", 21 | "**/*snapshot.json", 22 | "**/_journal.json", 23 | "**/tsup.config*.mjs", 24 | "**/.sst", 25 | "integration-tests/tests/prisma/*/client", 26 | "integration-tests/tests/prisma/*/drizzle" 27 | ], 28 | "plugins": [ 29 | "https://plugins.dprint.dev/typescript-0.91.1.wasm", 30 | "https://plugins.dprint.dev/json-0.19.3.wasm", 31 | "https://plugins.dprint.dev/markdown-0.17.1.wasm" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /drizzle-arktype/benchmarks/types.ts: -------------------------------------------------------------------------------- 1 | import { bench, setup } from '@ark/attest'; 2 | import { type } from 'arktype'; 3 | import { boolean, integer, pgTable, text } from 'drizzle-orm/pg-core'; 4 | import { createSelectSchema } from '~/index.ts'; 5 | 6 | const users = pgTable('users', { 7 | id: integer().primaryKey(), 8 | firstName: text().notNull(), 9 | middleName: text(), 10 | lastName: text().notNull(), 11 | age: integer().notNull(), 12 | admin: boolean().notNull().default(false), 13 | }); 14 | 15 | const teardown = setup(); 16 | 17 | bench('select schema', () => { 18 | return createSelectSchema(users); 19 | }).types([13129, 'instantiations']); 20 | 21 | bench('select schema with refinements', () => { 22 | return createSelectSchema(users, { 23 | firstName: (t) => t.atMostLength(100), 24 | middleName: (t) => t.atMostLength(100), 25 | lastName: (t) => t.atMostLength(100), 26 | age: type.number.atLeast(1), 27 | }); 28 | }).types([21631, 'instantiations']); 29 | 30 | teardown(); 31 | -------------------------------------------------------------------------------- /drizzle-arktype/rollup.config.ts: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { defineConfig } from 'rollup'; 3 | 4 | export default defineConfig([ 5 | { 6 | input: 'src/index.ts', 7 | output: [ 8 | { 9 | format: 'esm', 10 | dir: 'dist', 11 | entryFileNames: '[name].mjs', 12 | chunkFileNames: '[name]-[hash].mjs', 13 | sourcemap: true, 14 | }, 15 | { 16 | format: 'cjs', 17 | dir: 'dist', 18 | entryFileNames: '[name].cjs', 19 | chunkFileNames: '[name]-[hash].cjs', 20 | sourcemap: true, 21 | }, 22 | ], 23 | external: [ 24 | /^drizzle-orm\/?/, 25 | 'arktype', 26 | ], 27 | plugins: [ 28 | typescript({ 29 | tsconfig: 'tsconfig.build.json', 30 | }), 31 | ], 32 | }, 33 | ]); 34 | -------------------------------------------------------------------------------- /drizzle-arktype/scripts/build.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S pnpm tsx 2 | import 'zx/globals'; 3 | import cpy from 'cpy'; 4 | 5 | await fs.remove('dist'); 6 | await $`rollup --config rollup.config.ts --configPlugin typescript`; 7 | await $`resolve-tspaths`; 8 | await fs.copy('README.md', 'dist/README.md'); 9 | await cpy('dist/**/*.d.ts', 'dist', { 10 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'), 11 | }); 12 | await cpy('dist/**/*.d.ts', 'dist', { 13 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'), 14 | }); 15 | await fs.copy('package.json', 'dist/package.json'); 16 | await $`scripts/fix-imports.ts`; 17 | -------------------------------------------------------------------------------- /drizzle-arktype/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const CONSTANTS = { 2 | INT8_MIN: -128, 3 | INT8_MAX: 127, 4 | INT8_UNSIGNED_MAX: 255, 5 | INT16_MIN: -32768, 6 | INT16_MAX: 32767, 7 | INT16_UNSIGNED_MAX: 65535, 8 | INT24_MIN: -8388608, 9 | INT24_MAX: 8388607, 10 | INT24_UNSIGNED_MAX: 16777215, 11 | INT32_MIN: -2147483648, 12 | INT32_MAX: 2147483647, 13 | INT32_UNSIGNED_MAX: 4294967295, 14 | INT48_MIN: -140737488355328, 15 | INT48_MAX: 140737488355327, 16 | INT48_UNSIGNED_MAX: 281474976710655, 17 | INT64_MIN: -9223372036854775808n, 18 | INT64_MAX: 9223372036854775807n, 19 | INT64_UNSIGNED_MAX: 18446744073709551615n, 20 | }; 21 | -------------------------------------------------------------------------------- /drizzle-arktype/src/index.ts: -------------------------------------------------------------------------------- 1 | export { bufferSchema, jsonSchema, literalSchema } from './column.ts'; 2 | export * from './column.types.ts'; 3 | export * from './schema.ts'; 4 | export * from './schema.types.internal.ts'; 5 | export * from './schema.types.ts'; 6 | export * from './utils.ts'; 7 | -------------------------------------------------------------------------------- /drizzle-arktype/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "esnext", 5 | "target": "esnext", 6 | "noEmit": true, 7 | "rootDir": "..", 8 | "outDir": "./.cache" 9 | }, 10 | "include": [".", "../src"] 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-arktype/tests/utils.ts: -------------------------------------------------------------------------------- 1 | import { Type } from 'arktype'; 2 | import { expect, type TaskContext } from 'vitest'; 3 | 4 | export function expectSchemaShape>(t: TaskContext, expected: T) { 5 | return { 6 | from(actual: T) { 7 | expect(actual.json).toStrictEqual(expected.json); 8 | expect(actual.expression).toStrictEqual(expected.expression); 9 | }, 10 | }; 11 | } 12 | 13 | export const expectEnumValues = expectSchemaShape; 14 | 15 | export function Expect<_ extends true>() {} 16 | -------------------------------------------------------------------------------- /drizzle-arktype/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src" 5 | }, 6 | "include": ["src"] 7 | } 8 | -------------------------------------------------------------------------------- /drizzle-arktype/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "baseUrl": ".", 6 | "declaration": true, 7 | "noEmit": true, 8 | "paths": { 9 | "~/*": ["src/*"] 10 | } 11 | }, 12 | "include": ["src", "*.ts", "benchmarks"] 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-arktype/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import tsconfigPaths from 'vite-tsconfig-paths'; 2 | import { defineConfig } from 'vitest/config'; 3 | 4 | export default defineConfig({ 5 | test: { 6 | include: [ 7 | 'tests/**/*.test.ts', 8 | ], 9 | exclude: [ 10 | 'tests/bun/**/*', 11 | ], 12 | typecheck: { 13 | tsconfig: 'tsconfig.json', 14 | }, 15 | testTimeout: 100000, 16 | hookTimeout: 100000, 17 | isolate: false, 18 | poolOptions: { 19 | threads: { 20 | singleThread: true, 21 | }, 22 | }, 23 | }, 24 | plugins: [tsconfigPaths()], 25 | }); 26 | -------------------------------------------------------------------------------- /drizzle-kit/.gitignore: -------------------------------------------------------------------------------- 1 | /* 2 | **/.DS_Store 3 | 4 | !src 5 | !imports-checker 6 | !tests 7 | !vitest.config.ts 8 | !README.md 9 | !CONTRIBUTING.md 10 | !schema.ts 11 | 12 | !.eslint 13 | !.gitignore 14 | !package.json 15 | !tsconfig.json 16 | !tsconfig.cli-types.json 17 | !tsconfig.build.json 18 | !pnpm-lock.yaml 19 | !.github 20 | !build.ts 21 | !build.dev.ts 22 | 23 | tests/test.ts 24 | 25 | !patches 26 | -------------------------------------------------------------------------------- /drizzle-kit/src/cli/commands/_es5.ts: -------------------------------------------------------------------------------- 1 | const _ = ''; 2 | export default _; 3 | -------------------------------------------------------------------------------- /drizzle-kit/src/cli/commands/singlestoreUp.ts: -------------------------------------------------------------------------------- 1 | export const upSinglestoreHandler = (out: string) => {}; 2 | -------------------------------------------------------------------------------- /drizzle-kit/src/cli/validations/libsql.ts: -------------------------------------------------------------------------------- 1 | import { softAssertUnreachable } from 'src/global'; 2 | import { object, string, TypeOf } from 'zod'; 3 | import { error } from '../views'; 4 | import { wrapParam } from './common'; 5 | 6 | export const libSQLCredentials = object({ 7 | url: string().min(1), 8 | authToken: string().min(1).optional(), 9 | }); 10 | 11 | export type LibSQLCredentials = { 12 | url: string; 13 | authToken?: string; 14 | }; 15 | 16 | const _: LibSQLCredentials = {} as TypeOf; 17 | 18 | export const printConfigConnectionIssues = ( 19 | options: Record, 20 | command: 'generate' | 'migrate' | 'push' | 'pull' | 'studio', 21 | ) => { 22 | let text = `Please provide required params for 'turso' dialect:\n`; 23 | console.log(error(text)); 24 | console.log(wrapParam('url', options.url)); 25 | console.log(wrapParam('authToken', options.authToken, true, 'secret')); 26 | process.exit(1); 27 | }; 28 | -------------------------------------------------------------------------------- /drizzle-kit/src/cli/validations/studio.ts: -------------------------------------------------------------------------------- 1 | import { coerce, intersection, object, string, TypeOf, union } from 'zod'; 2 | import { dialect } from '../../schemaValidator'; 3 | import { mysqlCredentials } from './mysql'; 4 | import { postgresCredentials } from './postgres'; 5 | import { sqliteCredentials } from './sqlite'; 6 | 7 | export const credentials = intersection( 8 | postgresCredentials, 9 | mysqlCredentials, 10 | sqliteCredentials, 11 | ); 12 | 13 | export type Credentials = TypeOf; 14 | 15 | export const studioCliParams = object({ 16 | port: coerce.number().optional().default(4983), 17 | host: string().optional().default('127.0.0.1'), 18 | config: string().optional(), 19 | }); 20 | 21 | export const studioConfig = object({ 22 | dialect, 23 | schema: union([string(), string().array()]).optional(), 24 | }); 25 | -------------------------------------------------------------------------------- /drizzle-kit/src/extensions/getTablesFilterByExtensions.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '../index'; 2 | 3 | export const getTablesFilterByExtensions = ({ 4 | extensionsFilters, 5 | dialect, 6 | }: Pick): string[] => { 7 | if (extensionsFilters) { 8 | if ( 9 | extensionsFilters.includes('postgis') 10 | && dialect === 'postgresql' 11 | ) { 12 | return ['!geography_columns', '!geometry_columns', '!spatial_ref_sys']; 13 | } 14 | } 15 | return []; 16 | }; 17 | -------------------------------------------------------------------------------- /drizzle-kit/src/extensions/vector.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 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/d1http.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'sqlite', 6 | driver: 'd1-http', 7 | dbCredentials: { 8 | accountId: 'accid', 9 | databaseId: 'dbid', 10 | token: 'token', 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/drizzle.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'postgresql', 6 | dbCredentials: { 7 | url: 'postgresql://postgres:postgres@127.0.0.1:5432/db', 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/durable-sqlite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'sqlite', 6 | driver: 'durable-sqlite', 7 | }); 8 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/expo.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'sqlite', 6 | driver: 'expo', 7 | }); 8 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/postgres.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'postgresql', 6 | dbCredentials: { 7 | host: '127.0.0.1', 8 | port: 5432, 9 | user: 'postgresql', 10 | password: 'postgres', 11 | database: 'db', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/postgres2.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'postgresql', 6 | dbCredentials: { 7 | host: '127.0.0.1', 8 | port: 5432, 9 | user: 'postgresql', 10 | password: 'postgres', 11 | database: 'db', 12 | }, 13 | migrations: { 14 | schema: 'custom', 15 | table: 'custom', 16 | }, 17 | }); 18 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/schema.ts: -------------------------------------------------------------------------------- 1 | // mock 2 | -------------------------------------------------------------------------------- /drizzle-kit/tests/cli/turso.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '../../src'; 2 | 3 | export default defineConfig({ 4 | schema: './schema.ts', 5 | dialect: 'turso', 6 | dbCredentials: { 7 | url: 'turso.dev', 8 | authToken: 'token', 9 | }, 10 | }); 11 | -------------------------------------------------------------------------------- /drizzle-kit/tests/common.ts: -------------------------------------------------------------------------------- 1 | import { test } from 'vitest'; 2 | 3 | export interface DialectSuite { 4 | /** 5 | * 1 statement | create column: 6 | * 7 | * id int primary key autoincrement 8 | */ 9 | columns1(): Promise; 10 | } 11 | 12 | export const run = (suite: DialectSuite) => { 13 | test('add columns #1', suite.columns1); 14 | }; 15 | // test("add columns #1", suite.columns1) 16 | -------------------------------------------------------------------------------- /drizzle-kit/tests/indexes/common.ts: -------------------------------------------------------------------------------- 1 | import { afterAll, beforeAll, test } from 'vitest'; 2 | 3 | export interface DialectSuite { 4 | simpleIndex(context?: any): Promise; 5 | vectorIndex(context?: any): Promise; 6 | indexesToBeTriggered(context?: any): Promise; 7 | } 8 | 9 | export const run = ( 10 | suite: DialectSuite, 11 | beforeAllFn?: (context: any) => Promise, 12 | afterAllFn?: (context: any) => Promise, 13 | ) => { 14 | let context: any = {}; 15 | beforeAll(beforeAllFn ? () => beforeAllFn(context) : () => {}); 16 | test('index #1: simple index', () => suite.simpleIndex(context)); 17 | test('index #2: vector index', () => suite.vectorIndex(context)); 18 | test('index #3: fields that should be triggered on generate and not triggered on push', () => 19 | suite.indexesToBeTriggered(context)); 20 | afterAll(afterAllFn ? () => afterAllFn(context) : () => {}); 21 | }; 22 | -------------------------------------------------------------------------------- /drizzle-kit/tests/migrate/libsq-schema.ts: -------------------------------------------------------------------------------- 1 | import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; 2 | 3 | export const users = sqliteTable('users', { 4 | id: integer('id').primaryKey().notNull(), 5 | name: text('name').notNull(), 6 | }); 7 | -------------------------------------------------------------------------------- /drizzle-kit/tests/migrate/migrations/0000_little_blizzard.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `users` ( 2 | `id` integer PRIMARY KEY NOT NULL, 3 | `name` text NOT NULL 4 | ); 5 | -------------------------------------------------------------------------------- /drizzle-kit/tests/migrate/migrations/0001_nebulous_storm.sql: -------------------------------------------------------------------------------- 1 | PRAGMA foreign_keys=OFF;--> statement-breakpoint 2 | CREATE TABLE `__new_users` ( 3 | `id` integer, 4 | `name` integer NOT NULL 5 | ); 6 | --> statement-breakpoint 7 | INSERT INTO `__new_users`("id", "name") SELECT "id", "name" FROM `users`;--> statement-breakpoint 8 | DROP TABLE `users`;--> statement-breakpoint 9 | ALTER TABLE `__new_users` RENAME TO `users`;--> statement-breakpoint 10 | PRAGMA foreign_keys=ON; -------------------------------------------------------------------------------- /drizzle-kit/tests/migrate/migrations/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "7", 3 | "dialect": "sqlite", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "6", 8 | "when": 1725358702427, 9 | "tag": "0000_little_blizzard", 10 | "breakpoints": true 11 | }, 12 | { 13 | "idx": 1, 14 | "version": "6", 15 | "when": 1725358713033, 16 | "tag": "0001_nebulous_storm", 17 | "breakpoints": true 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /drizzle-kit/tests/testsinglestore.ts: -------------------------------------------------------------------------------- 1 | import { index, singlestoreTable, text } from 'drizzle-orm/singlestore-core'; 2 | import { diffTestSchemasSingleStore } from './schemaDiffer'; 3 | 4 | const from = { 5 | users: singlestoreTable( 6 | 'table', 7 | { 8 | name: text('name'), 9 | }, 10 | (t) => { 11 | return { 12 | idx: index('name_idx').on(t.name), 13 | }; 14 | }, 15 | ), 16 | }; 17 | 18 | const to = { 19 | users: singlestoreTable('table', { 20 | name: text('name'), 21 | }), 22 | }; 23 | 24 | diffTestSchemasSingleStore(from, to, []).then((res) => { 25 | const { statements, sqlStatements } = res; 26 | 27 | console.log(statements); 28 | console.log(sqlStatements); 29 | }); 30 | -------------------------------------------------------------------------------- /drizzle-kit/tests/wrap-param.test.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import { assert, expect, test } from 'vitest'; 3 | import { wrapParam } from '../src/cli/validations/common'; 4 | 5 | test('wrapParam', () => { 6 | expect(wrapParam('password', 'password123', false, 'secret')).toBe(` [${chalk.green('✓')}] password: '*****'`); 7 | expect(wrapParam('url', 'mysql://user:password@localhost:3306/database', false, 'url')).toBe( 8 | ` [${chalk.green('✓')}] url: 'mysql://user:****@localhost:3306/database'`, 9 | ); 10 | expect(wrapParam('url', 'singlestore://user:password@localhost:3306/database', false, 'url')).toBe( 11 | ` [${chalk.green('✓')}] url: 'singlestore://user:****@localhost:3306/database'`, 12 | ); 13 | expect(wrapParam('url', 'postgresql://user:password@localhost:5432/database', false, 'url')).toBe( 14 | ` [${chalk.green('✓')}] url: 'postgresql://user:****@localhost:5432/database'`, 15 | ); 16 | }); 17 | -------------------------------------------------------------------------------- /drizzle-kit/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /drizzle-kit/tsconfig.cli-types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": true, 5 | "emitDeclarationOnly": true, 6 | "noEmit": false 7 | }, 8 | "include": ["src/index.ts", "src/utils.ts", "src/utils-studio.ts", "src/api.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /drizzle-kit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "lib": ["es2021"], 5 | "types": ["node"], 6 | "strictNullChecks": true, 7 | "strictFunctionTypes": false, 8 | "allowJs": true, 9 | "skipLibCheck": true, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "strict": true, 13 | "noImplicitOverride": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "CommonJS", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "noErrorTruncation": true, 19 | "isolatedModules": true, 20 | "sourceMap": true, 21 | "baseUrl": ".", 22 | "outDir": "dist", 23 | "noEmit": true, 24 | "typeRoots": ["node_modules/@types", "src/@types"] 25 | }, 26 | "include": ["src", "dev", "tests", "drizzle.config.ts", "test.ts"], 27 | "exclude": ["node_modules"] 28 | } 29 | -------------------------------------------------------------------------------- /drizzle-kit/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import tsconfigPaths from 'vite-tsconfig-paths'; 2 | import { defineConfig } from 'vitest/config'; 3 | 4 | export default defineConfig({ 5 | test: { 6 | include: [ 7 | 'tests/**/*.test.ts', 8 | // Need to test it first before pushing changes 9 | // 'tests/singlestore-schemas.test.ts', 10 | // 'tests/singlestore-views.test.ts', 11 | // 'tests/push/singlestore-push.test.ts', 12 | // 'tests/push/singlestore.test.ts', 13 | ], 14 | 15 | // This one was excluded because we need to modify an API for SingleStore-generated columns. 16 | // It’s in the backlog. 17 | exclude: ['tests/**/singlestore-generated.test.ts'], 18 | 19 | typecheck: { 20 | tsconfig: 'tsconfig.json', 21 | }, 22 | testTimeout: 100000, 23 | hookTimeout: 100000, 24 | isolate: true, 25 | poolOptions: { 26 | threads: { 27 | singleThread: true, 28 | }, 29 | }, 30 | maxWorkers: 1, 31 | fileParallelism: false, 32 | }, 33 | plugins: [tsconfigPaths()], 34 | }); 35 | -------------------------------------------------------------------------------- /drizzle-orm/.madgerc: -------------------------------------------------------------------------------- 1 | { 2 | "detectiveOptions": { 3 | "ts": { 4 | "skipTypeImports": true 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /drizzle-orm/src/aws-data-api/pg/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/aws-data-api/pg/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { AwsDataApiPgDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: AwsDataApiPgDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/batch.ts: -------------------------------------------------------------------------------- 1 | import type { Dialect } from './column-builder.ts'; 2 | import type { RunnableQuery } from './runnable-query.ts'; 3 | 4 | export type BatchItem = RunnableQuery; 5 | 6 | export type BatchResponse = { 7 | [K in keyof T]: T[K]['_']['result']; 8 | }; 9 | -------------------------------------------------------------------------------- /drizzle-orm/src/better-sqlite3/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/better-sqlite3/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { BetterSQLite3Database } from './driver.ts'; 4 | 5 | export function migrate>( 6 | db: BetterSQLite3Database, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/bun-sql/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/bun-sql/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { BunSQLDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: BunSQLDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/bun-sqlite/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/bun-sqlite/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { BunSQLiteDatabase } from './driver.ts'; 4 | 5 | export function migrate>( 6 | db: BunSQLiteDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/cache/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cache.ts'; 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/cache/core/types.ts: -------------------------------------------------------------------------------- 1 | export type CacheConfig = { 2 | /** 3 | * expire time, in seconds (a positive integer) 4 | */ 5 | ex?: number; 6 | /** 7 | * expire time, in milliseconds (a positive integer). 8 | */ 9 | px?: number; 10 | /** 11 | * Unix time at which the key will expire, in seconds (a positive integer). 12 | */ 13 | exat?: number; 14 | /** 15 | * Unix time at which the key will expire, in milliseconds (a positive integer) 16 | */ 17 | pxat?: number; 18 | /** 19 | * Retain the time to live associated with the key. 20 | */ 21 | keepTtl?: boolean; 22 | /** 23 | * Set an expiration (TTL or time to live) on one or more fields of a given hash key. 24 | * Used for HEXPIRE command 25 | */ 26 | hexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt'; 27 | }; 28 | 29 | export type WithCacheConfig = { enable: boolean; config?: CacheConfig; tag?: string; autoInvalidate?: boolean }; 30 | -------------------------------------------------------------------------------- /drizzle-orm/src/cache/upstash/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cache.ts'; 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/d1/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/durable-sqlite/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/errors.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | 3 | export class DrizzleError extends Error { 4 | static readonly [entityKind]: string = 'DrizzleError'; 5 | 6 | constructor({ message, cause }: { message?: string; cause?: unknown }) { 7 | super(message); 8 | this.name = 'DrizzleError'; 9 | this.cause = cause; 10 | } 11 | } 12 | 13 | export class TransactionRollbackError extends DrizzleError { 14 | static override readonly [entityKind]: string = 'TransactionRollbackError'; 15 | 16 | constructor() { 17 | super({ message: 'Rollback' }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /drizzle-orm/src/errors/index.ts: -------------------------------------------------------------------------------- 1 | export class DrizzleQueryError extends Error { 2 | constructor( 3 | public query: string, 4 | public params: any[], 5 | public override cause?: Error, 6 | ) { 7 | super(`Failed query: ${query}\nparams: ${params}`); 8 | Error.captureStackTrace(this, DrizzleQueryError); 9 | 10 | // ES2022+: preserves original error on `.cause` 11 | if (cause) (this as any).cause = cause; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-orm/src/expo-sqlite/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './query.ts'; 3 | export * from './session.ts'; 4 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/alias.ts: -------------------------------------------------------------------------------- 1 | import { TableAliasProxyHandler } from '~/alias.ts'; 2 | import type { BuildAliasTable } from './query-builders/select.types.ts'; 3 | 4 | import type { GelTable } from './table.ts'; 5 | import type { GelViewBase } from './view-base.ts'; 6 | 7 | export function alias( 8 | table: TTable, 9 | alias: TAlias, 10 | ): BuildAliasTable { 11 | return new Proxy(table, new TableAliasProxyHandler(alias, false)) as any; 12 | } 13 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/checks.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { SQL } from '~/sql/index.ts'; 3 | import type { GelTable } from './table.ts'; 4 | 5 | export class CheckBuilder { 6 | static readonly [entityKind]: string = 'GelCheckBuilder'; 7 | 8 | protected brand!: 'GelConstraintBuilder'; 9 | 10 | constructor(public name: string, public value: SQL) {} 11 | 12 | /** @internal */ 13 | build(table: GelTable): Check { 14 | return new Check(table, this); 15 | } 16 | } 17 | 18 | export class Check { 19 | static readonly [entityKind]: string = 'GelCheck'; 20 | 21 | readonly name: string; 22 | readonly value: SQL; 23 | 24 | constructor(public table: GelTable, builder: CheckBuilder) { 25 | this.name = builder.name; 26 | this.value = builder.value; 27 | } 28 | } 29 | 30 | export function check(name: string, value: SQL): CheckBuilder { 31 | return new CheckBuilder(name, value); 32 | } 33 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/columns/date.common.ts: -------------------------------------------------------------------------------- 1 | import type { ColumnBuilderBaseConfig, ColumnDataType } from '~/column-builder.ts'; 2 | import { entityKind } from '~/entity.ts'; 3 | import { sql } from '~/sql/sql.ts'; 4 | import { GelColumnBuilder } from './common.ts'; 5 | 6 | export abstract class GelLocalDateColumnBaseBuilder< 7 | T extends ColumnBuilderBaseConfig, 8 | TRuntimeConfig extends object = object, 9 | > extends GelColumnBuilder { 10 | static override readonly [entityKind]: string = 'GelLocalDateColumnBaseBuilder'; 11 | 12 | defaultNow() { 13 | return this.default(sql`now()`); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/columns/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bigint.ts'; 2 | export * from './bigintT.ts'; 3 | export * from './boolean.ts'; 4 | export * from './bytes.ts'; 5 | export * from './common.ts'; 6 | export * from './custom.ts'; 7 | export * from './date-duration.ts'; 8 | export * from './decimal.ts'; 9 | export * from './double-precision.ts'; 10 | export * from './duration.ts'; 11 | export * from './int.common.ts'; 12 | export * from './integer.ts'; 13 | export * from './json.ts'; 14 | export * from './localdate.ts'; 15 | export * from './localtime.ts'; 16 | export * from './real.ts'; 17 | export * from './relative-duration.ts'; 18 | export * from './smallint.ts'; 19 | export * from './text.ts'; 20 | export * from './timestamp.ts'; 21 | export * from './timestamptz.ts'; 22 | export * from './uuid.ts'; 23 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/expressions.ts: -------------------------------------------------------------------------------- 1 | import type { GelColumn } from '~/gel-core/columns/index.ts'; 2 | import { bindIfParam } from '~/sql/expressions/index.ts'; 3 | import type { Placeholder, SQL, SQLChunk, SQLWrapper } from '~/sql/sql.ts'; 4 | import { sql } from '~/sql/sql.ts'; 5 | 6 | export * from '~/sql/expressions/index.ts'; 7 | 8 | export function concat(column: GelColumn | SQL.Aliased, value: string | Placeholder | SQLWrapper): SQL { 9 | return sql`${column} || ${bindIfParam(value, column)}`; 10 | } 11 | 12 | export function substring( 13 | column: GelColumn | SQL.Aliased, 14 | { from, for: _for }: { from?: number | Placeholder | SQLWrapper; for?: number | Placeholder | SQLWrapper }, 15 | ): SQL { 16 | const chunks: SQLChunk[] = [sql`substring(`, column]; 17 | if (from !== undefined) { 18 | chunks.push(sql` from `, bindIfParam(from, column)); 19 | } 20 | if (_for !== undefined) { 21 | chunks.push(sql` for `, bindIfParam(_for, column)); 22 | } 23 | chunks.push(sql`)`); 24 | return sql.join(chunks); 25 | } 26 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alias.ts'; 2 | export * from './checks.ts'; 3 | export * from './columns/index.ts'; 4 | export * from './db.ts'; 5 | export * from './dialect.ts'; 6 | export * from './foreign-keys.ts'; 7 | export * from './indexes.ts'; 8 | export * from './policies.ts'; 9 | export * from './primary-keys.ts'; 10 | export * from './query-builders/index.ts'; 11 | export * from './roles.ts'; 12 | export * from './schema.ts'; 13 | export * from './sequence.ts'; 14 | export * from './session.ts'; 15 | export * from './subquery.ts'; 16 | export * from './table.ts'; 17 | export * from './unique-constraint.ts'; 18 | export * from './utils.ts'; 19 | export * from './view-common.ts'; 20 | export * from './view.ts'; 21 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/query-builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete.ts'; 2 | export * from './insert.ts'; 3 | export * from './query-builder.ts'; 4 | export * from './refresh-materialized-view.ts'; 5 | export * from './select.ts'; 6 | export * from './select.types.ts'; 7 | export * from './update.ts'; 8 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/subquery.ts: -------------------------------------------------------------------------------- 1 | import type { AddAliasToSelection } from '~/query-builders/select.types.ts'; 2 | import type { ColumnsSelection } from '~/sql/sql.ts'; 3 | import type { Subquery, WithSubquery } from '~/subquery.ts'; 4 | 5 | export type SubqueryWithSelection = 6 | & Subquery> 7 | & AddAliasToSelection; 8 | 9 | export type WithSubqueryWithSelection = 10 | & WithSubquery> 11 | & AddAliasToSelection; 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/view-base.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import { type ColumnsSelection, View } from '~/sql/sql.ts'; 3 | 4 | export abstract class GelViewBase< 5 | TName extends string = string, 6 | TExisting extends boolean = boolean, 7 | TSelectedFields extends ColumnsSelection = ColumnsSelection, 8 | > extends View { 9 | static override readonly [entityKind]: string = 'GelViewBase'; 10 | 11 | declare readonly _: View['_'] & { 12 | readonly viewBrand: 'GelViewBase'; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel-core/view-common.ts: -------------------------------------------------------------------------------- 1 | export const GelViewConfig = Symbol.for('drizzle:GelViewConfig'); 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/gel/migrator.ts: -------------------------------------------------------------------------------- 1 | // import type { MigrationConfig } from '~/migrator.ts'; 2 | // import { readMigrationFiles } from '~/migrator.ts'; 3 | // import type { GelJsDatabase } from './driver.ts'; 4 | 5 | // not supported 6 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 7 | async function migrate>( 8 | // db: GelJsDatabase, 9 | // config: MigrationConfig, 10 | ) { 11 | return {}; 12 | // const migrations = readMigrationFiles(config); 13 | // await db.dialect.migrate(migrations, db.session, config); 14 | } 15 | -------------------------------------------------------------------------------- /drizzle-orm/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alias.ts'; 2 | export * from './column-builder.ts'; 3 | export * from './column.ts'; 4 | export * from './entity.ts'; 5 | export * from './errors.ts'; 6 | export * from './logger.ts'; 7 | export * from './operations.ts'; 8 | export * from './query-promise.ts'; 9 | export * from './relations.ts'; 10 | export * from './sql/index.ts'; 11 | export * from './subquery.ts'; 12 | export * from './table.ts'; 13 | export * from './utils.ts'; 14 | export * from './view-common.ts'; 15 | -------------------------------------------------------------------------------- /drizzle-orm/src/knex/index.ts: -------------------------------------------------------------------------------- 1 | import type { Knex as KnexType } from 'knex'; 2 | import type { InferInsertModel, InferSelectModel, Table } from '~/table.ts'; 3 | 4 | declare module 'knex/types/tables.ts' { 5 | export type Knexify = 6 | & KnexType.CompositeTableType< 7 | InferSelectModel, 8 | InferInsertModel 9 | > 10 | & {}; 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/libsql/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/alias.ts: -------------------------------------------------------------------------------- 1 | import { TableAliasProxyHandler } from '~/alias.ts'; 2 | import type { BuildAliasTable } from './query-builders/select.types.ts'; 3 | import type { MySqlTable } from './table.ts'; 4 | import type { MySqlViewBase } from './view-base.ts'; 5 | 6 | export function alias( 7 | table: TTable, 8 | alias: TAlias, 9 | ): BuildAliasTable { 10 | return new Proxy(table, new TableAliasProxyHandler(alias, false)) as any; 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/checks.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { SQL } from '~/sql/sql.ts'; 3 | import type { MySqlTable } from './table.ts'; 4 | 5 | export class CheckBuilder { 6 | static readonly [entityKind]: string = 'MySqlCheckBuilder'; 7 | 8 | protected brand!: 'MySqlConstraintBuilder'; 9 | 10 | constructor(public name: string, public value: SQL) {} 11 | 12 | /** @internal */ 13 | build(table: MySqlTable): Check { 14 | return new Check(table, this); 15 | } 16 | } 17 | 18 | export class Check { 19 | static readonly [entityKind]: string = 'MySqlCheck'; 20 | 21 | readonly name: string; 22 | readonly value: SQL; 23 | 24 | constructor(public table: MySqlTable, builder: CheckBuilder) { 25 | this.name = builder.name; 26 | this.value = builder.value; 27 | } 28 | } 29 | 30 | export function check(name: string, value: SQL): CheckBuilder { 31 | return new CheckBuilder(name, value); 32 | } 33 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/columns/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bigint.ts'; 2 | export * from './binary.ts'; 3 | export * from './boolean.ts'; 4 | export * from './char.ts'; 5 | export * from './common.ts'; 6 | export * from './custom.ts'; 7 | export * from './date.ts'; 8 | export * from './datetime.ts'; 9 | export * from './decimal.ts'; 10 | export * from './double.ts'; 11 | export * from './enum.ts'; 12 | export * from './float.ts'; 13 | export * from './int.ts'; 14 | export * from './json.ts'; 15 | export * from './mediumint.ts'; 16 | export * from './real.ts'; 17 | export * from './serial.ts'; 18 | export * from './smallint.ts'; 19 | export * from './text.ts'; 20 | export * from './time.ts'; 21 | export * from './timestamp.ts'; 22 | export * from './tinyint.ts'; 23 | export * from './varbinary.ts'; 24 | export * from './varchar.ts'; 25 | export * from './year.ts'; 26 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alias.ts'; 2 | export * from './checks.ts'; 3 | export * from './columns/index.ts'; 4 | export * from './db.ts'; 5 | export * from './dialect.ts'; 6 | export * from './foreign-keys.ts'; 7 | export * from './indexes.ts'; 8 | export * from './primary-keys.ts'; 9 | export * from './query-builders/index.ts'; 10 | export * from './schema.ts'; 11 | export * from './session.ts'; 12 | export * from './subquery.ts'; 13 | export * from './table.ts'; 14 | export * from './unique-constraint.ts'; 15 | export * from './utils.ts'; 16 | export * from './view-common.ts'; 17 | export * from './view.ts'; 18 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/query-builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete.ts'; 2 | export * from './insert.ts'; 3 | export * from './query-builder.ts'; 4 | export * from './select.ts'; 5 | export * from './select.types.ts'; 6 | export * from './update.ts'; 7 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/view-base.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { ColumnsSelection } from '~/sql/sql.ts'; 3 | import { View } from '~/sql/sql.ts'; 4 | 5 | export abstract class MySqlViewBase< 6 | TName extends string = string, 7 | TExisting extends boolean = boolean, 8 | TSelectedFields extends ColumnsSelection = ColumnsSelection, 9 | > extends View { 10 | static override readonly [entityKind]: string = 'MySqlViewBase'; 11 | 12 | declare readonly _: View['_'] & { 13 | readonly viewBrand: 'MySqlViewBase'; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-core/view-common.ts: -------------------------------------------------------------------------------- 1 | export const MySqlViewConfig = Symbol.for('drizzle:MySqlViewConfig'); 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql-proxy/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql2/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/mysql2/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { MySql2Database } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: MySql2Database, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/neon-http/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/neon-serverless/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/neon-serverless/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { NeonDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: NeonDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/neon/index.ts: -------------------------------------------------------------------------------- 1 | export * from './neon-identity.ts'; 2 | export * from './rls.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/neon/neon-identity.ts: -------------------------------------------------------------------------------- 1 | import { jsonb, pgSchema, text, timestamp } from '~/pg-core/index.ts'; 2 | 3 | const neonAuthSchema = pgSchema('neon_auth'); 4 | 5 | /** 6 | * Table schema of the `users_sync` table used by Neon Auth. 7 | * This table automatically synchronizes and stores user data from external authentication providers. 8 | * 9 | * @schema neon_auth 10 | * @table users_sync 11 | */ 12 | export const usersSync = neonAuthSchema.table('users_sync', { 13 | rawJson: jsonb('raw_json').notNull(), 14 | id: text().primaryKey().notNull(), 15 | name: text(), 16 | email: text(), 17 | createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' }), 18 | deletedAt: timestamp('deleted_at', { withTimezone: true, mode: 'string' }), 19 | }); 20 | -------------------------------------------------------------------------------- /drizzle-orm/src/node-postgres/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/node-postgres/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { NodePgDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: NodePgDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/op-sqlite/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/alias.ts: -------------------------------------------------------------------------------- 1 | import { TableAliasProxyHandler } from '~/alias.ts'; 2 | import type { BuildAliasTable } from './query-builders/select.types.ts'; 3 | 4 | import type { PgTable } from './table.ts'; 5 | import type { PgViewBase } from './view-base.ts'; 6 | 7 | export function alias( 8 | table: TTable, 9 | alias: TAlias, 10 | ): BuildAliasTable { 11 | return new Proxy(table, new TableAliasProxyHandler(alias, false)) as any; 12 | } 13 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/checks.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { SQL } from '~/sql/index.ts'; 3 | import type { PgTable } from './table.ts'; 4 | 5 | export class CheckBuilder { 6 | static readonly [entityKind]: string = 'PgCheckBuilder'; 7 | 8 | protected brand!: 'PgConstraintBuilder'; 9 | 10 | constructor(public name: string, public value: SQL) {} 11 | 12 | /** @internal */ 13 | build(table: PgTable): Check { 14 | return new Check(table, this); 15 | } 16 | } 17 | 18 | export class Check { 19 | static readonly [entityKind]: string = 'PgCheck'; 20 | 21 | readonly name: string; 22 | readonly value: SQL; 23 | 24 | constructor(public table: PgTable, builder: CheckBuilder) { 25 | this.name = builder.name; 26 | this.value = builder.value; 27 | } 28 | } 29 | 30 | export function check(name: string, value: SQL): CheckBuilder { 31 | return new CheckBuilder(name, value); 32 | } 33 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/columns/date.common.ts: -------------------------------------------------------------------------------- 1 | import type { ColumnBuilderBaseConfig, ColumnDataType } from '~/column-builder.ts'; 2 | import { entityKind } from '~/entity.ts'; 3 | import { sql } from '~/sql/sql.ts'; 4 | import { PgColumnBuilder } from './common.ts'; 5 | 6 | export abstract class PgDateColumnBaseBuilder< 7 | T extends ColumnBuilderBaseConfig, 8 | TRuntimeConfig extends object = object, 9 | > extends PgColumnBuilder { 10 | static override readonly [entityKind]: string = 'PgDateColumnBaseBuilder'; 11 | 12 | defaultNow() { 13 | return this.default(sql`now()`); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/expressions.ts: -------------------------------------------------------------------------------- 1 | import type { PgColumn } from '~/pg-core/columns/index.ts'; 2 | import { bindIfParam } from '~/sql/expressions/index.ts'; 3 | import type { Placeholder, SQL, SQLChunk, SQLWrapper } from '~/sql/sql.ts'; 4 | import { sql } from '~/sql/sql.ts'; 5 | 6 | export * from '~/sql/expressions/index.ts'; 7 | 8 | export function concat(column: PgColumn | SQL.Aliased, value: string | Placeholder | SQLWrapper): SQL { 9 | return sql`${column} || ${bindIfParam(value, column)}`; 10 | } 11 | 12 | export function substring( 13 | column: PgColumn | SQL.Aliased, 14 | { from, for: _for }: { from?: number | Placeholder | SQLWrapper; for?: number | Placeholder | SQLWrapper }, 15 | ): SQL { 16 | const chunks: SQLChunk[] = [sql`substring(`, column]; 17 | if (from !== undefined) { 18 | chunks.push(sql` from `, bindIfParam(from, column)); 19 | } 20 | if (_for !== undefined) { 21 | chunks.push(sql` for `, bindIfParam(_for, column)); 22 | } 23 | chunks.push(sql`)`); 24 | return sql.join(chunks); 25 | } 26 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alias.ts'; 2 | export * from './checks.ts'; 3 | export * from './columns/index.ts'; 4 | export * from './db.ts'; 5 | export * from './dialect.ts'; 6 | export * from './foreign-keys.ts'; 7 | export * from './indexes.ts'; 8 | export * from './policies.ts'; 9 | export * from './primary-keys.ts'; 10 | export * from './query-builders/index.ts'; 11 | export * from './roles.ts'; 12 | export * from './schema.ts'; 13 | export * from './sequence.ts'; 14 | export * from './session.ts'; 15 | export * from './subquery.ts'; 16 | export * from './table.ts'; 17 | export * from './unique-constraint.ts'; 18 | export * from './utils.ts'; 19 | export * from './utils/index.ts'; 20 | export * from './view-common.ts'; 21 | export * from './view.ts'; 22 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/query-builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete.ts'; 2 | export * from './insert.ts'; 3 | export * from './query-builder.ts'; 4 | export * from './refresh-materialized-view.ts'; 5 | export * from './select.ts'; 6 | export * from './select.types.ts'; 7 | export * from './update.ts'; 8 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './array.ts'; 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/view-base.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import { type ColumnsSelection, View } from '~/sql/sql.ts'; 3 | 4 | export abstract class PgViewBase< 5 | TName extends string = string, 6 | TExisting extends boolean = boolean, 7 | TSelectedFields extends ColumnsSelection = ColumnsSelection, 8 | > extends View { 9 | static override readonly [entityKind]: string = 'PgViewBase'; 10 | 11 | declare readonly _: View['_'] & { 12 | readonly viewBrand: 'PgViewBase'; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-core/view-common.ts: -------------------------------------------------------------------------------- 1 | export const PgViewConfig = Symbol.for('drizzle:PgViewConfig'); 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/pg-proxy/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/pglite/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/pglite/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { PgliteDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: PgliteDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/planetscale-serverless/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/planetscale-serverless/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { PlanetScaleDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: PlanetScaleDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | 11 | await db.dialect.migrate(migrations, db.session, config); 12 | } 13 | -------------------------------------------------------------------------------- /drizzle-orm/src/postgres-js/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/postgres-js/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { PostgresJsDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: PostgresJsDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/primary-key.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { AnyColumn } from './column.ts'; 3 | import type { Table } from './table.ts'; 4 | 5 | export abstract class PrimaryKey { 6 | static readonly [entityKind]: string = 'PrimaryKey'; 7 | 8 | declare protected $brand: 'PrimaryKey'; 9 | 10 | constructor(readonly table: Table, readonly columns: AnyColumn[]) {} 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/prisma/mysql/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/prisma/pg/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "postgresql" 7 | url = env("DB_URL") 8 | } 9 | 10 | model User { 11 | id Int @id @default(autoincrement()) 12 | email String @unique 13 | name String? 14 | } 15 | -------------------------------------------------------------------------------- /drizzle-orm/src/prisma/sqlite/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/query-builders/query-builder.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { SQL, SQLWrapper } from '~/sql/index.ts'; 3 | 4 | export abstract class TypedQueryBuilder implements SQLWrapper { 5 | static readonly [entityKind]: string = 'TypedQueryBuilder'; 6 | 7 | declare _: { 8 | selectedFields: TSelection; 9 | result: TResult; 10 | config?: TConfig; 11 | }; 12 | 13 | /** @internal */ 14 | getSelectedFields(): TSelection { 15 | return this._.selectedFields; 16 | } 17 | 18 | abstract getSQL(): SQL; 19 | } 20 | -------------------------------------------------------------------------------- /drizzle-orm/src/runnable-query.ts: -------------------------------------------------------------------------------- 1 | import type { Dialect } from './column-builder.ts'; 2 | import type { PreparedQuery } from './session.ts'; 3 | 4 | export interface RunnableQuery { 5 | readonly _: { 6 | readonly dialect: TDialect; 7 | readonly result: T; 8 | }; 9 | 10 | /** @internal */ 11 | _prepare(): PreparedQuery; 12 | } 13 | -------------------------------------------------------------------------------- /drizzle-orm/src/session.ts: -------------------------------------------------------------------------------- 1 | import type { Query } from './index.ts'; 2 | 3 | export interface PreparedQuery { 4 | getQuery(): Query; 5 | mapResult(response: unknown, isFromBatch?: boolean): unknown; 6 | /** @internal */ 7 | isResponseInArrayMode(): boolean; 8 | } 9 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-core/alias.ts: -------------------------------------------------------------------------------- 1 | import { TableAliasProxyHandler } from '~/alias.ts'; 2 | import type { BuildAliasTable } from './query-builders/select.types.ts'; 3 | import type { SingleStoreTable } from './table.ts'; 4 | 5 | export function alias( // | SingleStoreViewBase 6 | table: TTable, 7 | alias: TAlias, 8 | ): BuildAliasTable { 9 | return new Proxy(table, new TableAliasProxyHandler(alias, false)) as any; 10 | } 11 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-core/columns/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bigint.ts'; 2 | export * from './binary.ts'; 3 | export * from './boolean.ts'; 4 | export * from './char.ts'; 5 | export * from './common.ts'; 6 | export * from './custom.ts'; 7 | export * from './date.ts'; 8 | export * from './datetime.ts'; 9 | export * from './decimal.ts'; 10 | export * from './double.ts'; 11 | export * from './enum.ts'; 12 | export * from './float.ts'; 13 | export * from './int.ts'; 14 | export * from './json.ts'; 15 | export * from './mediumint.ts'; 16 | export * from './real.ts'; 17 | export * from './serial.ts'; 18 | export * from './smallint.ts'; 19 | export * from './text.ts'; 20 | export * from './time.ts'; 21 | export * from './timestamp.ts'; 22 | export * from './tinyint.ts'; 23 | export * from './varbinary.ts'; 24 | export * from './varchar.ts'; 25 | export * from './vector.ts'; 26 | export * from './year.ts'; 27 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alias.ts'; 2 | export * from './columns/index.ts'; 3 | export * from './db.ts'; 4 | export * from './dialect.ts'; 5 | export * from './indexes.ts'; 6 | export * from './primary-keys.ts'; 7 | export * from './query-builders/index.ts'; 8 | export * from './schema.ts'; 9 | export * from './session.ts'; 10 | export * from './subquery.ts'; 11 | export * from './table.ts'; 12 | export * from './unique-constraint.ts'; 13 | export * from './utils.ts'; 14 | /* export * from './view-common.ts'; 15 | export * from './view.ts'; */ 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-core/query-builders/index.ts: -------------------------------------------------------------------------------- 1 | /* export * from './attach.ts'; 2 | export * from './branch.ts'; 3 | export * from './createMilestone.ts'; */ 4 | export * from './delete.ts'; 5 | /* export * from './detach.ts'; */ 6 | export * from './insert.ts'; 7 | /* export * from './optimizeTable.ts'; */ 8 | export * from './query-builder.ts'; 9 | export * from './select.ts'; 10 | export * from './select.types.ts'; 11 | export * from './update.ts'; 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-core/view-base.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { ColumnsSelection } from '~/sql/sql.ts'; 3 | import { View } from '~/sql/sql.ts'; 4 | 5 | export abstract class SingleStoreViewBase< 6 | TName extends string = string, 7 | TExisting extends boolean = boolean, 8 | TSelectedFields extends ColumnsSelection = ColumnsSelection, 9 | > extends View { 10 | static override readonly [entityKind]: string = 'SingleStoreViewBase'; 11 | 12 | declare readonly _: View['_'] & { 13 | readonly viewBrand: 'SingleStoreViewBase'; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-core/view-common.ts: -------------------------------------------------------------------------------- 1 | export const SingleStoreViewConfig = Symbol.for('drizzle:SingleStoreViewConfig'); 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore-proxy/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/singlestore/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { SingleStoreDriverDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: SingleStoreDriverDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/sql-js/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/sql-js/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { SQLJsDatabase } from './driver.ts'; 4 | 5 | export function migrate>( 6 | db: SQLJsDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/sql/expressions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './conditions.ts'; 2 | export * from './select.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/sql/functions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './aggregate.ts'; 2 | export * from './vector.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/sql/index.ts: -------------------------------------------------------------------------------- 1 | export * from './expressions/index.ts'; 2 | export * from './functions/index.ts'; 3 | export * from './sql.ts'; 4 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/alias.ts: -------------------------------------------------------------------------------- 1 | import { TableAliasProxyHandler } from '~/alias.ts'; 2 | import type { BuildAliasTable } from './query-builders/select.types.ts'; 3 | 4 | import type { SQLiteTable } from './table.ts'; 5 | import type { SQLiteViewBase } from './view-base.ts'; 6 | 7 | export function alias( 8 | table: TTable, 9 | alias: TAlias, 10 | ): BuildAliasTable { 11 | return new Proxy(table, new TableAliasProxyHandler(alias, false)) as any; 12 | } 13 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/checks.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { SQL } from '~/sql/sql.ts'; 3 | import type { SQLiteTable } from './table.ts'; 4 | 5 | export class CheckBuilder { 6 | static readonly [entityKind]: string = 'SQLiteCheckBuilder'; 7 | 8 | protected brand!: 'SQLiteConstraintBuilder'; 9 | 10 | constructor(public name: string, public value: SQL) {} 11 | 12 | build(table: SQLiteTable): Check { 13 | return new Check(table, this); 14 | } 15 | } 16 | 17 | export class Check { 18 | static readonly [entityKind]: string = 'SQLiteCheck'; 19 | 20 | declare _: { 21 | brand: 'SQLiteCheck'; 22 | }; 23 | 24 | readonly name: string; 25 | readonly value: SQL; 26 | 27 | constructor(public table: SQLiteTable, builder: CheckBuilder) { 28 | this.name = builder.name; 29 | this.value = builder.value; 30 | } 31 | } 32 | 33 | export function check(name: string, value: SQL): CheckBuilder { 34 | return new CheckBuilder(name, value); 35 | } 36 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/columns/all.ts: -------------------------------------------------------------------------------- 1 | import { blob } from './blob.ts'; 2 | import { customType } from './custom.ts'; 3 | import { integer } from './integer.ts'; 4 | import { numeric } from './numeric.ts'; 5 | import { real } from './real.ts'; 6 | import { text } from './text.ts'; 7 | 8 | export function getSQLiteColumnBuilders() { 9 | return { 10 | blob, 11 | customType, 12 | integer, 13 | numeric, 14 | real, 15 | text, 16 | }; 17 | } 18 | 19 | export type SQLiteColumnBuilders = ReturnType; 20 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/columns/index.ts: -------------------------------------------------------------------------------- 1 | export * from './blob.ts'; 2 | export * from './common.ts'; 3 | export * from './custom.ts'; 4 | export * from './integer.ts'; 5 | export * from './numeric.ts'; 6 | export * from './real.ts'; 7 | export * from './text.ts'; 8 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alias.ts'; 2 | export * from './checks.ts'; 3 | export * from './columns/index.ts'; 4 | export * from './db.ts'; 5 | export * from './dialect.ts'; 6 | export * from './foreign-keys.ts'; 7 | export * from './indexes.ts'; 8 | export * from './primary-keys.ts'; 9 | export * from './query-builders/index.ts'; 10 | export * from './session.ts'; 11 | export * from './subquery.ts'; 12 | export * from './table.ts'; 13 | export * from './unique-constraint.ts'; 14 | export * from './utils.ts'; 15 | export * from './view.ts'; 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/query-builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete.ts'; 2 | export * from './insert.ts'; 3 | export * from './query-builder.ts'; 4 | export * from './select.ts'; 5 | export * from './select.types.ts'; 6 | export * from './update.ts'; 7 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/view-base.ts: -------------------------------------------------------------------------------- 1 | import { entityKind } from '~/entity.ts'; 2 | import type { ColumnsSelection } from '~/sql/sql.ts'; 3 | import { View } from '~/sql/sql.ts'; 4 | 5 | export abstract class SQLiteViewBase< 6 | TName extends string = string, 7 | TExisting extends boolean = boolean, 8 | TSelection extends ColumnsSelection = ColumnsSelection, 9 | > extends View { 10 | static override readonly [entityKind]: string = 'SQLiteViewBase'; 11 | 12 | declare _: View['_'] & { 13 | viewBrand: 'SQLiteView'; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-core/view-common.ts: -------------------------------------------------------------------------------- 1 | export const SQLiteViewConfig = Symbol.for('drizzle:SQLiteViewConfig'); 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/sqlite-proxy/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/supabase/index.ts: -------------------------------------------------------------------------------- 1 | export * from './rls.ts'; 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/table.utils.ts: -------------------------------------------------------------------------------- 1 | /** @internal */ 2 | export const TableName = Symbol.for('drizzle:Name'); 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/tidb-serverless/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/tidb-serverless/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { TiDBServerlessDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: TiDBServerlessDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/tracing-utils.ts: -------------------------------------------------------------------------------- 1 | export function iife(fn: (...args: T) => U, ...args: T): U { 2 | return fn(...args); 3 | } 4 | -------------------------------------------------------------------------------- /drizzle-orm/src/vercel-postgres/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/src/vercel-postgres/migrator.ts: -------------------------------------------------------------------------------- 1 | import type { MigrationConfig } from '~/migrator.ts'; 2 | import { readMigrationFiles } from '~/migrator.ts'; 3 | import type { VercelPgDatabase } from './driver.ts'; 4 | 5 | export async function migrate>( 6 | db: VercelPgDatabase, 7 | config: MigrationConfig, 8 | ) { 9 | const migrations = readMigrationFiles(config); 10 | await db.dialect.migrate(migrations, db.session, config); 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/src/version.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore - imported using Rollup json plugin 2 | export { version as npmVersion } from '../package.json'; 3 | // In version 7, we changed the PostgreSQL indexes API 4 | export const compatibilityVersion = 10; 5 | -------------------------------------------------------------------------------- /drizzle-orm/src/view-common.ts: -------------------------------------------------------------------------------- 1 | export const ViewBaseConfig = Symbol.for('drizzle:ViewBaseConfig'); 2 | -------------------------------------------------------------------------------- /drizzle-orm/src/xata-http/index.ts: -------------------------------------------------------------------------------- 1 | export * from './driver.ts'; 2 | export * from './session.ts'; 3 | -------------------------------------------------------------------------------- /drizzle-orm/tests/is.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, test } from 'vitest'; 2 | import { Column, is } from '~/index.ts'; 3 | import { PgArray, PgColumn, PgSerial, pgTable, serial } from '~/pg-core/index.ts'; 4 | 5 | const pgExampleTable = pgTable('test', { 6 | a: serial('a').array(), 7 | }); 8 | 9 | describe.concurrent('is', () => { 10 | test('Column', ({ expect }) => { 11 | expect(is(pgExampleTable.a, Column)).toBe(true); 12 | expect(is(pgExampleTable.a, PgColumn)).toBe(true); 13 | expect(is(pgExampleTable.a, PgArray)).toBe(true); 14 | expect(is(pgExampleTable.a, PgSerial)).toBe(false); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /drizzle-orm/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "rootDir": ".." 5 | }, 6 | "include": [".", "../src"] 7 | } 8 | -------------------------------------------------------------------------------- /drizzle-orm/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /drizzle-orm/tsconfig.dts.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "compilerOptions": { 4 | "composite": false, 5 | "rootDir": "src", 6 | "outDir": "dist-dts", 7 | "declaration": true, 8 | "noEmit": false, 9 | "emitDeclarationOnly": true, 10 | "incremental": false 11 | }, 12 | "include": ["src"] 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-orm/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | "paths": { 6 | "~/*": ["src/*"] 7 | }, 8 | "declaration": true, 9 | "outDir": "dist", 10 | "noEmit": true 11 | }, 12 | "include": ["src", "scripts"] 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-orm/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { globSync } from 'glob'; 2 | import { defineConfig } from 'tsup'; 3 | 4 | const entries = globSync('src/**/*.ts'); 5 | 6 | export default defineConfig({ 7 | entry: entries, 8 | outDir: 'dist.new', 9 | format: ['cjs', 'esm'], 10 | bundle: false, 11 | splitting: false, 12 | sourcemap: true, 13 | outExtension({ format }) { 14 | return { 15 | js: format === 'cjs' ? '.cjs' : '.js', 16 | }; 17 | }, 18 | tsconfig: 'tsconfig.build.json', 19 | }); 20 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/geldb/1-to-1-fk.ts: -------------------------------------------------------------------------------- 1 | import { type GelColumn, integer } from '~/gel-core/columns/index.ts'; 2 | import { gelTable } from '~/gel-core/table.ts'; 3 | 4 | { 5 | const test1 = gelTable('test1_table', { 6 | id: integer('id').primaryKey(), 7 | test2Id: integer('test2_id').references(() => test2.id), 8 | }); 9 | 10 | const test1Id = integer('test1_id').references(() => test1.id); 11 | 12 | const test2 = gelTable('test2_table', { 13 | id: integer('id').primaryKey(), 14 | test1Id, 15 | }); 16 | } 17 | 18 | { 19 | const test1 = gelTable('test1_table', { 20 | id: integer('id').primaryKey(), 21 | test2Id: integer('test2_id').references((): GelColumn => test2.id), 22 | }); 23 | 24 | const test2 = gelTable('test2_table', { 25 | id: integer('id').primaryKey(), 26 | test1Id: integer('test1_id').references(() => test1.id), 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/geldb/array.ts: -------------------------------------------------------------------------------- 1 | import { type Equal, Expect } from 'type-tests/utils.ts'; 2 | import type { Column } from '~/column.ts'; 3 | import { gelTable, integer } from '~/gel-core/index.ts'; 4 | 5 | { 6 | const table = gelTable('table', { 7 | a: integer('a').array().notNull(), 8 | }); 9 | Expect< 10 | Equal< 11 | Column< 12 | { 13 | name: 'a'; 14 | tableName: 'table'; 15 | dataType: 'number'; 16 | columnType: 'GelInteger'; 17 | data: number; 18 | driverParam: number; 19 | notNull: false; 20 | hasDefault: false; 21 | enumValues: undefined; 22 | baseColumn: never; 23 | generated: undefined; 24 | identity: undefined; 25 | isPrimaryKey: false; 26 | isAutoincrement: false; 27 | hasRuntimeDefault: false; 28 | }, 29 | {}, 30 | {} 31 | >, 32 | typeof table['a']['_']['baseColumn'] 33 | > 34 | >; 35 | } 36 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/geldb/db.ts: -------------------------------------------------------------------------------- 1 | import * as gel from 'gel'; 2 | import { drizzle } from '~/gel/index.ts'; 3 | 4 | export const db = drizzle(gel.createClient()); 5 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/geldb/no-strict-null-checks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "strictNullChecks": false, 6 | "strictPropertyInitialization": false, 7 | "exactOptionalPropertyTypes": false 8 | }, 9 | "include": ["./test.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/geldb/other.ts: -------------------------------------------------------------------------------- 1 | import type { Equal } from 'type-tests/utils.ts'; 2 | import { Expect } from 'type-tests/utils.ts'; 3 | import { eq, inArray } from '~/sql/expressions/index.ts'; 4 | import { sql } from '~/sql/sql.ts'; 5 | import { db } from './db.ts'; 6 | import { users } from './tables.ts'; 7 | 8 | const rawQuery = await db.execute( 9 | sql`select ${users.id}, ${users.class} from ${users} where ${inArray(users.id, [1, 2, 3])} and ${ 10 | eq(users.class, 'A') 11 | }`, 12 | ); 13 | 14 | Expect[], typeof rawQuery>>; 15 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/knex/index.ts: -------------------------------------------------------------------------------- 1 | import { knex } from 'knex'; 2 | import { type Equal, Expect } from 'type-tests/utils.ts'; 3 | import { pgTable, serial, text } from '~/pg-core/index.ts'; 4 | import type { PromiseOf } from '~/utils.ts'; 5 | import '~/knex'; 6 | 7 | const test = pgTable('test', { 8 | id: serial('id').primaryKey(), 9 | name: text('name').notNull(), 10 | }); 11 | 12 | declare module 'knex/types/tables.ts' { 13 | interface Tables { 14 | test: Knexify; 15 | } 16 | } 17 | 18 | const db = knex({}); 19 | 20 | { 21 | const res = db('test').select(); 22 | Expect, typeof test.$inferSelect[]>>; 23 | } 24 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/mysql/1-to-1-fk.ts: -------------------------------------------------------------------------------- 1 | import { int, serial } from '~/mysql-core/columns/index.ts'; 2 | import { mysqlTable } from '~/mysql-core/table.ts'; 3 | 4 | const test1 = mysqlTable('test1_table', { 5 | id: serial('id').primaryKey(), 6 | test2Id: int('test2_id').references(() => test2.id), 7 | }); 8 | 9 | const test1Id = int('test1_id').references(() => test1.id); 10 | 11 | const test2 = mysqlTable('test2_table', { 12 | id: serial('id').primaryKey(), 13 | test1Id, 14 | }); 15 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/mysql/db.ts: -------------------------------------------------------------------------------- 1 | import { createPool } from 'mysql2/promise'; 2 | import { drizzle } from '~/mysql2/index.ts'; 3 | 4 | const pool = createPool({}); 5 | 6 | export const db = drizzle(pool); 7 | 8 | { 9 | drizzle(pool); 10 | // @ts-expect-error - missing mode 11 | drizzle(pool, { schema: {} }); 12 | drizzle(pool, { schema: {}, mode: 'default' }); 13 | drizzle(pool, { schema: {}, mode: 'planetscale' }); 14 | drizzle(pool, { mode: 'default' }); 15 | drizzle(pool, { mode: 'planetscale' }); 16 | } 17 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/mysql/no-strict-null-checks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "strictNullChecks": false, 6 | "strictPropertyInitialization": false, 7 | "exactOptionalPropertyTypes": false 8 | }, 9 | "include": ["./test.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/mysql/update.ts: -------------------------------------------------------------------------------- 1 | import { type Equal, Expect } from 'type-tests/utils.ts'; 2 | import type { MySqlUpdate } from '~/mysql-core/index.ts'; 3 | import type { MySqlRawQueryResult } from '~/mysql2/session.ts'; 4 | import { sql } from '~/sql/sql.ts'; 5 | import { db } from './db.ts'; 6 | import { users } from './tables.ts'; 7 | 8 | { 9 | function dynamic(qb: T) { 10 | return qb.where(sql``); 11 | } 12 | 13 | const qbBase = db.update(users).set({}).$dynamic(); 14 | const qb = dynamic(qbBase); 15 | const result = await qb; 16 | Expect>; 17 | } 18 | 19 | { 20 | db 21 | .update(users) 22 | .set({}) 23 | .where(sql``) 24 | // @ts-expect-error method was already called 25 | .where(sql``); 26 | } 27 | 28 | { 29 | db.update(users).set({}).where(sql``).limit(1).orderBy(sql``); 30 | } 31 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/pg/1-to-1-fk.ts: -------------------------------------------------------------------------------- 1 | import { integer, type PgColumn, serial } from '~/pg-core/columns/index.ts'; 2 | import { pgTable } from '~/pg-core/table.ts'; 3 | 4 | { 5 | const test1 = pgTable('test1_table', { 6 | id: serial('id').primaryKey(), 7 | test2Id: integer('test2_id').references(() => test2.id), 8 | }); 9 | 10 | const test1Id = integer('test1_id').references(() => test1.id); 11 | 12 | const test2 = pgTable('test2_table', { 13 | id: serial('id').primaryKey(), 14 | test1Id, 15 | }); 16 | } 17 | 18 | { 19 | const test1 = pgTable('test1_table', { 20 | id: serial('id').primaryKey(), 21 | test2Id: integer('test2_id').references((): PgColumn => test2.id), 22 | }); 23 | 24 | const test2 = pgTable('test2_table', { 25 | id: serial('id').primaryKey(), 26 | test1Id: integer('test1_id').references(() => test1.id), 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/pg/array.ts: -------------------------------------------------------------------------------- 1 | import { type Equal, Expect } from 'type-tests/utils.ts'; 2 | import type { Column } from '~/column.ts'; 3 | import { integer, pgTable } from '~/pg-core/index.ts'; 4 | 5 | { 6 | const table = pgTable('table', { 7 | a: integer('a').array().notNull(), 8 | }); 9 | Expect< 10 | Equal< 11 | Column< 12 | { 13 | name: 'a'; 14 | tableName: 'table'; 15 | dataType: 'number'; 16 | columnType: 'PgInteger'; 17 | data: number; 18 | driverParam: string | number; 19 | notNull: false; 20 | hasDefault: false; 21 | enumValues: undefined; 22 | baseColumn: never; 23 | generated: undefined; 24 | identity: undefined; 25 | isPrimaryKey: false; 26 | isAutoincrement: false; 27 | hasRuntimeDefault: false; 28 | }, 29 | {}, 30 | {} 31 | >, 32 | typeof table['a']['_']['baseColumn'] 33 | > 34 | >; 35 | } 36 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/pg/db.ts: -------------------------------------------------------------------------------- 1 | import pg from 'pg'; 2 | import { drizzle } from '~/node-postgres/index.ts'; 3 | 4 | const { Client } = pg; 5 | 6 | export const db = drizzle(new Client()); 7 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/pg/no-strict-null-checks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "strictNullChecks": false, 6 | "strictPropertyInitialization": false, 7 | "exactOptionalPropertyTypes": false 8 | }, 9 | "include": ["./test.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/pg/other.ts: -------------------------------------------------------------------------------- 1 | import type { QueryResult } from 'pg'; 2 | import { eq, inArray } from '~/sql/expressions/index.ts'; 3 | import { sql } from '~/sql/sql.ts'; 4 | 5 | import type { Equal } from 'type-tests/utils.ts'; 6 | import { Expect } from 'type-tests/utils.ts'; 7 | import { db } from './db.ts'; 8 | import { users } from './tables.ts'; 9 | 10 | const rawQuery = await db.execute( 11 | sql`select ${users.id}, ${users.class} from ${users} where ${inArray(users.id, [1, 2, 3])} and ${ 12 | eq(users.class, 'A') 13 | }`, 14 | ); 15 | 16 | Expect>, typeof rawQuery>>; 17 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/singlestore/db.ts: -------------------------------------------------------------------------------- 1 | import { createPool } from 'mysql2/promise'; 2 | import { drizzle } from '~/singlestore/index.ts'; 3 | 4 | const pool = createPool({}); 5 | 6 | export const db = drizzle(pool); 7 | 8 | { 9 | drizzle(pool); 10 | drizzle(pool, { schema: {} }); 11 | drizzle(pool, { schema: {} }); 12 | drizzle(pool, {}); 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/singlestore/no-strict-null-checks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "strictNullChecks": false, 6 | "strictPropertyInitialization": false, 7 | "exactOptionalPropertyTypes": false 8 | }, 9 | "include": ["./test.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/singlestore/update.ts: -------------------------------------------------------------------------------- 1 | import { type Equal, Expect } from 'type-tests/utils.ts'; 2 | import type { SingleStoreUpdate } from '~/singlestore-core/index.ts'; 3 | import type { SingleStoreRawQueryResult } from '~/singlestore/session.ts'; 4 | import { sql } from '~/sql/sql.ts'; 5 | import { db } from './db.ts'; 6 | import { users } from './tables.ts'; 7 | 8 | { 9 | function dynamic(qb: T) { 10 | return qb.where(sql``); 11 | } 12 | 13 | const qbBase = db.update(users).set({}).$dynamic(); 14 | const qb = dynamic(qbBase); 15 | const result = await qb; 16 | Expect>; 17 | } 18 | 19 | { 20 | db 21 | .update(users) 22 | .set({}) 23 | .where(sql``) 24 | // @ts-expect-error method was already called 25 | .where(sql``); 26 | } 27 | 28 | { 29 | db.update(users).set({}).where(sql``).limit(1).orderBy(sql``); 30 | } 31 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/sqlite/.gitignore: -------------------------------------------------------------------------------- 1 | ./database.db 2 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/sqlite/db.ts: -------------------------------------------------------------------------------- 1 | import Database from 'better-sqlite3'; 2 | import { Database as BunDatabase } from 'bun:sqlite'; 3 | import { drizzle as drizzleBetterSqlite3 } from '~/better-sqlite3/index.ts'; 4 | import { drizzle as drizzleBun } from '~/bun-sqlite/index.ts'; 5 | import { drizzle as drizzleD1 } from '~/d1/index.ts'; 6 | import { drizzle as durableSqlite } from '~/durable-sqlite/index.ts'; 7 | 8 | const client = new Database(':memory:'); 9 | const bunClient = new BunDatabase(':memory:'); 10 | declare const d1: D1Database; 11 | declare const durableSql: DurableObjectStorage; 12 | 13 | export const db = drizzleBetterSqlite3(client); 14 | export const bunDb = drizzleBun(bunClient); 15 | export const d1Db = drizzleD1(d1); 16 | export const durableSqliteDb = durableSqlite(durableSql); 17 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/sqlite/no-strict-null-checks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "strictNullChecks": false, 6 | "strictPropertyInitialization": false, 7 | "exactOptionalPropertyTypes": false 8 | }, 9 | "include": ["./test.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "composite": false, 5 | "noEmit": true, 6 | "rootDir": "..", 7 | "outDir": "./.cache" 8 | }, 9 | "include": [".", "../src"], 10 | "exclude": ["**/playground"] 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/utils.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function 2 | export function Expect() {} 3 | 4 | export type Equal = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? true 5 | : false; 6 | -------------------------------------------------------------------------------- /drizzle-orm/type-tests/utils/neon-auth-token.ts: -------------------------------------------------------------------------------- 1 | import type { HTTPQueryOptions } from '@neondatabase/serverless'; 2 | import { type Equal, Expect } from 'type-tests/utils.ts'; 3 | import type { NeonAuthToken } from '~/utils'; 4 | 5 | Expect['authToken'], undefined>, NeonAuthToken>>; 6 | -------------------------------------------------------------------------------- /drizzle-orm/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { viteCommonjs } from '@originjs/vite-plugin-commonjs'; 2 | import tsconfigPaths from 'vite-tsconfig-paths'; 3 | import { defineConfig } from 'vitest/config'; 4 | 5 | export default defineConfig({ 6 | test: { 7 | typecheck: { 8 | tsconfig: 'tests/tsconfig.json', 9 | }, 10 | }, 11 | plugins: [viteCommonjs(), tsconfigPaths()], 12 | }); 13 | -------------------------------------------------------------------------------- /drizzle-seed/rollup.config.ts: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { defineConfig } from 'rollup'; 3 | 4 | export default defineConfig([ 5 | { 6 | input: 'src/index.ts', 7 | output: [ 8 | { 9 | format: 'esm', 10 | dir: 'dist', 11 | entryFileNames: '[name].mjs', 12 | chunkFileNames: '[name]-[hash].mjs', 13 | sourcemap: true, 14 | }, 15 | { 16 | format: 'cjs', 17 | dir: 'dist', 18 | entryFileNames: '[name].cjs', 19 | chunkFileNames: '[name]-[hash].cjs', 20 | sourcemap: true, 21 | }, 22 | ], 23 | external: [/^drizzle-orm\/?/, 'pure-rand'], 24 | plugins: [ 25 | typescript({ 26 | tsconfig: 'tsconfig.build.json', 27 | }), 28 | ], 29 | }, 30 | ]); 31 | -------------------------------------------------------------------------------- /drizzle-seed/scripts/build.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S pnpm tsx 2 | import 'zx/globals'; 3 | import cpy from 'cpy'; 4 | 5 | await fs.remove('dist'); 6 | await $`rollup --config rollup.config.ts --configPlugin typescript`; 7 | await $`resolve-tspaths`; 8 | await fs.copy('README.md', 'dist/README.md'); 9 | await cpy('dist/**/*.d.ts', 'dist', { 10 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'), 11 | }); 12 | await cpy('dist/**/*.d.ts', 'dist', { 13 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'), 14 | }); 15 | await fs.copy('package.json', 'dist/package.json'); 16 | -------------------------------------------------------------------------------- /drizzle-seed/src/datasets/companyNameSuffixes.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'LLC', 3 | 'Ltd', 4 | 'Inc.', 5 | 'Corp.', 6 | 'PLC', 7 | 'GmbH', 8 | 'AG', 9 | 'S.A.', 10 | 'S.p.A.', 11 | 'SARL', 12 | 'B.V.', 13 | 'N.V.', 14 | 'Oy', 15 | 'AB', 16 | 'AS', 17 | 'Pty Ltd', 18 | 'K.K.', 19 | 'JSC', 20 | 'Ltda.', 21 | 'Pvt Ltd', 22 | 'Sdn Bhd', 23 | 'A/S', 24 | 'SAOG', 25 | 'Co.', 26 | 'SCC', 27 | ]; 28 | 29 | export const maxStringLength = 7; 30 | -------------------------------------------------------------------------------- /drizzle-seed/src/datasets/emailDomains.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'gmail.com', 3 | 'yahoo.com', 4 | 'outlook.com', 5 | 'msn.com', 6 | 'hotmail.com', 7 | 'aol.com', 8 | 'hotmail.co.uk', 9 | 'hotmail.fr', 10 | 'yahoo.fr', 11 | 'wanadoo.fr', 12 | 'orange.fr', 13 | 'comcast.net', 14 | 'yahoo.co.uk', 15 | 'yahoo.com.br', 16 | 'yahoo.co.in', 17 | 'live.com', 18 | 'rediffmail.com', 19 | 'free.fr', 20 | 'gmx.de', 21 | 'web.de', 22 | 'ymail.com', 23 | 'libero.it', 24 | ]; 25 | 26 | export const maxStringLength = 14; 27 | -------------------------------------------------------------------------------- /drizzle-seed/src/datasets/states.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'Alabama', 3 | 'Alaska', 4 | 'Arizona', 5 | 'Arkansas', 6 | 'California', 7 | 'Colorado', 8 | 'Connecticut', 9 | 'Delaware', 10 | 'Florida', 11 | 'Georgia', 12 | 'Hawaii', 13 | 'Idaho', 14 | 'Illinois', 15 | 'Indiana', 16 | 'Iowa', 17 | 'Kansas', 18 | 'Kentucky', 19 | 'Louisiana', 20 | 'Maine', 21 | 'Maryland', 22 | 'Massachusetts', 23 | 'Michigan', 24 | 'Minnesota', 25 | 'Mississippi', 26 | 'Missouri', 27 | 'Montana', 28 | 'Nebraska', 29 | 'Nevada', 30 | 'New Hampshire', 31 | 'New Jersey', 32 | 'New Mexico', 33 | 'New York', 34 | 'North Carolina', 35 | 'North Dakota', 36 | 'Ohio', 37 | 'Oklahoma', 38 | 'Oregon', 39 | 'Pennsylvania', 40 | 'Rhode Island', 41 | 'South Carolina', 42 | 'South Dakota', 43 | 'Tennessee', 44 | 'Texas', 45 | 'Utah', 46 | 'Vermont', 47 | 'Virginia', 48 | 'Washington', 49 | 'West Virginia', 50 | 'Wisconsin', 51 | 'Wyoming', 52 | ]; 53 | 54 | export const maxStringLength = 14; 55 | -------------------------------------------------------------------------------- /drizzle-seed/src/services/apiVersion.ts: -------------------------------------------------------------------------------- 1 | export const latestVersion = 2; 2 | -------------------------------------------------------------------------------- /drizzle-seed/tests/mysql/generatorsTest/mysqlSchema.ts: -------------------------------------------------------------------------------- 1 | import { datetime, mysqlTable, year } from 'drizzle-orm/mysql-core'; 2 | 3 | export const datetimeTable = mysqlTable('datetime_table', { 4 | datetime: datetime('datetime'), 5 | }); 6 | 7 | export const yearTable = mysqlTable('year_table', { 8 | year: year('year'), 9 | }); 10 | -------------------------------------------------------------------------------- /drizzle-seed/tests/sqlite/allDataTypesTest/sqliteSchema.ts: -------------------------------------------------------------------------------- 1 | import { blob, integer, numeric, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'; 2 | 3 | export const allDataTypes = sqliteTable('all_data_types', { 4 | integerNumber: integer('integer_number', { mode: 'number' }), 5 | integerBoolean: integer('integer_boolean', { mode: 'boolean' }), 6 | integerTimestamp: integer('integer_timestamp', { mode: 'timestamp' }), 7 | integerTimestampms: integer('integer_timestampms', { mode: 'timestamp_ms' }), 8 | real: real('real'), 9 | text: text('text', { mode: 'text' }), 10 | textJson: text('text_json', { mode: 'json' }), 11 | blobBigint: blob('blob_bigint', { mode: 'bigint' }), 12 | blobBuffer: blob('blob_buffer', { mode: 'buffer' }), 13 | blobJson: blob('blob_json', { mode: 'json' }), 14 | numeric: numeric('numeric'), 15 | }); 16 | -------------------------------------------------------------------------------- /drizzle-seed/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src" 5 | }, 6 | "include": ["src"] 7 | } 8 | -------------------------------------------------------------------------------- /drizzle-seed/type-tests/mysql.ts: -------------------------------------------------------------------------------- 1 | import type { MySqlColumn } from 'drizzle-orm/mysql-core'; 2 | import { int, mysqlTable, text } from 'drizzle-orm/mysql-core'; 3 | import { drizzle as mysql2Drizzle } from 'drizzle-orm/mysql2'; 4 | import { reset, seed } from '../src/index.ts'; 5 | 6 | const mysqlUsers = mysqlTable('users', { 7 | id: int().primaryKey().autoincrement(), 8 | name: text(), 9 | inviteId: int('invite_id').references((): MySqlColumn => mysqlUsers.id), 10 | }); 11 | 12 | { 13 | const db = mysql2Drizzle(''); 14 | 15 | await seed(db, { users: mysqlUsers }); 16 | await reset(db, { users: mysqlUsers }); 17 | } 18 | -------------------------------------------------------------------------------- /drizzle-seed/type-tests/sqlite.ts: -------------------------------------------------------------------------------- 1 | import { drizzle as betterSqlite3Drizzle } from 'drizzle-orm/better-sqlite3'; 2 | import type { SQLiteColumn } from 'drizzle-orm/sqlite-core'; 3 | import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'; 4 | import { reset, seed } from '../src/index.ts'; 5 | 6 | const mysqlUsers = sqliteTable('users', { 7 | id: int().primaryKey(), 8 | name: text(), 9 | inviteId: int('invite_id').references((): SQLiteColumn => mysqlUsers.id), 10 | }); 11 | 12 | { 13 | const db = betterSqlite3Drizzle(''); 14 | 15 | await seed(db, { users: mysqlUsers }); 16 | await reset(db, { users: mysqlUsers }); 17 | } 18 | -------------------------------------------------------------------------------- /drizzle-seed/type-tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "composite": false, 5 | "noEmit": true, 6 | "rootDir": "..", 7 | "outDir": "./.cache" 8 | }, 9 | "include": [".", "../src"], 10 | "exclude": ["**/playground"] 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-seed/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | 3 | export default defineConfig({ 4 | test: { 5 | include: [ 6 | './tests/pg/**/*.test.ts', 7 | './tests/mysql/**/*.test.ts', 8 | './tests/sqlite/**/*.test.ts', 9 | ], 10 | exclude: [], 11 | typecheck: { 12 | tsconfig: 'tsconfig.json', 13 | }, 14 | testTimeout: 100000, 15 | hookTimeout: 100000, 16 | isolate: true, 17 | poolOptions: { 18 | threads: { 19 | singleThread: true, 20 | }, 21 | }, 22 | maxWorkers: 1, 23 | fileParallelism: false, 24 | }, 25 | }); 26 | -------------------------------------------------------------------------------- /drizzle-typebox/rollup.config.ts: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { defineConfig } from 'rollup'; 3 | 4 | export default defineConfig([ 5 | { 6 | input: 'src/index.ts', 7 | output: [ 8 | { 9 | format: 'esm', 10 | dir: 'dist', 11 | entryFileNames: '[name].mjs', 12 | chunkFileNames: '[name]-[hash].mjs', 13 | sourcemap: true, 14 | }, 15 | { 16 | format: 'cjs', 17 | dir: 'dist', 18 | entryFileNames: '[name].cjs', 19 | chunkFileNames: '[name]-[hash].cjs', 20 | sourcemap: true, 21 | }, 22 | ], 23 | external: [ 24 | /^drizzle-orm\/?/, 25 | '@sinclair/typebox', 26 | ], 27 | plugins: [ 28 | typescript({ 29 | tsconfig: 'tsconfig.build.json', 30 | }), 31 | ], 32 | }, 33 | ]); 34 | -------------------------------------------------------------------------------- /drizzle-typebox/scripts/build.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S pnpm tsx 2 | import 'zx/globals'; 3 | import cpy from 'cpy'; 4 | 5 | await fs.remove('dist'); 6 | await $`rollup --config rollup.config.ts --configPlugin typescript`; 7 | await $`resolve-tspaths`; 8 | await fs.copy('README.md', 'dist/README.md'); 9 | await cpy('dist/**/*.d.ts', 'dist', { 10 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'), 11 | }); 12 | await cpy('dist/**/*.d.ts', 'dist', { 13 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'), 14 | }); 15 | await fs.copy('package.json', 'dist/package.json'); 16 | await $`scripts/fix-imports.ts`; 17 | -------------------------------------------------------------------------------- /drizzle-typebox/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const CONSTANTS = { 2 | INT8_MIN: -128, 3 | INT8_MAX: 127, 4 | INT8_UNSIGNED_MAX: 255, 5 | INT16_MIN: -32768, 6 | INT16_MAX: 32767, 7 | INT16_UNSIGNED_MAX: 65535, 8 | INT24_MIN: -8388608, 9 | INT24_MAX: 8388607, 10 | INT24_UNSIGNED_MAX: 16777215, 11 | INT32_MIN: -2147483648, 12 | INT32_MAX: 2147483647, 13 | INT32_UNSIGNED_MAX: 4294967295, 14 | INT48_MIN: -140737488355328, 15 | INT48_MAX: 140737488355327, 16 | INT48_UNSIGNED_MAX: 281474976710655, 17 | INT64_MIN: -9223372036854775808n, 18 | INT64_MAX: 9223372036854775807n, 19 | INT64_UNSIGNED_MAX: 18446744073709551615n, 20 | }; 21 | -------------------------------------------------------------------------------- /drizzle-typebox/src/index.ts: -------------------------------------------------------------------------------- 1 | export { bufferSchema, jsonSchema, literalSchema } from './column.ts'; 2 | export * from './column.types.ts'; 3 | export * from './schema.ts'; 4 | export * from './schema.types.internal.ts'; 5 | export * from './schema.types.ts'; 6 | export * from './utils.ts'; 7 | -------------------------------------------------------------------------------- /drizzle-typebox/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "esnext", 5 | "target": "esnext", 6 | "noEmit": true, 7 | "rootDir": "..", 8 | "outDir": "./.cache" 9 | }, 10 | "include": [".", "../src"] 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-typebox/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src" 5 | }, 6 | "include": ["src"] 7 | } 8 | -------------------------------------------------------------------------------- /drizzle-typebox/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "baseUrl": ".", 6 | "declaration": true, 7 | "noEmit": true, 8 | "paths": { 9 | "~/*": ["src/*"] 10 | } 11 | }, 12 | "include": ["src", "*.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-typebox/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import tsconfigPaths from 'vite-tsconfig-paths'; 2 | import { defineConfig } from 'vitest/config'; 3 | 4 | export default defineConfig({ 5 | test: { 6 | include: [ 7 | 'tests/**/*.test.ts', 8 | ], 9 | exclude: [ 10 | 'tests/bun/**/*', 11 | ], 12 | typecheck: { 13 | tsconfig: 'tsconfig.json', 14 | }, 15 | testTimeout: 100000, 16 | hookTimeout: 100000, 17 | isolate: false, 18 | poolOptions: { 19 | threads: { 20 | singleThread: true, 21 | }, 22 | }, 23 | }, 24 | plugins: [tsconfigPaths()], 25 | }); 26 | -------------------------------------------------------------------------------- /drizzle-valibot/rollup.config.ts: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { defineConfig } from 'rollup'; 3 | 4 | export default defineConfig([ 5 | { 6 | input: 'src/index.ts', 7 | output: [ 8 | { 9 | format: 'esm', 10 | dir: 'dist', 11 | entryFileNames: '[name].mjs', 12 | chunkFileNames: '[name]-[hash].mjs', 13 | sourcemap: true, 14 | }, 15 | { 16 | format: 'cjs', 17 | dir: 'dist', 18 | entryFileNames: '[name].cjs', 19 | chunkFileNames: '[name]-[hash].cjs', 20 | sourcemap: true, 21 | }, 22 | ], 23 | external: [ 24 | /^drizzle-orm\/?/, 25 | 'valibot', 26 | ], 27 | plugins: [ 28 | typescript({ 29 | tsconfig: 'tsconfig.build.json', 30 | }), 31 | ], 32 | }, 33 | ]); 34 | -------------------------------------------------------------------------------- /drizzle-valibot/scripts/build.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S pnpm tsx 2 | import 'zx/globals'; 3 | import cpy from 'cpy'; 4 | 5 | await fs.remove('dist'); 6 | await $`rollup --config rollup.config.ts --configPlugin typescript`; 7 | await $`resolve-tspaths`; 8 | await fs.copy('README.md', 'dist/README.md'); 9 | await cpy('dist/**/*.d.ts', 'dist', { 10 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'), 11 | }); 12 | await cpy('dist/**/*.d.ts', 'dist', { 13 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'), 14 | }); 15 | await fs.copy('package.json', 'dist/package.json'); 16 | await $`scripts/fix-imports.ts`; 17 | -------------------------------------------------------------------------------- /drizzle-valibot/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const CONSTANTS = { 2 | INT8_MIN: -128, 3 | INT8_MAX: 127, 4 | INT8_UNSIGNED_MAX: 255, 5 | INT16_MIN: -32768, 6 | INT16_MAX: 32767, 7 | INT16_UNSIGNED_MAX: 65535, 8 | INT24_MIN: -8388608, 9 | INT24_MAX: 8388607, 10 | INT24_UNSIGNED_MAX: 16777215, 11 | INT32_MIN: -2147483648, 12 | INT32_MAX: 2147483647, 13 | INT32_UNSIGNED_MAX: 4294967295, 14 | INT48_MIN: -140737488355328, 15 | INT48_MAX: 140737488355327, 16 | INT48_UNSIGNED_MAX: 281474976710655, 17 | INT64_MIN: -9223372036854775808n, 18 | INT64_MAX: 9223372036854775807n, 19 | INT64_UNSIGNED_MAX: 18446744073709551615n, 20 | }; 21 | -------------------------------------------------------------------------------- /drizzle-valibot/src/index.ts: -------------------------------------------------------------------------------- 1 | export { bufferSchema, jsonSchema, literalSchema } from './column.ts'; 2 | export * from './column.types.ts'; 3 | export * from './schema.ts'; 4 | export * from './schema.types.internal.ts'; 5 | export * from './schema.types.ts'; 6 | export * from './utils.ts'; 7 | -------------------------------------------------------------------------------- /drizzle-valibot/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "esnext", 5 | "target": "esnext", 6 | "noEmit": true, 7 | "rootDir": "..", 8 | "outDir": "./.cache" 9 | }, 10 | "include": [".", "../src"] 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-valibot/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src" 5 | }, 6 | "include": ["src"] 7 | } 8 | -------------------------------------------------------------------------------- /drizzle-valibot/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "baseUrl": ".", 6 | "declaration": true, 7 | "noEmit": true, 8 | "paths": { 9 | "~/*": ["src/*"] 10 | } 11 | }, 12 | "include": ["src", "*.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-valibot/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import tsconfigPaths from 'vite-tsconfig-paths'; 2 | import { defineConfig } from 'vitest/config'; 3 | 4 | export default defineConfig({ 5 | test: { 6 | include: [ 7 | 'tests/**/*.test.ts', 8 | ], 9 | exclude: [ 10 | 'tests/bun/**/*', 11 | ], 12 | typecheck: { 13 | tsconfig: 'tsconfig.json', 14 | }, 15 | testTimeout: 100000, 16 | hookTimeout: 100000, 17 | isolate: false, 18 | poolOptions: { 19 | threads: { 20 | singleThread: true, 21 | }, 22 | }, 23 | }, 24 | plugins: [tsconfigPaths()], 25 | }); 26 | -------------------------------------------------------------------------------- /drizzle-zod/rollup.config.ts: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { defineConfig } from 'rollup'; 3 | 4 | export default defineConfig([ 5 | { 6 | input: 'src/index.ts', 7 | output: [ 8 | { 9 | format: 'esm', 10 | dir: 'dist', 11 | entryFileNames: '[name].mjs', 12 | chunkFileNames: '[name]-[hash].mjs', 13 | sourcemap: true, 14 | }, 15 | { 16 | format: 'cjs', 17 | dir: 'dist', 18 | entryFileNames: '[name].cjs', 19 | chunkFileNames: '[name]-[hash].cjs', 20 | sourcemap: true, 21 | }, 22 | ], 23 | external: [ 24 | /^drizzle-orm\/?/, 25 | 'zod', 26 | ], 27 | plugins: [ 28 | typescript({ 29 | tsconfig: 'tsconfig.build.json', 30 | }), 31 | ], 32 | }, 33 | ]); 34 | -------------------------------------------------------------------------------- /drizzle-zod/scripts/build.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S pnpm tsx 2 | import 'zx/globals'; 3 | import cpy from 'cpy'; 4 | 5 | await fs.remove('dist'); 6 | await $`rollup --config rollup.config.ts --configPlugin typescript`; 7 | await $`resolve-tspaths`; 8 | await fs.copy('README.md', 'dist/README.md'); 9 | await cpy('dist/**/*.d.ts', 'dist', { 10 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'), 11 | }); 12 | await cpy('dist/**/*.d.ts', 'dist', { 13 | rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'), 14 | }); 15 | await fs.copy('package.json', 'dist/package.json'); 16 | await $`scripts/fix-imports.ts`; 17 | -------------------------------------------------------------------------------- /drizzle-zod/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const CONSTANTS = { 2 | INT8_MIN: -128, 3 | INT8_MAX: 127, 4 | INT8_UNSIGNED_MAX: 255, 5 | INT16_MIN: -32768, 6 | INT16_MAX: 32767, 7 | INT16_UNSIGNED_MAX: 65535, 8 | INT24_MIN: -8388608, 9 | INT24_MAX: 8388607, 10 | INT24_UNSIGNED_MAX: 16777215, 11 | INT32_MIN: -2147483648, 12 | INT32_MAX: 2147483647, 13 | INT32_UNSIGNED_MAX: 4294967295, 14 | INT48_MIN: -140737488355328, 15 | INT48_MAX: 140737488355327, 16 | INT48_UNSIGNED_MAX: 281474976710655, 17 | INT64_MIN: -9223372036854775808n, 18 | INT64_MAX: 9223372036854775807n, 19 | INT64_UNSIGNED_MAX: 18446744073709551615n, 20 | }; 21 | -------------------------------------------------------------------------------- /drizzle-zod/src/index.ts: -------------------------------------------------------------------------------- 1 | export { bufferSchema, jsonSchema, literalSchema } from './column.ts'; 2 | export * from './column.types.ts'; 3 | export * from './schema.ts'; 4 | export * from './schema.types.internal.ts'; 5 | export * from './schema.types.ts'; 6 | export * from './utils.ts'; 7 | -------------------------------------------------------------------------------- /drizzle-zod/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "esnext", 5 | "target": "esnext", 6 | "noEmit": true, 7 | "rootDir": "..", 8 | "outDir": "./.cache" 9 | }, 10 | "include": [".", "../src"] 11 | } 12 | -------------------------------------------------------------------------------- /drizzle-zod/tests/utils.ts: -------------------------------------------------------------------------------- 1 | import { expect, type TaskContext } from 'vitest'; 2 | import type { z } from 'zod/v4'; 3 | 4 | export function expectSchemaShape>(t: TaskContext, expected: T) { 5 | return { 6 | from(actual: T) { 7 | expect(Object.keys(actual.shape)).toStrictEqual(Object.keys(expected.shape)); 8 | for (const key in Object.keys(actual.shape)) { 9 | expect(actual.shape[key]?._zod.def).toStrictEqual(expected.shape[key]?._zod.def); 10 | } 11 | }, 12 | }; 13 | } 14 | 15 | export function expectEnumValues>(t: TaskContext, expected: T) { 16 | return { 17 | from(actual: T) { 18 | expect(actual.def).toStrictEqual(expected.def); 19 | }, 20 | }; 21 | } 22 | 23 | export function Expect<_ extends true>() {} 24 | -------------------------------------------------------------------------------- /drizzle-zod/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "stripInternal": true 6 | }, 7 | "include": ["src"] 8 | } 9 | -------------------------------------------------------------------------------- /drizzle-zod/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "baseUrl": ".", 6 | "declaration": true, 7 | "noEmit": true, 8 | "paths": { 9 | "~/*": ["src/*"] 10 | } 11 | }, 12 | "include": ["src", "*.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /drizzle-zod/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import tsconfigPaths from 'vite-tsconfig-paths'; 2 | import { defineConfig } from 'vitest/config'; 3 | 4 | export default defineConfig({ 5 | test: { 6 | include: [ 7 | 'tests/**/*.test.ts', 8 | ], 9 | exclude: [ 10 | 'tests/bun/**/*', 11 | ], 12 | typecheck: { 13 | tsconfig: 'tsconfig.json', 14 | }, 15 | testTimeout: 100000, 16 | hookTimeout: 100000, 17 | isolate: false, 18 | poolOptions: { 19 | threads: { 20 | singleThread: true, 21 | }, 22 | }, 23 | }, 24 | plugins: [tsconfigPaths()], 25 | }); 26 | -------------------------------------------------------------------------------- /eslint-plugin-drizzle/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | tsconfig.tsbuildinfo 4 | -------------------------------------------------------------------------------- /eslint-plugin-drizzle/src/configs/all.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | env: { 3 | es2024: true, 4 | }, 5 | parserOptions: { 6 | ecmaVersion: 'latest', 7 | sourceType: 'module', 8 | }, 9 | plugins: ['drizzle'], 10 | rules: { 11 | 'drizzle/enforce-delete-with-where': 'error', 12 | 'drizzle/enforce-update-with-where': 'error', 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /eslint-plugin-drizzle/src/configs/recommended.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | env: { 3 | es2024: true, 4 | }, 5 | parserOptions: { 6 | ecmaVersion: 'latest', 7 | sourceType: 'module', 8 | }, 9 | plugins: ['drizzle'], 10 | rules: { 11 | 'drizzle/enforce-delete-with-where': 'error', 12 | 'drizzle/enforce-update-with-where': 'error', 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /eslint-plugin-drizzle/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { TSESLint } from '@typescript-eslint/utils'; 2 | import { name, version } from '../package.json'; 3 | import all from './configs/all'; 4 | import recommended from './configs/recommended'; 5 | import deleteRule from './enforce-delete-with-where'; 6 | import updateRule from './enforce-update-with-where'; 7 | import type { Options } from './utils/options'; 8 | 9 | export const rules = { 10 | 'enforce-delete-with-where': deleteRule, 11 | 'enforce-update-with-where': updateRule, 12 | } satisfies Record>; 13 | 14 | export const configs = { all, recommended }; 15 | 16 | export const meta = { name, version }; 17 | -------------------------------------------------------------------------------- /eslint-plugin-drizzle/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "noUnusedLocals": true, 5 | "noUnusedParameters": true, 6 | "noImplicitReturns": true, 7 | "noFallthroughCasesInSwitch": true, 8 | "moduleResolution": "nodenext", 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "allowJs": true, 12 | "resolveJsonModule": true, 13 | "lib": [ 14 | "esnext" 15 | ], 16 | "composite": false, 17 | "incremental": false, 18 | "skipLibCheck": true, 19 | "outDir": "dist", 20 | "module": "nodenext", 21 | "target": "es6", 22 | "exactOptionalPropertyTypes": true, 23 | "noUncheckedIndexedAccess": true 24 | }, 25 | "include": [ 26 | "src/**/*.ts", 27 | "package.json" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /eslint-plugin-drizzle/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | 3 | export default defineConfig({ 4 | test: { 5 | globals: true, 6 | exclude: ['**/dist/**'], 7 | }, 8 | }); 9 | -------------------------------------------------------------------------------- /integration-tests/.env.example: -------------------------------------------------------------------------------- 1 | PG_CONNECTION_STRING="postgres://postgres:postgres@localhost:55432/postgres" 2 | MYSQL_CONNECTION_STRING="mysql://root:mysql@127.0.0.1:33306/drizzle" 3 | SINGLESTORE_CONNECTION_STRING="singlestore://root:singlestore@localhost:3306/drizzle" 4 | PLANETSCALE_CONNECTION_STRING= 5 | TIDB_CONNECTION_STRING= 6 | NEON_HTTP_CONNECTION_STRING=postgres://postgres:postgres@db.localtest.me:5432/postgres 7 | NEON_SERVERLESS_CONNECTION_STRING=postgres://postgres:postgres@localhost:5445/postgres 8 | LIBSQL_URL="file:local.db" 9 | LIBSQL_AUTH_TOKEN="ey..." # For Turso only 10 | LIBSQL_REMOTE_URL="libsql://..." 11 | LIBSQL_REMOTE_TOKEN="ey..." 12 | AWS_DATA_API_DB= 13 | AWS_DATA_API_SECRET_ARN= 14 | AWS_DATA_API_RESOURCE_ARN= 15 | AWS_TEST_PROFILE= 16 | VERCEL_CONNECTION_STRING= # For driver-init, utils/is-config tests. Must not be local DB - breaks with Vercel drivers 17 | -------------------------------------------------------------------------------- /integration-tests/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | *.db 3 | trace 4 | tests/imports/imports.cjs 5 | tests/imports/imports.mjs 6 | .sst 7 | -------------------------------------------------------------------------------- /integration-tests/.xata/migrations/.ledger: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /integration-tests/.xata/version/compatibility.json: -------------------------------------------------------------------------------- 1 | { 2 | "@xata.io/cli": { "latest": "0.15.10", "compatibility": [{ "range": ">=0.0.0" }] }, 3 | "@xata.io/client": { "latest": "0.29.3", "compatibility": [{ "range": ">=0.0.0" }] } 4 | } 5 | -------------------------------------------------------------------------------- /integration-tests/.xatarc: -------------------------------------------------------------------------------- 1 | { 2 | "databaseURL": "https://Andrii-Sherman-s-workspace-2r5ujp.us-east-1.xata.sh/db/integration-tests", 3 | "codegen": { 4 | "output": "tests/xata/xata.ts" 5 | } 6 | } -------------------------------------------------------------------------------- /integration-tests/docker-neon.yml: -------------------------------------------------------------------------------- 1 | services: 2 | postgres: 3 | image: 'postgres:latest' 4 | environment: 5 | POSTGRES_USER: postgres 6 | POSTGRES_PASSWORD: postgres 7 | POSTGRES_DB: postgres 8 | ports: 9 | - '5432:5441' 10 | healthcheck: 11 | test: ['CMD-SHELL', 'pg_isready -U postgres'] 12 | interval: 10s 13 | timeout: 5s 14 | retries: 5 15 | neon-proxy: 16 | image: ghcr.io/timowilhelm/local-neon-http-proxy:main 17 | environment: 18 | - PG_CONNECTION_STRING=postgres://postgres:postgres@postgres:5432/postgres 19 | ports: 20 | - '4444:4444' 21 | depends_on: 22 | postgres: 23 | condition: service_healthy 24 | pg_proxy: 25 | image: ghcr.io/neondatabase/wsproxy:latest 26 | environment: 27 | APPEND_PORT: 'postgres:5432' 28 | ALLOW_ADDR_REGEX: '.*' 29 | LOG_TRAFFIC: 'true' 30 | ports: 31 | - '5446:80' 32 | depends_on: 33 | - postgres 34 | -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql-proxy/first/0000_nostalgic_carnage.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `userstest` ( 2 | `id` serial PRIMARY KEY, 3 | `name` text NOT NULL, 4 | `verified` boolean NOT NULL DEFAULT false, 5 | `jsonb` json, 6 | `created_at` timestamp NOT NULL DEFAULT now() 7 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql-proxy/first/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "mysql", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680270921944, 9 | "tag": "0000_nostalgic_carnage", 10 | "breakpoints": true 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql-proxy/second/0000_nostalgic_carnage.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `userstest` ( 2 | `id` serial PRIMARY KEY, 3 | `name` text NOT NULL, 4 | `verified` boolean NOT NULL DEFAULT false, 5 | `jsonb` json, 6 | `created_at` timestamp NOT NULL DEFAULT now() 7 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql-proxy/second/0001_test.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `users12` ( 2 | `id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL, 3 | `name` text NOT NULL, 4 | `email` text NOT NULL 5 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql-proxy/second/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "mysql", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680270921944, 9 | "tag": "0000_nostalgic_carnage", 10 | "breakpoints": true 11 | }, 12 | { 13 | "idx": 1, 14 | "version": "5", 15 | "when": 1680270921945, 16 | "tag": "0001_test", 17 | "breakpoints": true 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql/0000_nostalgic_carnage.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `cities_migration` ( 2 | `id` int, 3 | `fullname_name` text, 4 | `state` text 5 | ); 6 | --> statement-breakpoint 7 | CREATE TABLE `users_migration` ( 8 | `id` int PRIMARY KEY NOT NULL, 9 | `full_name` text, 10 | `phone` int, 11 | `invited_by` int, 12 | `city_id` int, 13 | `date` timestamp DEFAULT (now()) 14 | ); 15 | --> statement-breakpoint 16 | CREATE TABLE `users12` ( 17 | `id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL, 18 | `name` text NOT NULL, 19 | `email` text NOT NULL 20 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/mysql/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "mysql", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680270921944, 9 | "tag": "0000_nostalgic_carnage", 10 | "breakpoints": true 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg-proxy/first/0000_puzzling_flatman.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "users" ( 2 | id serial PRIMARY KEY, 3 | name text NOT NULL, 4 | verified boolean NOT NULL DEFAULT false, 5 | jsonb jsonb, 6 | created_at timestamptz NOT NULL DEFAULT now() 7 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg-proxy/first/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "pg", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680271923328, 9 | "tag": "0000_puzzling_flatman", 10 | "breakpoints": true 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg-proxy/second/0000_puzzling_flatman.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "users" ( 2 | id serial PRIMARY KEY, 3 | name text NOT NULL, 4 | verified boolean NOT NULL DEFAULT false, 5 | jsonb jsonb, 6 | created_at timestamptz NOT NULL DEFAULT now() 7 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg-proxy/second/0001_test.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "users12" ( 2 | "id" serial PRIMARY KEY NOT NULL, 3 | "name" text NOT NULL, 4 | "email" text NOT NULL 5 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg-proxy/second/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "pg", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680271923328, 9 | "tag": "0000_puzzling_flatman", 10 | "breakpoints": true 11 | }, 12 | { 13 | "idx": 1, 14 | "version": "5", 15 | "when": 1680271923329, 16 | "tag": "0001_test", 17 | "breakpoints": true 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg/0001_test.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS "users12" ( 2 | "id" serial PRIMARY KEY NOT NULL, 3 | "name" text NOT NULL, 4 | "email" text NOT NULL 5 | ); -------------------------------------------------------------------------------- /integration-tests/drizzle2/pg/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "pg", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680271923328, 9 | "tag": "0000_puzzling_flatman", 10 | "breakpoints": true 11 | }, 12 | { 13 | "idx": 1, 14 | "version": "5", 15 | "when": 1680271923329, 16 | "tag": "0001_test", 17 | "breakpoints": true 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/planetscale/0000_nostalgic_carnage.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `drizzle_tests_cities_migration` ( 2 | `id` int, 3 | `fullname_name` text, 4 | `state` text 5 | ); 6 | --> statement-breakpoint 7 | CREATE TABLE `drizzle_tests_users_migration` ( 8 | `id` int PRIMARY KEY NOT NULL, 9 | `full_name` text, 10 | `phone` int, 11 | `invited_by` int, 12 | `city_id` int, 13 | `date` timestamp DEFAULT (now()) 14 | ); 15 | --> statement-breakpoint 16 | CREATE TABLE `drizzle_tests_users12` ( 17 | `id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL, 18 | `name` text NOT NULL, 19 | `email` text NOT NULL 20 | ); 21 | -------------------------------------------------------------------------------- /integration-tests/drizzle2/planetscale/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "mysql", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680270921944, 9 | "tag": "0000_nostalgic_carnage", 10 | "breakpoints": true 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /integration-tests/drizzle2/singlestore/0000_nostalgic_carnage.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `cities_migration` ( 2 | `id` int, 3 | `fullname_name` text, 4 | `state` text 5 | ); 6 | --> statement-breakpoint 7 | CREATE TABLE `users_migration` ( 8 | `id` int PRIMARY KEY NOT NULL, 9 | `full_name` text, 10 | `phone` int, 11 | `invited_by` int, 12 | `city_id` int, 13 | `date` timestamp DEFAULT now() 14 | ); 15 | --> statement-breakpoint 16 | CREATE TABLE `users12` ( 17 | `id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL, 18 | `name` text NOT NULL, 19 | `email` text NOT NULL 20 | ); 21 | -------------------------------------------------------------------------------- /integration-tests/drizzle2/singlestore/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "dialect": "singlestore", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "1", 8 | "when": 1680270921944, 9 | "tag": "0000_nostalgic_carnage", 10 | "breakpoints": true 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /integration-tests/drizzle2/sqlite/0000_fancy_bug.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE another_users ( 2 | `id` integer PRIMARY KEY NOT NULL, 3 | `name` text NOT NULL, 4 | `email` text NOT NULL 5 | ); 6 | --> statement-breakpoint 7 | CREATE TABLE users12 ( 8 | `id` integer PRIMARY KEY NOT NULL, 9 | `name` text NOT NULL, 10 | `email` text NOT NULL 11 | ); 12 | -------------------------------------------------------------------------------- /integration-tests/drizzle2/sqlite/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5", 3 | "dialect": "sqlite", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "5", 8 | "when": 1680202256473, 9 | "tag": "0000_fancy_bug", 10 | "breakpoints": true 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /integration-tests/js-tests/driver-init/commonjs/schema.cjs: -------------------------------------------------------------------------------- 1 | const { int: mysqlInt, mysqlTable } = require('drizzle-orm/mysql-core'); 2 | const { integer: pgInt, pgTable } = require('drizzle-orm/pg-core'); 3 | const { integer: sqliteInt, sqliteTable } = require('drizzle-orm/sqlite-core'); 4 | 5 | module.exports.sqlite = { 6 | User: sqliteTable('test', { 7 | id: sqliteInt('id').primaryKey().notNull(), 8 | }), 9 | }; 10 | 11 | module.exports.pg = { 12 | User: pgTable('test', { 13 | id: pgInt('id').primaryKey().notNull(), 14 | }), 15 | }; 16 | 17 | module.exports.mysql = { 18 | User: mysqlTable('test', { 19 | id: mysqlInt('id').primaryKey().notNull(), 20 | }), 21 | }; 22 | -------------------------------------------------------------------------------- /integration-tests/js-tests/driver-init/module/schema.mjs: -------------------------------------------------------------------------------- 1 | import { int as mysqlInt, mysqlTable } from 'drizzle-orm/mysql-core'; 2 | import { integer as pgInt, pgTable } from 'drizzle-orm/pg-core'; 3 | import { integer as sqliteInt, sqliteTable } from 'drizzle-orm/sqlite-core'; 4 | 5 | export const sqlite = { 6 | User: sqliteTable('test', { 7 | id: sqliteInt('id').primaryKey().notNull(), 8 | }), 9 | }; 10 | 11 | export const pg = { 12 | User: pgTable('test', { 13 | id: pgInt('id').primaryKey().notNull(), 14 | }), 15 | }; 16 | 17 | export const mysql = { 18 | User: mysqlTable('test', { 19 | id: mysqlInt('id').primaryKey().notNull(), 20 | }), 21 | }; 22 | -------------------------------------------------------------------------------- /integration-tests/sst-env.d.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/triple-slash-reference 2 | /// 3 | -------------------------------------------------------------------------------- /integration-tests/sst.config.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/triple-slash-reference 2 | /// 3 | 4 | export default $config({ 5 | app(_input) { 6 | return { 7 | name: 'awsdataapi', 8 | removal: 'remove', 9 | home: 'aws', 10 | }; 11 | }, 12 | async run() { 13 | new sst.aws.Postgres('Postgres', { 14 | scaling: { 15 | min: '0.5 ACU', 16 | max: '1 ACU', 17 | }, 18 | }); 19 | }, 20 | }); 21 | -------------------------------------------------------------------------------- /integration-tests/tests/common.ts: -------------------------------------------------------------------------------- 1 | import { beforeEach } from 'vitest'; 2 | 3 | export function skipTests(names: string[]) { 4 | beforeEach((ctx) => { 5 | if (ctx.task.suite?.name === 'common' && names.includes(ctx.task.name)) { 6 | ctx.skip(); 7 | } 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/tests/pg/rls/rls.definition.test.ts: -------------------------------------------------------------------------------- 1 | import { crudPolicy } from 'drizzle-orm/neon'; 2 | import { getTableConfig, integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core'; 3 | import { test } from 'vitest'; 4 | 5 | test.skip('getTableConfig: policies', async () => { 6 | const schema = pgTable('hhh', { 7 | id: integer(), 8 | }, () => [ 9 | pgPolicy('name'), 10 | crudPolicy({ role: pgRole('users'), read: true, modify: true }), 11 | ]); 12 | 13 | const tc = getTableConfig(schema); 14 | 15 | console.log(tc.policies); 16 | }); 17 | -------------------------------------------------------------------------------- /integration-tests/tests/relational/db.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import Database from 'better-sqlite3'; 3 | import { sql } from 'drizzle-orm'; 4 | import { drizzle } from 'drizzle-orm/better-sqlite3'; 5 | import util from 'node:util'; 6 | import * as schema from './tables.ts'; 7 | 8 | async function main() { 9 | const bdb = new Database(process.env['SQLITE_DB_PATH']!); 10 | const db = drizzle(bdb, { schema, logger: true }); 11 | 12 | const result = db.query.users.findMany({ 13 | columns: { 14 | id: true, 15 | name: true, 16 | }, 17 | with: { 18 | posts: { 19 | columns: { 20 | authorId: true, 21 | }, 22 | with: { 23 | comments: true, 24 | }, 25 | extras: { 26 | lower: sql`lower(${schema.posts.title})`.as('lower_name'), 27 | }, 28 | }, 29 | }, 30 | }); 31 | 32 | console.log(util.inspect(result, false, null, true)); 33 | bdb.close(); 34 | } 35 | 36 | main(); 37 | -------------------------------------------------------------------------------- /integration-tests/tests/sqlite/durable-objects/drizzle/0000_cuddly_black_bolt.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `another_users` ( 2 | `id` integer PRIMARY KEY NOT NULL, 3 | `name` text NOT NULL, 4 | `email` text NOT NULL 5 | ); 6 | --> statement-breakpoint 7 | CREATE TABLE `users12` ( 8 | `id` integer PRIMARY KEY NOT NULL, 9 | `name` text NOT NULL, 10 | `email` text NOT NULL 11 | ); 12 | -------------------------------------------------------------------------------- /integration-tests/tests/sqlite/durable-objects/drizzle/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "7", 3 | "dialect": "sqlite", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "6", 8 | "when": 1732696446109, 9 | "tag": "0000_cuddly_black_bolt", 10 | "breakpoints": true 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /integration-tests/tests/sqlite/durable-objects/drizzle/migrations.js: -------------------------------------------------------------------------------- 1 | import m0000 from './0000_cuddly_black_bolt.sql'; 2 | import journal from './meta/_journal.json'; 3 | 4 | export default { 5 | journal, 6 | migrations: { 7 | m0000, 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /integration-tests/tests/sqlite/durable-objects/worker-configuration.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by Wrangler by running `wrangler types` 2 | 3 | interface Env { 4 | MY_DURABLE_OBJECT: DurableObjectNamespace; 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/tests/sqlite/durable-objects/wrangler.toml: -------------------------------------------------------------------------------- 1 | #:schema node_modules/wrangler/config-schema.json 2 | name = "sqlite-durable-objects" 3 | main = "index.ts" 4 | compatibility_date = "2024-11-12" 5 | compatibility_flags = [ "nodejs_compat" ] 6 | 7 | # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model. 8 | # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps. 9 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects 10 | [[durable_objects.bindings]] 11 | name = "MY_DURABLE_OBJECT" 12 | class_name = "MyDurableObject" 13 | 14 | # Durable Object migrations. 15 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations 16 | [[migrations]] 17 | tag = "v1" 18 | new_sqlite_classes = ["MyDurableObject"] 19 | 20 | [[rules]] 21 | type = "Text" 22 | globs = ["**/*.sql"] 23 | fallthrough = true 24 | 25 | 26 | -------------------------------------------------------------------------------- /integration-tests/tests/utils.ts: -------------------------------------------------------------------------------- 1 | // shut up eslint you cannot possibly comprehend what's happening here 2 | // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars 3 | export function Expect() {} 4 | 5 | export type Equal = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? true 6 | : false; 7 | 8 | export function toLocalDate(date: Date) { 9 | const localTime = new Date(date.getTime() - date.getTimezoneOffset() * 60000); 10 | localTime.setUTCHours(0); 11 | return localTime; 12 | } 13 | 14 | export const randomString = () => 15 | Array.from({ length: 10 }, () => 'abcdefghijklmnopqrstuvwxyz'[Math.floor(Math.random() * 26)]).join(''); 16 | -------------------------------------------------------------------------------- /integration-tests/tests/version.test.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | 3 | import * as version from 'drizzle-orm/version'; 4 | import { expect, test } from 'vitest'; 5 | import { z } from 'zod'; 6 | 7 | test('shape', () => { 8 | const shape = z.object({ 9 | compatibilityVersion: z.number(), 10 | npmVersion: z.string(), 11 | }); 12 | expect(() => shape.parse(version)).not.toThrowError(); 13 | }); 14 | -------------------------------------------------------------------------------- /integration-tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "checkJs": false, 5 | "noEmit": true, 6 | "paths": { 7 | "~/*": ["./tests/*"] 8 | } 9 | }, 10 | "include": ["tests", "type-tests"], 11 | "exclude": ["**/playground", "**/.sst", "tests/prisma/*/client/**/*.js"] 12 | } 13 | -------------------------------------------------------------------------------- /integration-tests/vitest-ci.config.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import tsconfigPaths from 'vite-tsconfig-paths'; 3 | import { defineConfig } from 'vitest/config'; 4 | 5 | export default defineConfig({ 6 | test: { 7 | typecheck: { 8 | tsconfig: 'tsconfig.json', 9 | }, 10 | testTimeout: 100000, 11 | hookTimeout: 200000, 12 | isolate: true, 13 | poolOptions: { 14 | threads: { 15 | singleThread: true, 16 | }, 17 | }, 18 | maxWorkers: 1, 19 | fileParallelism: false, 20 | }, 21 | plugins: [tsconfigPaths()], 22 | }); 23 | -------------------------------------------------------------------------------- /patches/typescript@5.6.3.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lib/tsserver.js b/lib/tsserver.js 2 | index 3f1ce62663e3c32aa487f0fc7dcb3dd940e7cd24..559f2f70531180c5d54d98b18ae54a67eab54e1d 100644 3 | --- a/lib/tsserver.js 4 | +++ b/lib/tsserver.js 5 | @@ -15203,7 +15203,7 @@ function isInternalDeclaration(node, sourceFile) { 6 | // src/compiler/utilities.ts 7 | var resolvingEmptyArray = []; 8 | var externalHelpersModuleNameText = "tslib"; 9 | -var defaultMaximumTruncationLength = 160; 10 | +var defaultMaximumTruncationLength = 1e6; 11 | var noTruncationMaximumTruncationLength = 1e6; 12 | function getDeclarationOfKind(symbol, kind) { 13 | const declarations = symbol.declarations; 14 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - drizzle-orm 3 | - drizzle-kit 4 | - drizzle-zod 5 | - drizzle-typebox 6 | - drizzle-valibot 7 | - drizzle-arktype 8 | - drizzle-seed 9 | - integration-tests 10 | - eslint-plugin-drizzle 11 | onlyBuiltDependencies: 12 | - '@contrast/fn-inspect' 13 | - '@newrelic/native-metrics' 14 | - '@prisma/client' 15 | - '@prisma/engines' 16 | - better-sqlite3 17 | - bufferutil 18 | - cpu-features 19 | - dprint 20 | - es5-ext 21 | - esbuild 22 | - prisma 23 | - protobufjs 24 | - sqlite3 25 | - ssh2 26 | - utf-8-validate 27 | - workerd 28 | --------------------------------------------------------------------------------