From 46b9546d78698c40a9000f49ca2bd7bb1c0e79dd Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Mon, 23 Jan 2023 12:48:25 +0100 Subject: [PATCH 1/8] Move all ORM files to drizzle-orm --- drizzle-orm-mysql/package.json | 45 ------------- drizzle-orm-mysql/tsconfig.json | 10 --- drizzle-orm-pg/package.json | 58 ---------------- drizzle-orm-pg/src/.gitignore | 0 drizzle-orm-pg/tsconfig.json | 12 ---- drizzle-orm-sqlite/package.json | 66 ------------------- drizzle-orm-sqlite/src/.gitignore | 0 drizzle-orm-sqlite/tsconfig.build.json | 8 --- drizzle-orm-sqlite/tsconfig.json | 11 ---- drizzle-orm/package.json | 64 +++++++++++++++--- .../src/better-sqlite3/driver.ts | 0 .../src/better-sqlite3}/index.ts | 0 .../src/better-sqlite3/migrator.ts | 0 .../src/better-sqlite3/session.ts | 0 .../src/bun/driver.ts | 0 .../neondb => drizzle-orm/src/bun}/index.ts | 0 .../src/bun/migrator.ts | 0 .../src/bun/session.ts | 0 .../src/d1/driver.ts | 0 .../src/node => drizzle-orm/src/d1}/index.ts | 0 .../src/d1/migrator.ts | 0 .../src/d1/session.ts | 0 .../src/mysql-common}/README.md | 0 .../src/mysql-common}/alias.ts | 0 .../src/mysql-common}/checks.ts | 0 .../src/mysql-common}/columns/bigint.ts | 0 .../src/mysql-common}/columns/binary.ts | 0 .../src/mysql-common}/columns/boolean.ts | 0 .../src/mysql-common}/columns/char.ts | 0 .../src/mysql-common}/columns/common.ts | 0 .../src/mysql-common}/columns/custom.ts | 0 .../src/mysql-common}/columns/date.common.ts | 0 .../src/mysql-common}/columns/date.ts | 0 .../src/mysql-common}/columns/datetime.ts | 0 .../src/mysql-common}/columns/decimal.ts | 0 .../src/mysql-common}/columns/double.ts | 0 .../src/mysql-common}/columns/enum.ts | 0 .../src/mysql-common}/columns/float.ts | 0 .../src/mysql-common}/columns/index.ts | 0 .../src/mysql-common}/columns/int.ts | 0 .../src/mysql-common}/columns/json.ts | 0 .../src/mysql-common}/columns/mediumint.ts | 0 .../src/mysql-common}/columns/real.ts | 0 .../src/mysql-common}/columns/serial.ts | 0 .../src/mysql-common}/columns/smallint.ts | 0 .../src/mysql-common}/columns/text.ts | 0 .../src/mysql-common}/columns/time.ts | 0 .../src/mysql-common}/columns/timestamp.ts | 0 .../src/mysql-common}/columns/tinyint.ts | 0 .../src/mysql-common}/columns/varbinary.ts | 0 .../src/mysql-common}/columns/varchar.ts | 0 .../src/mysql-common}/columns/year.ts | 0 .../src/mysql-common}/db.ts | 0 .../src/mysql-common}/dialect.ts | 0 .../src/mysql-common}/expressions.ts | 0 .../src/mysql-common}/foreign-keys.ts | 0 .../src/mysql-common}/index.ts | 0 .../src/mysql-common}/indexes.ts | 0 .../src/mysql-common}/operations.ts | 0 .../mysql-common}/query-builders/delete.ts | 0 .../src/mysql-common}/query-builders/index.ts | 0 .../mysql-common}/query-builders/insert.ts | 0 .../mysql-common}/query-builders/select.ts | 0 .../query-builders/select.types.ts | 0 .../mysql-common}/query-builders/update.ts | 0 .../src/mysql-common}/session.ts | 0 .../src/mysql-common}/table.ts | 0 .../src/mysql-common}/tsconfig.build.json | 0 .../src/mysql-common}/utils.ts | 0 .../src/mysql2/driver.ts | 0 .../src/mysql2}/index.ts | 0 .../src/mysql2/migrator.ts | 0 .../src/mysql2/session.ts | 0 .../src/neondb/driver.ts | 0 .../src/neondb}/index.ts | 0 .../src/neondb/migrator.ts | 0 .../src/neondb/session.ts | 0 .../src/pg-common}/README.md | 0 .../src/pg-common}/alias.ts | 0 .../src/pg-common}/checks.ts | 0 .../src/pg-common}/columns/bigint.ts | 0 .../src/pg-common}/columns/bigserial.ts | 0 .../src/pg-common}/columns/boolean.ts | 0 .../src/pg-common}/columns/common.ts | 0 .../src/pg-common}/columns/custom.ts | 0 .../src/pg-common}/columns/date.common.ts | 0 .../src/pg-common}/columns/date.ts | 0 .../pg-common}/columns/double-precision.ts | 0 .../src/pg-common}/columns/enum.ts | 0 .../src/pg-common}/columns/index.ts | 0 .../src/pg-common}/columns/integer.ts | 0 .../src/pg-common}/columns/interval.ts | 0 .../src/pg-common}/columns/json.ts | 0 .../src/pg-common}/columns/jsonb.ts | 0 .../src/pg-common}/columns/numeric.ts | 0 .../src/pg-common}/columns/real.ts | 0 .../src/pg-common}/columns/serial.ts | 0 .../src/pg-common}/columns/smallint.ts | 0 .../src/pg-common}/columns/smallserial.ts | 0 .../src/pg-common}/columns/text.ts | 0 .../src/pg-common}/columns/time.ts | 0 .../src/pg-common}/columns/timestamp.ts | 0 .../src/pg-common}/columns/uuid.ts | 0 .../src/pg-common}/columns/varchar.ts | 0 .../src => drizzle-orm/src/pg-common}/db.ts | 0 .../src/pg-common}/dialect.ts | 0 .../src/pg-common}/expressions.ts | 0 .../src/pg-common}/foreign-keys.ts | 0 .../src/pg-common}/index.ts | 0 .../src/pg-common}/indexes.ts | 0 .../src/pg-common}/node/driver.ts | 0 .../src/pg-common/node}/index.ts | 0 .../src/pg-common}/node/migrator.ts | 0 .../src/pg-common}/node/session.ts | 0 .../src/pg-common}/operations.ts | 0 .../src/pg-common}/query-builders/delete.ts | 0 .../src/pg-common}/query-builders/index.ts | 0 .../src/pg-common}/query-builders/insert.ts | 0 .../src/pg-common}/query-builders/select.ts | 0 .../pg-common}/query-builders/select.types.ts | 0 .../src/pg-common}/query-builders/update.ts | 0 .../src/pg-common}/session.ts | 0 .../src/pg-common}/table.ts | 0 .../src/pg-common}/utils.ts | 0 .../src/postgres.js/README.md | 0 .../src/postgres.js/driver.ts | 0 .../src/postgres.js}/index.ts | 0 .../src/postgres.js/migrator.ts | 0 .../src/postgres.js/session.ts | 0 .../src/sql.js/driver.ts | 0 .../src/sql.js/index.ts | 0 .../src/sql.js/migrator.ts | 0 .../src/sql.js/session.ts | 0 .../src/sqlite-common}/README.md | 0 .../src/sqlite-common}/alias.ts | 0 .../src/sqlite-common}/checks.ts | 0 .../src/sqlite-common}/columns/blob.ts | 0 .../src/sqlite-common}/columns/common.ts | 0 .../src/sqlite-common}/columns/index.ts | 0 .../src/sqlite-common}/columns/integer.ts | 0 .../src/sqlite-common}/columns/numeric.ts | 0 .../src/sqlite-common}/columns/real.ts | 0 .../src/sqlite-common}/columns/text.ts | 0 .../src/sqlite-common}/db.ts | 0 .../src/sqlite-common}/dialect.ts | 0 .../src/sqlite-common}/expressions.ts | 0 .../src/sqlite-common}/foreign-keys.ts | 0 .../src/sqlite-common}/index.ts | 0 .../src/sqlite-common}/indexes.ts | 0 .../src/sqlite-common}/operations.ts | 0 .../src/sqlite-common}/primary-keys.ts | 0 .../sqlite-common}/query-builders/delete.ts | 0 .../sqlite-common}/query-builders/index.ts | 0 .../sqlite-common}/query-builders/insert.ts | 0 .../sqlite-common}/query-builders/select.ts | 0 .../query-builders/select.types.ts | 0 .../sqlite-common}/query-builders/update.ts | 0 .../src/sqlite-common}/session.ts | 0 .../src/sqlite-common}/table.ts | 0 .../src/sqlite-common}/unique-constraint.ts | 0 .../src/sqlite-common}/utils.ts | 0 .../tests/mysql}/dan/1-to-1-fk.ts | 0 .../tests/mysql}/dan/db.ts | 0 .../tests/mysql}/dan/delete.ts | 0 .../tests/mysql}/dan/insert.ts | 0 .../tests/mysql}/dan/select.ts | 0 .../tests/mysql}/dan/tables.ts | 0 .../tests/mysql}/tsconfig.json | 0 .../tests/mysql}/utils.ts | 0 .../tests/pg}/dan/1-to-1-fk.ts | 0 .../tests => drizzle-orm/tests/pg}/dan/db.ts | 0 .../tests/pg}/dan/delete.ts | 0 .../tests/pg}/dan/insert.ts | 0 .../tests/pg}/dan/other.ts | 0 .../tests/pg}/dan/select.ts | 0 .../tests/pg}/dan/tables.ts | 0 .../tests/pg}/dan/update.ts | 0 .../tests/pg}/tsconfig.json | 0 .../tests => drizzle-orm/tests/pg}/utils.ts | 0 .../tests/sqlite}/.gitignore | 0 .../tests/sqlite}/dan/db.ts | 0 .../tests/sqlite}/dan/delete.ts | 0 .../tests/sqlite}/dan/insert.ts | 0 .../tests/sqlite}/dan/other.ts | 0 .../tests/sqlite}/dan/select.ts | 0 .../tests/sqlite}/dan/tables.ts | 0 .../tests/sqlite}/dan/update.ts | 0 .../tests/sqlite}/tsconfig.json | 0 .../tests/sqlite}/utils.ts | 0 drizzle-orm/tsconfig.json | 8 ++- drizzle-zod/package.json | 3 - integration-tests/package.json | 3 - 192 files changed, 60 insertions(+), 228 deletions(-) delete mode 100644 drizzle-orm-mysql/package.json delete mode 100644 drizzle-orm-mysql/tsconfig.json delete mode 100644 drizzle-orm-pg/package.json delete mode 100644 drizzle-orm-pg/src/.gitignore delete mode 100644 drizzle-orm-pg/tsconfig.json delete mode 100644 drizzle-orm-sqlite/package.json delete mode 100644 drizzle-orm-sqlite/src/.gitignore delete mode 100644 drizzle-orm-sqlite/tsconfig.build.json delete mode 100644 drizzle-orm-sqlite/tsconfig.json rename {drizzle-orm-sqlite => drizzle-orm}/src/better-sqlite3/driver.ts (100%) rename {drizzle-orm-mysql/src/mysql2 => drizzle-orm/src/better-sqlite3}/index.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/better-sqlite3/migrator.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/better-sqlite3/session.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/bun/driver.ts (100%) rename {drizzle-orm-pg/src/neondb => drizzle-orm/src/bun}/index.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/bun/migrator.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/bun/session.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/d1/driver.ts (100%) rename {drizzle-orm-pg/src/node => drizzle-orm/src/d1}/index.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/d1/migrator.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/d1/session.ts (100%) rename {drizzle-orm-mysql => drizzle-orm/src/mysql-common}/README.md (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/alias.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/checks.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/bigint.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/binary.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/boolean.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/char.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/common.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/custom.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/date.common.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/date.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/datetime.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/decimal.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/double.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/enum.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/float.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/index.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/int.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/json.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/mediumint.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/real.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/serial.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/smallint.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/text.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/time.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/timestamp.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/tinyint.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/varbinary.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/varchar.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/columns/year.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/db.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/dialect.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/expressions.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/foreign-keys.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/index.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/indexes.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/operations.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/query-builders/delete.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/query-builders/index.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/query-builders/insert.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/query-builders/select.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/query-builders/select.types.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/query-builders/update.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/session.ts (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/table.ts (100%) rename {drizzle-orm-mysql => drizzle-orm/src/mysql-common}/tsconfig.build.json (100%) rename {drizzle-orm-mysql/src => drizzle-orm/src/mysql-common}/utils.ts (100%) rename {drizzle-orm-mysql => drizzle-orm}/src/mysql2/driver.ts (100%) rename {drizzle-orm-pg/src/postgres.js => drizzle-orm/src/mysql2}/index.ts (100%) rename {drizzle-orm-mysql => drizzle-orm}/src/mysql2/migrator.ts (100%) rename {drizzle-orm-mysql => drizzle-orm}/src/mysql2/session.ts (100%) rename {drizzle-orm-pg => drizzle-orm}/src/neondb/driver.ts (100%) rename {drizzle-orm-sqlite/src/better-sqlite3 => drizzle-orm/src/neondb}/index.ts (100%) rename {drizzle-orm-pg => drizzle-orm}/src/neondb/migrator.ts (100%) rename {drizzle-orm-pg => drizzle-orm}/src/neondb/session.ts (100%) rename {drizzle-orm-pg => drizzle-orm/src/pg-common}/README.md (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/alias.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/checks.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/bigint.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/bigserial.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/boolean.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/common.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/custom.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/date.common.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/date.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/double-precision.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/enum.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/index.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/integer.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/interval.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/json.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/jsonb.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/numeric.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/real.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/serial.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/smallint.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/smallserial.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/text.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/time.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/timestamp.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/uuid.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/columns/varchar.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/db.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/dialect.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/expressions.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/foreign-keys.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/index.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/indexes.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/node/driver.ts (100%) rename {drizzle-orm-sqlite/src/bun => drizzle-orm/src/pg-common/node}/index.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/node/migrator.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/node/session.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/operations.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/query-builders/delete.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/query-builders/index.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/query-builders/insert.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/query-builders/select.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/query-builders/select.types.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/query-builders/update.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/session.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/table.ts (100%) rename {drizzle-orm-pg/src => drizzle-orm/src/pg-common}/utils.ts (100%) rename {drizzle-orm-pg => drizzle-orm}/src/postgres.js/README.md (100%) rename {drizzle-orm-pg => drizzle-orm}/src/postgres.js/driver.ts (100%) rename {drizzle-orm-sqlite/src/d1 => drizzle-orm/src/postgres.js}/index.ts (100%) rename {drizzle-orm-pg => drizzle-orm}/src/postgres.js/migrator.ts (100%) rename {drizzle-orm-pg => drizzle-orm}/src/postgres.js/session.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/sql.js/driver.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/sql.js/index.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/sql.js/migrator.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm}/src/sql.js/session.ts (100%) rename {drizzle-orm-sqlite => drizzle-orm/src/sqlite-common}/README.md (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/alias.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/checks.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/blob.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/common.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/index.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/integer.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/numeric.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/real.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/columns/text.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/db.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/dialect.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/expressions.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/foreign-keys.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/index.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/indexes.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/operations.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/primary-keys.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/query-builders/delete.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/query-builders/index.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/query-builders/insert.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/query-builders/select.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/query-builders/select.types.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/query-builders/update.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/session.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/table.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/unique-constraint.ts (100%) rename {drizzle-orm-sqlite/src => drizzle-orm/src/sqlite-common}/utils.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/dan/1-to-1-fk.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/dan/db.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/dan/delete.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/dan/insert.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/dan/select.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/dan/tables.ts (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/tsconfig.json (100%) rename {drizzle-orm-mysql/tests => drizzle-orm/tests/mysql}/utils.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/1-to-1-fk.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/db.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/delete.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/insert.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/other.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/select.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/tables.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/dan/update.ts (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/tsconfig.json (100%) rename {drizzle-orm-pg/tests => drizzle-orm/tests/pg}/utils.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/.gitignore (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/db.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/delete.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/insert.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/other.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/select.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/tables.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/dan/update.ts (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/tsconfig.json (100%) rename {drizzle-orm-sqlite/tests => drizzle-orm/tests/sqlite}/utils.ts (100%) diff --git a/drizzle-orm-mysql/package.json b/drizzle-orm-mysql/package.json deleted file mode 100644 index d63a0fb97..000000000 --- a/drizzle-orm-mysql/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "drizzle-orm-mysql", - "version": "0.16.1", - "description": "Drizzle ORM package for MySQL database", - "scripts": { - "build": "tsc -p tsconfig.build.json && resolve-tspaths && cp README.md package.json dist/", - "test:types": "cd tests && tsc", - "pack": "cp package.json dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz", - "publish": "npm publish package.tgz" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/drizzle-team/drizzle-orm.git" - }, - "keywords": [ - "orm", - "mysql", - "database", - "sql", - "typescript", - "drizzle", - "drizzle-orm", - "drizzle-orm-mysql" - ], - "author": "Drizzle Team", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/drizzle-team/drizzle-orm/issues" - }, - "homepage": "https://github.com/drizzle-team/drizzle-orm#readme", - "peerDependencies": { - "drizzle-orm": ">=0.15 <0.16", - "mysql2": ">=2 <3" - }, - "peerDependenciesMeta": { - "mysql2": { - "optional": true - } - }, - "devDependencies": { - "@types/node": "^18.11.12", - "drizzle-orm": "link:../drizzle-orm/dist", - "mysql2": "^2.3.3" - } -} diff --git a/drizzle-orm-mysql/tsconfig.json b/drizzle-orm-mysql/tsconfig.json deleted file mode 100644 index 3df86785c..000000000 --- a/drizzle-orm-mysql/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - "paths": { - "~/*": ["src/*"] - } - } -} diff --git a/drizzle-orm-pg/package.json b/drizzle-orm-pg/package.json deleted file mode 100644 index 2eee102cc..000000000 --- a/drizzle-orm-pg/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "drizzle-orm-pg", - "version": "0.16.2", - "description": "Drizzle ORM package for PostgreSQL database", - "scripts": { - "build": "tsc --build && resolve-tspaths && cp README.md package.json dist/", - "test:types": "cd tests && tsc", - "pack": "cp package.json dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz", - "publish": "npm publish package.tgz" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/drizzle-team/drizzle-orm.git" - }, - "keywords": [ - "orm", - "pg", - "postgres", - "postgresql", - "database", - "sql", - "typescript" - ], - "author": "Drizzle Team", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/drizzle-team/drizzle-orm/issues" - }, - "homepage": "https://github.com/drizzle-team/drizzle-orm#readme", - "peerDependencies": { - "@types/pg": ">=8 <9", - "drizzle-orm": ">=0.15 <0.16", - "pg": ">=8 <9", - "postgres": ">=3 <4", - "@neondatabase/serverless": ">=0.1 <0.2" - }, - "peerDependenciesMeta": { - "pg": { - "optional": true - }, - "@types/pg": { - "optional": true - }, - "postgres": { - "optional": true - }, - "@neondatabase/serverless": { - "optional": true - } - }, - "devDependencies": { - "@neondatabase/serverless": "^0.1.13", - "@types/pg": "^8.6.5", - "drizzle-orm": "link:../drizzle-orm/dist", - "pg": "^8.8.0", - "postgres": "^3.3.3" - } -} diff --git a/drizzle-orm-pg/src/.gitignore b/drizzle-orm-pg/src/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/drizzle-orm-pg/tsconfig.json b/drizzle-orm-pg/tsconfig.json deleted file mode 100644 index 8b4c5ffe6..000000000 --- a/drizzle-orm-pg/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "./dist", - "baseUrl": ".", - "paths": { - "~/*": ["src/*"] - } - }, - "include": ["src"] -} diff --git a/drizzle-orm-sqlite/package.json b/drizzle-orm-sqlite/package.json deleted file mode 100644 index 000bab83a..000000000 --- a/drizzle-orm-sqlite/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "drizzle-orm-sqlite", - "version": "0.16.0", - "description": "Drizzle ORM package for SQLite database", - "scripts": { - "build": "tsc -p tsconfig.build.json && resolve-tspaths && cp README.md package.json dist/", - "test:types": "cd tests && tsc", - "pack": "cp package.json dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz", - "publish": "npm publish package.tgz" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/drizzle-team/drizzle-orm.git" - }, - "keywords": [ - "orm", - "sqlite", - "database", - "sql", - "typescript" - ], - "author": "Drizzle Team", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/drizzle-team/drizzle-orm/issues" - }, - "homepage": "https://github.com/drizzle-team/drizzle-orm#readme", - "peerDependencies": { - "@cloudflare/workers-types": ">=3", - "@types/better-sqlite3": "*", - "better-sqlite3": ">=7 <9", - "drizzle-orm": ">=0.15 <0.16", - "sqlite3": ">=5 <6", - "sql.js": ">=1 <2", - "@types/sql.js": "*" - }, - "peerDependenciesMeta": { - "better-sqlite3": { - "optional": true - }, - "@types/better-sqlite3": { - "optional": true - }, - "sqlite3": { - "optional": true - }, - "sql.js": { - "optional": true - }, - "@types/sql.js": { - "optional": true - }, - "@cloudflare/workers-types": { - "optional": true - } - }, - "devDependencies": { - "@cloudflare/workers-types": "^3.18.0", - "@types/better-sqlite3": "^7.6.2", - "@types/sql.js": "^1.4.4", - "better-sqlite3": "^7.6.2", - "drizzle-orm": "link:../drizzle-orm/dist", - "sql.js": "^1.8.0", - "sqlite3": "^5.1.2" - } -} diff --git a/drizzle-orm-sqlite/src/.gitignore b/drizzle-orm-sqlite/src/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/drizzle-orm-sqlite/tsconfig.build.json b/drizzle-orm-sqlite/tsconfig.build.json deleted file mode 100644 index 266158dd3..000000000 --- a/drizzle-orm-sqlite/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/drizzle-orm-sqlite/tsconfig.json b/drizzle-orm-sqlite/tsconfig.json deleted file mode 100644 index c76d7b3cc..000000000 --- a/drizzle-orm-sqlite/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - "paths": { - "~/*": ["src/*"] - }, - "types": ["bun-types", "@cloudflare/workers-types"] - } -} diff --git a/drizzle-orm/package.json b/drizzle-orm/package.json index fb15334b9..0a6b15bbc 100644 --- a/drizzle-orm/package.json +++ b/drizzle-orm/package.json @@ -3,8 +3,8 @@ "version": "0.16.0", "description": "Drizzle ORM package for SQL databases", "scripts": { - "build": "tsc && cp ../README.md package.json dist/", - "test:types": "echo WARN: No tests defined!", + "build": "tsc && resolve-tspaths && cp ../README.md package.json dist/", + "test:types": "cd tests && tsc", "pack": "cp package.json dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz", "publish": "npm publish package.tgz" }, @@ -23,7 +23,8 @@ "database", "sql", "typescript", - "ts" + "ts", + "drizzle-orm" ], "author": "Drizzle Team", "license": "Apache-2.0", @@ -32,22 +33,65 @@ }, "homepage": "https://github.com/drizzle-team/drizzle-orm#readme", "peerDependencies": { - "drizzle-orm-mysql": ">=0.15 <0.16", - "drizzle-orm-pg": ">=0.15 <0.16", - "drizzle-orm-sqlite": ">=0.15 <0.16" + "mysql2": ">=2 <3", + "@cloudflare/workers-types": ">=3", + "@types/better-sqlite3": "*", + "better-sqlite3": ">=7 <9", + "sqlite3": ">=5 <6", + "sql.js": ">=1 <2", + "@types/sql.js": "*", + "@types/pg": "*", + "pg": ">=8 <9", + "postgres": ">=3 <4", + "@neondatabase/serverless": ">=0.1 <0.2" }, "peerDependenciesMeta": { - "drizzle-orm-mysql": { + "mysql2": { "optional": true }, - "drizzle-orm-pg": { + "better-sqlite3": { "optional": true }, - "drizzle-orm-sqlite": { + "@types/better-sqlite3": { + "optional": true + }, + "sqlite3": { + "optional": true + }, + "sql.js": { + "optional": true + }, + "@types/sql.js": { + "optional": true + }, + "@cloudflare/workers-types": { + "optional": true + }, + "pg": { + "optional": true + }, + "@types/pg": { + "optional": true + }, + "postgres": { + "optional": true + }, + "@neondatabase/serverless": { "optional": true } }, "devDependencies": { - "@types/node": "^18.11.9" + "@types/node": "^18.11.9", + "mysql2": "^2.3.3", + "@cloudflare/workers-types": "^3.18.0", + "@types/better-sqlite3": "^7.6.2", + "@types/sql.js": "^1.4.4", + "better-sqlite3": "^7.6.2", + "sql.js": "^1.8.0", + "sqlite3": "^5.1.2", + "@neondatabase/serverless": "^0.1.13", + "@types/pg": "^8.6.5", + "pg": "^8.8.0", + "postgres": "^3.3.3" } } diff --git a/drizzle-orm-sqlite/src/better-sqlite3/driver.ts b/drizzle-orm/src/better-sqlite3/driver.ts similarity index 100% rename from drizzle-orm-sqlite/src/better-sqlite3/driver.ts rename to drizzle-orm/src/better-sqlite3/driver.ts diff --git a/drizzle-orm-mysql/src/mysql2/index.ts b/drizzle-orm/src/better-sqlite3/index.ts similarity index 100% rename from drizzle-orm-mysql/src/mysql2/index.ts rename to drizzle-orm/src/better-sqlite3/index.ts diff --git a/drizzle-orm-sqlite/src/better-sqlite3/migrator.ts b/drizzle-orm/src/better-sqlite3/migrator.ts similarity index 100% rename from drizzle-orm-sqlite/src/better-sqlite3/migrator.ts rename to drizzle-orm/src/better-sqlite3/migrator.ts diff --git a/drizzle-orm-sqlite/src/better-sqlite3/session.ts b/drizzle-orm/src/better-sqlite3/session.ts similarity index 100% rename from drizzle-orm-sqlite/src/better-sqlite3/session.ts rename to drizzle-orm/src/better-sqlite3/session.ts diff --git a/drizzle-orm-sqlite/src/bun/driver.ts b/drizzle-orm/src/bun/driver.ts similarity index 100% rename from drizzle-orm-sqlite/src/bun/driver.ts rename to drizzle-orm/src/bun/driver.ts diff --git a/drizzle-orm-pg/src/neondb/index.ts b/drizzle-orm/src/bun/index.ts similarity index 100% rename from drizzle-orm-pg/src/neondb/index.ts rename to drizzle-orm/src/bun/index.ts diff --git a/drizzle-orm-sqlite/src/bun/migrator.ts b/drizzle-orm/src/bun/migrator.ts similarity index 100% rename from drizzle-orm-sqlite/src/bun/migrator.ts rename to drizzle-orm/src/bun/migrator.ts diff --git a/drizzle-orm-sqlite/src/bun/session.ts b/drizzle-orm/src/bun/session.ts similarity index 100% rename from drizzle-orm-sqlite/src/bun/session.ts rename to drizzle-orm/src/bun/session.ts diff --git a/drizzle-orm-sqlite/src/d1/driver.ts b/drizzle-orm/src/d1/driver.ts similarity index 100% rename from drizzle-orm-sqlite/src/d1/driver.ts rename to drizzle-orm/src/d1/driver.ts diff --git a/drizzle-orm-pg/src/node/index.ts b/drizzle-orm/src/d1/index.ts similarity index 100% rename from drizzle-orm-pg/src/node/index.ts rename to drizzle-orm/src/d1/index.ts diff --git a/drizzle-orm-sqlite/src/d1/migrator.ts b/drizzle-orm/src/d1/migrator.ts similarity index 100% rename from drizzle-orm-sqlite/src/d1/migrator.ts rename to drizzle-orm/src/d1/migrator.ts diff --git a/drizzle-orm-sqlite/src/d1/session.ts b/drizzle-orm/src/d1/session.ts similarity index 100% rename from drizzle-orm-sqlite/src/d1/session.ts rename to drizzle-orm/src/d1/session.ts diff --git a/drizzle-orm-mysql/README.md b/drizzle-orm/src/mysql-common/README.md similarity index 100% rename from drizzle-orm-mysql/README.md rename to drizzle-orm/src/mysql-common/README.md diff --git a/drizzle-orm-mysql/src/alias.ts b/drizzle-orm/src/mysql-common/alias.ts similarity index 100% rename from drizzle-orm-mysql/src/alias.ts rename to drizzle-orm/src/mysql-common/alias.ts diff --git a/drizzle-orm-mysql/src/checks.ts b/drizzle-orm/src/mysql-common/checks.ts similarity index 100% rename from drizzle-orm-mysql/src/checks.ts rename to drizzle-orm/src/mysql-common/checks.ts diff --git a/drizzle-orm-mysql/src/columns/bigint.ts b/drizzle-orm/src/mysql-common/columns/bigint.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/bigint.ts rename to drizzle-orm/src/mysql-common/columns/bigint.ts diff --git a/drizzle-orm-mysql/src/columns/binary.ts b/drizzle-orm/src/mysql-common/columns/binary.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/binary.ts rename to drizzle-orm/src/mysql-common/columns/binary.ts diff --git a/drizzle-orm-mysql/src/columns/boolean.ts b/drizzle-orm/src/mysql-common/columns/boolean.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/boolean.ts rename to drizzle-orm/src/mysql-common/columns/boolean.ts diff --git a/drizzle-orm-mysql/src/columns/char.ts b/drizzle-orm/src/mysql-common/columns/char.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/char.ts rename to drizzle-orm/src/mysql-common/columns/char.ts diff --git a/drizzle-orm-mysql/src/columns/common.ts b/drizzle-orm/src/mysql-common/columns/common.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/common.ts rename to drizzle-orm/src/mysql-common/columns/common.ts diff --git a/drizzle-orm-mysql/src/columns/custom.ts b/drizzle-orm/src/mysql-common/columns/custom.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/custom.ts rename to drizzle-orm/src/mysql-common/columns/custom.ts diff --git a/drizzle-orm-mysql/src/columns/date.common.ts b/drizzle-orm/src/mysql-common/columns/date.common.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/date.common.ts rename to drizzle-orm/src/mysql-common/columns/date.common.ts diff --git a/drizzle-orm-mysql/src/columns/date.ts b/drizzle-orm/src/mysql-common/columns/date.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/date.ts rename to drizzle-orm/src/mysql-common/columns/date.ts diff --git a/drizzle-orm-mysql/src/columns/datetime.ts b/drizzle-orm/src/mysql-common/columns/datetime.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/datetime.ts rename to drizzle-orm/src/mysql-common/columns/datetime.ts diff --git a/drizzle-orm-mysql/src/columns/decimal.ts b/drizzle-orm/src/mysql-common/columns/decimal.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/decimal.ts rename to drizzle-orm/src/mysql-common/columns/decimal.ts diff --git a/drizzle-orm-mysql/src/columns/double.ts b/drizzle-orm/src/mysql-common/columns/double.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/double.ts rename to drizzle-orm/src/mysql-common/columns/double.ts diff --git a/drizzle-orm-mysql/src/columns/enum.ts b/drizzle-orm/src/mysql-common/columns/enum.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/enum.ts rename to drizzle-orm/src/mysql-common/columns/enum.ts diff --git a/drizzle-orm-mysql/src/columns/float.ts b/drizzle-orm/src/mysql-common/columns/float.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/float.ts rename to drizzle-orm/src/mysql-common/columns/float.ts diff --git a/drizzle-orm-mysql/src/columns/index.ts b/drizzle-orm/src/mysql-common/columns/index.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/index.ts rename to drizzle-orm/src/mysql-common/columns/index.ts diff --git a/drizzle-orm-mysql/src/columns/int.ts b/drizzle-orm/src/mysql-common/columns/int.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/int.ts rename to drizzle-orm/src/mysql-common/columns/int.ts diff --git a/drizzle-orm-mysql/src/columns/json.ts b/drizzle-orm/src/mysql-common/columns/json.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/json.ts rename to drizzle-orm/src/mysql-common/columns/json.ts diff --git a/drizzle-orm-mysql/src/columns/mediumint.ts b/drizzle-orm/src/mysql-common/columns/mediumint.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/mediumint.ts rename to drizzle-orm/src/mysql-common/columns/mediumint.ts diff --git a/drizzle-orm-mysql/src/columns/real.ts b/drizzle-orm/src/mysql-common/columns/real.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/real.ts rename to drizzle-orm/src/mysql-common/columns/real.ts diff --git a/drizzle-orm-mysql/src/columns/serial.ts b/drizzle-orm/src/mysql-common/columns/serial.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/serial.ts rename to drizzle-orm/src/mysql-common/columns/serial.ts diff --git a/drizzle-orm-mysql/src/columns/smallint.ts b/drizzle-orm/src/mysql-common/columns/smallint.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/smallint.ts rename to drizzle-orm/src/mysql-common/columns/smallint.ts diff --git a/drizzle-orm-mysql/src/columns/text.ts b/drizzle-orm/src/mysql-common/columns/text.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/text.ts rename to drizzle-orm/src/mysql-common/columns/text.ts diff --git a/drizzle-orm-mysql/src/columns/time.ts b/drizzle-orm/src/mysql-common/columns/time.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/time.ts rename to drizzle-orm/src/mysql-common/columns/time.ts diff --git a/drizzle-orm-mysql/src/columns/timestamp.ts b/drizzle-orm/src/mysql-common/columns/timestamp.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/timestamp.ts rename to drizzle-orm/src/mysql-common/columns/timestamp.ts diff --git a/drizzle-orm-mysql/src/columns/tinyint.ts b/drizzle-orm/src/mysql-common/columns/tinyint.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/tinyint.ts rename to drizzle-orm/src/mysql-common/columns/tinyint.ts diff --git a/drizzle-orm-mysql/src/columns/varbinary.ts b/drizzle-orm/src/mysql-common/columns/varbinary.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/varbinary.ts rename to drizzle-orm/src/mysql-common/columns/varbinary.ts diff --git a/drizzle-orm-mysql/src/columns/varchar.ts b/drizzle-orm/src/mysql-common/columns/varchar.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/varchar.ts rename to drizzle-orm/src/mysql-common/columns/varchar.ts diff --git a/drizzle-orm-mysql/src/columns/year.ts b/drizzle-orm/src/mysql-common/columns/year.ts similarity index 100% rename from drizzle-orm-mysql/src/columns/year.ts rename to drizzle-orm/src/mysql-common/columns/year.ts diff --git a/drizzle-orm-mysql/src/db.ts b/drizzle-orm/src/mysql-common/db.ts similarity index 100% rename from drizzle-orm-mysql/src/db.ts rename to drizzle-orm/src/mysql-common/db.ts diff --git a/drizzle-orm-mysql/src/dialect.ts b/drizzle-orm/src/mysql-common/dialect.ts similarity index 100% rename from drizzle-orm-mysql/src/dialect.ts rename to drizzle-orm/src/mysql-common/dialect.ts diff --git a/drizzle-orm-mysql/src/expressions.ts b/drizzle-orm/src/mysql-common/expressions.ts similarity index 100% rename from drizzle-orm-mysql/src/expressions.ts rename to drizzle-orm/src/mysql-common/expressions.ts diff --git a/drizzle-orm-mysql/src/foreign-keys.ts b/drizzle-orm/src/mysql-common/foreign-keys.ts similarity index 100% rename from drizzle-orm-mysql/src/foreign-keys.ts rename to drizzle-orm/src/mysql-common/foreign-keys.ts diff --git a/drizzle-orm-mysql/src/index.ts b/drizzle-orm/src/mysql-common/index.ts similarity index 100% rename from drizzle-orm-mysql/src/index.ts rename to drizzle-orm/src/mysql-common/index.ts diff --git a/drizzle-orm-mysql/src/indexes.ts b/drizzle-orm/src/mysql-common/indexes.ts similarity index 100% rename from drizzle-orm-mysql/src/indexes.ts rename to drizzle-orm/src/mysql-common/indexes.ts diff --git a/drizzle-orm-mysql/src/operations.ts b/drizzle-orm/src/mysql-common/operations.ts similarity index 100% rename from drizzle-orm-mysql/src/operations.ts rename to drizzle-orm/src/mysql-common/operations.ts diff --git a/drizzle-orm-mysql/src/query-builders/delete.ts b/drizzle-orm/src/mysql-common/query-builders/delete.ts similarity index 100% rename from drizzle-orm-mysql/src/query-builders/delete.ts rename to drizzle-orm/src/mysql-common/query-builders/delete.ts diff --git a/drizzle-orm-mysql/src/query-builders/index.ts b/drizzle-orm/src/mysql-common/query-builders/index.ts similarity index 100% rename from drizzle-orm-mysql/src/query-builders/index.ts rename to drizzle-orm/src/mysql-common/query-builders/index.ts diff --git a/drizzle-orm-mysql/src/query-builders/insert.ts b/drizzle-orm/src/mysql-common/query-builders/insert.ts similarity index 100% rename from drizzle-orm-mysql/src/query-builders/insert.ts rename to drizzle-orm/src/mysql-common/query-builders/insert.ts diff --git a/drizzle-orm-mysql/src/query-builders/select.ts b/drizzle-orm/src/mysql-common/query-builders/select.ts similarity index 100% rename from drizzle-orm-mysql/src/query-builders/select.ts rename to drizzle-orm/src/mysql-common/query-builders/select.ts diff --git a/drizzle-orm-mysql/src/query-builders/select.types.ts b/drizzle-orm/src/mysql-common/query-builders/select.types.ts similarity index 100% rename from drizzle-orm-mysql/src/query-builders/select.types.ts rename to drizzle-orm/src/mysql-common/query-builders/select.types.ts diff --git a/drizzle-orm-mysql/src/query-builders/update.ts b/drizzle-orm/src/mysql-common/query-builders/update.ts similarity index 100% rename from drizzle-orm-mysql/src/query-builders/update.ts rename to drizzle-orm/src/mysql-common/query-builders/update.ts diff --git a/drizzle-orm-mysql/src/session.ts b/drizzle-orm/src/mysql-common/session.ts similarity index 100% rename from drizzle-orm-mysql/src/session.ts rename to drizzle-orm/src/mysql-common/session.ts diff --git a/drizzle-orm-mysql/src/table.ts b/drizzle-orm/src/mysql-common/table.ts similarity index 100% rename from drizzle-orm-mysql/src/table.ts rename to drizzle-orm/src/mysql-common/table.ts diff --git a/drizzle-orm-mysql/tsconfig.build.json b/drizzle-orm/src/mysql-common/tsconfig.build.json similarity index 100% rename from drizzle-orm-mysql/tsconfig.build.json rename to drizzle-orm/src/mysql-common/tsconfig.build.json diff --git a/drizzle-orm-mysql/src/utils.ts b/drizzle-orm/src/mysql-common/utils.ts similarity index 100% rename from drizzle-orm-mysql/src/utils.ts rename to drizzle-orm/src/mysql-common/utils.ts diff --git a/drizzle-orm-mysql/src/mysql2/driver.ts b/drizzle-orm/src/mysql2/driver.ts similarity index 100% rename from drizzle-orm-mysql/src/mysql2/driver.ts rename to drizzle-orm/src/mysql2/driver.ts diff --git a/drizzle-orm-pg/src/postgres.js/index.ts b/drizzle-orm/src/mysql2/index.ts similarity index 100% rename from drizzle-orm-pg/src/postgres.js/index.ts rename to drizzle-orm/src/mysql2/index.ts diff --git a/drizzle-orm-mysql/src/mysql2/migrator.ts b/drizzle-orm/src/mysql2/migrator.ts similarity index 100% rename from drizzle-orm-mysql/src/mysql2/migrator.ts rename to drizzle-orm/src/mysql2/migrator.ts diff --git a/drizzle-orm-mysql/src/mysql2/session.ts b/drizzle-orm/src/mysql2/session.ts similarity index 100% rename from drizzle-orm-mysql/src/mysql2/session.ts rename to drizzle-orm/src/mysql2/session.ts diff --git a/drizzle-orm-pg/src/neondb/driver.ts b/drizzle-orm/src/neondb/driver.ts similarity index 100% rename from drizzle-orm-pg/src/neondb/driver.ts rename to drizzle-orm/src/neondb/driver.ts diff --git a/drizzle-orm-sqlite/src/better-sqlite3/index.ts b/drizzle-orm/src/neondb/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/better-sqlite3/index.ts rename to drizzle-orm/src/neondb/index.ts diff --git a/drizzle-orm-pg/src/neondb/migrator.ts b/drizzle-orm/src/neondb/migrator.ts similarity index 100% rename from drizzle-orm-pg/src/neondb/migrator.ts rename to drizzle-orm/src/neondb/migrator.ts diff --git a/drizzle-orm-pg/src/neondb/session.ts b/drizzle-orm/src/neondb/session.ts similarity index 100% rename from drizzle-orm-pg/src/neondb/session.ts rename to drizzle-orm/src/neondb/session.ts diff --git a/drizzle-orm-pg/README.md b/drizzle-orm/src/pg-common/README.md similarity index 100% rename from drizzle-orm-pg/README.md rename to drizzle-orm/src/pg-common/README.md diff --git a/drizzle-orm-pg/src/alias.ts b/drizzle-orm/src/pg-common/alias.ts similarity index 100% rename from drizzle-orm-pg/src/alias.ts rename to drizzle-orm/src/pg-common/alias.ts diff --git a/drizzle-orm-pg/src/checks.ts b/drizzle-orm/src/pg-common/checks.ts similarity index 100% rename from drizzle-orm-pg/src/checks.ts rename to drizzle-orm/src/pg-common/checks.ts diff --git a/drizzle-orm-pg/src/columns/bigint.ts b/drizzle-orm/src/pg-common/columns/bigint.ts similarity index 100% rename from drizzle-orm-pg/src/columns/bigint.ts rename to drizzle-orm/src/pg-common/columns/bigint.ts diff --git a/drizzle-orm-pg/src/columns/bigserial.ts b/drizzle-orm/src/pg-common/columns/bigserial.ts similarity index 100% rename from drizzle-orm-pg/src/columns/bigserial.ts rename to drizzle-orm/src/pg-common/columns/bigserial.ts diff --git a/drizzle-orm-pg/src/columns/boolean.ts b/drizzle-orm/src/pg-common/columns/boolean.ts similarity index 100% rename from drizzle-orm-pg/src/columns/boolean.ts rename to drizzle-orm/src/pg-common/columns/boolean.ts diff --git a/drizzle-orm-pg/src/columns/common.ts b/drizzle-orm/src/pg-common/columns/common.ts similarity index 100% rename from drizzle-orm-pg/src/columns/common.ts rename to drizzle-orm/src/pg-common/columns/common.ts diff --git a/drizzle-orm-pg/src/columns/custom.ts b/drizzle-orm/src/pg-common/columns/custom.ts similarity index 100% rename from drizzle-orm-pg/src/columns/custom.ts rename to drizzle-orm/src/pg-common/columns/custom.ts diff --git a/drizzle-orm-pg/src/columns/date.common.ts b/drizzle-orm/src/pg-common/columns/date.common.ts similarity index 100% rename from drizzle-orm-pg/src/columns/date.common.ts rename to drizzle-orm/src/pg-common/columns/date.common.ts diff --git a/drizzle-orm-pg/src/columns/date.ts b/drizzle-orm/src/pg-common/columns/date.ts similarity index 100% rename from drizzle-orm-pg/src/columns/date.ts rename to drizzle-orm/src/pg-common/columns/date.ts diff --git a/drizzle-orm-pg/src/columns/double-precision.ts b/drizzle-orm/src/pg-common/columns/double-precision.ts similarity index 100% rename from drizzle-orm-pg/src/columns/double-precision.ts rename to drizzle-orm/src/pg-common/columns/double-precision.ts diff --git a/drizzle-orm-pg/src/columns/enum.ts b/drizzle-orm/src/pg-common/columns/enum.ts similarity index 100% rename from drizzle-orm-pg/src/columns/enum.ts rename to drizzle-orm/src/pg-common/columns/enum.ts diff --git a/drizzle-orm-pg/src/columns/index.ts b/drizzle-orm/src/pg-common/columns/index.ts similarity index 100% rename from drizzle-orm-pg/src/columns/index.ts rename to drizzle-orm/src/pg-common/columns/index.ts diff --git a/drizzle-orm-pg/src/columns/integer.ts b/drizzle-orm/src/pg-common/columns/integer.ts similarity index 100% rename from drizzle-orm-pg/src/columns/integer.ts rename to drizzle-orm/src/pg-common/columns/integer.ts diff --git a/drizzle-orm-pg/src/columns/interval.ts b/drizzle-orm/src/pg-common/columns/interval.ts similarity index 100% rename from drizzle-orm-pg/src/columns/interval.ts rename to drizzle-orm/src/pg-common/columns/interval.ts diff --git a/drizzle-orm-pg/src/columns/json.ts b/drizzle-orm/src/pg-common/columns/json.ts similarity index 100% rename from drizzle-orm-pg/src/columns/json.ts rename to drizzle-orm/src/pg-common/columns/json.ts diff --git a/drizzle-orm-pg/src/columns/jsonb.ts b/drizzle-orm/src/pg-common/columns/jsonb.ts similarity index 100% rename from drizzle-orm-pg/src/columns/jsonb.ts rename to drizzle-orm/src/pg-common/columns/jsonb.ts diff --git a/drizzle-orm-pg/src/columns/numeric.ts b/drizzle-orm/src/pg-common/columns/numeric.ts similarity index 100% rename from drizzle-orm-pg/src/columns/numeric.ts rename to drizzle-orm/src/pg-common/columns/numeric.ts diff --git a/drizzle-orm-pg/src/columns/real.ts b/drizzle-orm/src/pg-common/columns/real.ts similarity index 100% rename from drizzle-orm-pg/src/columns/real.ts rename to drizzle-orm/src/pg-common/columns/real.ts diff --git a/drizzle-orm-pg/src/columns/serial.ts b/drizzle-orm/src/pg-common/columns/serial.ts similarity index 100% rename from drizzle-orm-pg/src/columns/serial.ts rename to drizzle-orm/src/pg-common/columns/serial.ts diff --git a/drizzle-orm-pg/src/columns/smallint.ts b/drizzle-orm/src/pg-common/columns/smallint.ts similarity index 100% rename from drizzle-orm-pg/src/columns/smallint.ts rename to drizzle-orm/src/pg-common/columns/smallint.ts diff --git a/drizzle-orm-pg/src/columns/smallserial.ts b/drizzle-orm/src/pg-common/columns/smallserial.ts similarity index 100% rename from drizzle-orm-pg/src/columns/smallserial.ts rename to drizzle-orm/src/pg-common/columns/smallserial.ts diff --git a/drizzle-orm-pg/src/columns/text.ts b/drizzle-orm/src/pg-common/columns/text.ts similarity index 100% rename from drizzle-orm-pg/src/columns/text.ts rename to drizzle-orm/src/pg-common/columns/text.ts diff --git a/drizzle-orm-pg/src/columns/time.ts b/drizzle-orm/src/pg-common/columns/time.ts similarity index 100% rename from drizzle-orm-pg/src/columns/time.ts rename to drizzle-orm/src/pg-common/columns/time.ts diff --git a/drizzle-orm-pg/src/columns/timestamp.ts b/drizzle-orm/src/pg-common/columns/timestamp.ts similarity index 100% rename from drizzle-orm-pg/src/columns/timestamp.ts rename to drizzle-orm/src/pg-common/columns/timestamp.ts diff --git a/drizzle-orm-pg/src/columns/uuid.ts b/drizzle-orm/src/pg-common/columns/uuid.ts similarity index 100% rename from drizzle-orm-pg/src/columns/uuid.ts rename to drizzle-orm/src/pg-common/columns/uuid.ts diff --git a/drizzle-orm-pg/src/columns/varchar.ts b/drizzle-orm/src/pg-common/columns/varchar.ts similarity index 100% rename from drizzle-orm-pg/src/columns/varchar.ts rename to drizzle-orm/src/pg-common/columns/varchar.ts diff --git a/drizzle-orm-pg/src/db.ts b/drizzle-orm/src/pg-common/db.ts similarity index 100% rename from drizzle-orm-pg/src/db.ts rename to drizzle-orm/src/pg-common/db.ts diff --git a/drizzle-orm-pg/src/dialect.ts b/drizzle-orm/src/pg-common/dialect.ts similarity index 100% rename from drizzle-orm-pg/src/dialect.ts rename to drizzle-orm/src/pg-common/dialect.ts diff --git a/drizzle-orm-pg/src/expressions.ts b/drizzle-orm/src/pg-common/expressions.ts similarity index 100% rename from drizzle-orm-pg/src/expressions.ts rename to drizzle-orm/src/pg-common/expressions.ts diff --git a/drizzle-orm-pg/src/foreign-keys.ts b/drizzle-orm/src/pg-common/foreign-keys.ts similarity index 100% rename from drizzle-orm-pg/src/foreign-keys.ts rename to drizzle-orm/src/pg-common/foreign-keys.ts diff --git a/drizzle-orm-pg/src/index.ts b/drizzle-orm/src/pg-common/index.ts similarity index 100% rename from drizzle-orm-pg/src/index.ts rename to drizzle-orm/src/pg-common/index.ts diff --git a/drizzle-orm-pg/src/indexes.ts b/drizzle-orm/src/pg-common/indexes.ts similarity index 100% rename from drizzle-orm-pg/src/indexes.ts rename to drizzle-orm/src/pg-common/indexes.ts diff --git a/drizzle-orm-pg/src/node/driver.ts b/drizzle-orm/src/pg-common/node/driver.ts similarity index 100% rename from drizzle-orm-pg/src/node/driver.ts rename to drizzle-orm/src/pg-common/node/driver.ts diff --git a/drizzle-orm-sqlite/src/bun/index.ts b/drizzle-orm/src/pg-common/node/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/bun/index.ts rename to drizzle-orm/src/pg-common/node/index.ts diff --git a/drizzle-orm-pg/src/node/migrator.ts b/drizzle-orm/src/pg-common/node/migrator.ts similarity index 100% rename from drizzle-orm-pg/src/node/migrator.ts rename to drizzle-orm/src/pg-common/node/migrator.ts diff --git a/drizzle-orm-pg/src/node/session.ts b/drizzle-orm/src/pg-common/node/session.ts similarity index 100% rename from drizzle-orm-pg/src/node/session.ts rename to drizzle-orm/src/pg-common/node/session.ts diff --git a/drizzle-orm-pg/src/operations.ts b/drizzle-orm/src/pg-common/operations.ts similarity index 100% rename from drizzle-orm-pg/src/operations.ts rename to drizzle-orm/src/pg-common/operations.ts diff --git a/drizzle-orm-pg/src/query-builders/delete.ts b/drizzle-orm/src/pg-common/query-builders/delete.ts similarity index 100% rename from drizzle-orm-pg/src/query-builders/delete.ts rename to drizzle-orm/src/pg-common/query-builders/delete.ts diff --git a/drizzle-orm-pg/src/query-builders/index.ts b/drizzle-orm/src/pg-common/query-builders/index.ts similarity index 100% rename from drizzle-orm-pg/src/query-builders/index.ts rename to drizzle-orm/src/pg-common/query-builders/index.ts diff --git a/drizzle-orm-pg/src/query-builders/insert.ts b/drizzle-orm/src/pg-common/query-builders/insert.ts similarity index 100% rename from drizzle-orm-pg/src/query-builders/insert.ts rename to drizzle-orm/src/pg-common/query-builders/insert.ts diff --git a/drizzle-orm-pg/src/query-builders/select.ts b/drizzle-orm/src/pg-common/query-builders/select.ts similarity index 100% rename from drizzle-orm-pg/src/query-builders/select.ts rename to drizzle-orm/src/pg-common/query-builders/select.ts diff --git a/drizzle-orm-pg/src/query-builders/select.types.ts b/drizzle-orm/src/pg-common/query-builders/select.types.ts similarity index 100% rename from drizzle-orm-pg/src/query-builders/select.types.ts rename to drizzle-orm/src/pg-common/query-builders/select.types.ts diff --git a/drizzle-orm-pg/src/query-builders/update.ts b/drizzle-orm/src/pg-common/query-builders/update.ts similarity index 100% rename from drizzle-orm-pg/src/query-builders/update.ts rename to drizzle-orm/src/pg-common/query-builders/update.ts diff --git a/drizzle-orm-pg/src/session.ts b/drizzle-orm/src/pg-common/session.ts similarity index 100% rename from drizzle-orm-pg/src/session.ts rename to drizzle-orm/src/pg-common/session.ts diff --git a/drizzle-orm-pg/src/table.ts b/drizzle-orm/src/pg-common/table.ts similarity index 100% rename from drizzle-orm-pg/src/table.ts rename to drizzle-orm/src/pg-common/table.ts diff --git a/drizzle-orm-pg/src/utils.ts b/drizzle-orm/src/pg-common/utils.ts similarity index 100% rename from drizzle-orm-pg/src/utils.ts rename to drizzle-orm/src/pg-common/utils.ts diff --git a/drizzle-orm-pg/src/postgres.js/README.md b/drizzle-orm/src/postgres.js/README.md similarity index 100% rename from drizzle-orm-pg/src/postgres.js/README.md rename to drizzle-orm/src/postgres.js/README.md diff --git a/drizzle-orm-pg/src/postgres.js/driver.ts b/drizzle-orm/src/postgres.js/driver.ts similarity index 100% rename from drizzle-orm-pg/src/postgres.js/driver.ts rename to drizzle-orm/src/postgres.js/driver.ts diff --git a/drizzle-orm-sqlite/src/d1/index.ts b/drizzle-orm/src/postgres.js/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/d1/index.ts rename to drizzle-orm/src/postgres.js/index.ts diff --git a/drizzle-orm-pg/src/postgres.js/migrator.ts b/drizzle-orm/src/postgres.js/migrator.ts similarity index 100% rename from drizzle-orm-pg/src/postgres.js/migrator.ts rename to drizzle-orm/src/postgres.js/migrator.ts diff --git a/drizzle-orm-pg/src/postgres.js/session.ts b/drizzle-orm/src/postgres.js/session.ts similarity index 100% rename from drizzle-orm-pg/src/postgres.js/session.ts rename to drizzle-orm/src/postgres.js/session.ts diff --git a/drizzle-orm-sqlite/src/sql.js/driver.ts b/drizzle-orm/src/sql.js/driver.ts similarity index 100% rename from drizzle-orm-sqlite/src/sql.js/driver.ts rename to drizzle-orm/src/sql.js/driver.ts diff --git a/drizzle-orm-sqlite/src/sql.js/index.ts b/drizzle-orm/src/sql.js/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/sql.js/index.ts rename to drizzle-orm/src/sql.js/index.ts diff --git a/drizzle-orm-sqlite/src/sql.js/migrator.ts b/drizzle-orm/src/sql.js/migrator.ts similarity index 100% rename from drizzle-orm-sqlite/src/sql.js/migrator.ts rename to drizzle-orm/src/sql.js/migrator.ts diff --git a/drizzle-orm-sqlite/src/sql.js/session.ts b/drizzle-orm/src/sql.js/session.ts similarity index 100% rename from drizzle-orm-sqlite/src/sql.js/session.ts rename to drizzle-orm/src/sql.js/session.ts diff --git a/drizzle-orm-sqlite/README.md b/drizzle-orm/src/sqlite-common/README.md similarity index 100% rename from drizzle-orm-sqlite/README.md rename to drizzle-orm/src/sqlite-common/README.md diff --git a/drizzle-orm-sqlite/src/alias.ts b/drizzle-orm/src/sqlite-common/alias.ts similarity index 100% rename from drizzle-orm-sqlite/src/alias.ts rename to drizzle-orm/src/sqlite-common/alias.ts diff --git a/drizzle-orm-sqlite/src/checks.ts b/drizzle-orm/src/sqlite-common/checks.ts similarity index 100% rename from drizzle-orm-sqlite/src/checks.ts rename to drizzle-orm/src/sqlite-common/checks.ts diff --git a/drizzle-orm-sqlite/src/columns/blob.ts b/drizzle-orm/src/sqlite-common/columns/blob.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/blob.ts rename to drizzle-orm/src/sqlite-common/columns/blob.ts diff --git a/drizzle-orm-sqlite/src/columns/common.ts b/drizzle-orm/src/sqlite-common/columns/common.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/common.ts rename to drizzle-orm/src/sqlite-common/columns/common.ts diff --git a/drizzle-orm-sqlite/src/columns/index.ts b/drizzle-orm/src/sqlite-common/columns/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/index.ts rename to drizzle-orm/src/sqlite-common/columns/index.ts diff --git a/drizzle-orm-sqlite/src/columns/integer.ts b/drizzle-orm/src/sqlite-common/columns/integer.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/integer.ts rename to drizzle-orm/src/sqlite-common/columns/integer.ts diff --git a/drizzle-orm-sqlite/src/columns/numeric.ts b/drizzle-orm/src/sqlite-common/columns/numeric.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/numeric.ts rename to drizzle-orm/src/sqlite-common/columns/numeric.ts diff --git a/drizzle-orm-sqlite/src/columns/real.ts b/drizzle-orm/src/sqlite-common/columns/real.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/real.ts rename to drizzle-orm/src/sqlite-common/columns/real.ts diff --git a/drizzle-orm-sqlite/src/columns/text.ts b/drizzle-orm/src/sqlite-common/columns/text.ts similarity index 100% rename from drizzle-orm-sqlite/src/columns/text.ts rename to drizzle-orm/src/sqlite-common/columns/text.ts diff --git a/drizzle-orm-sqlite/src/db.ts b/drizzle-orm/src/sqlite-common/db.ts similarity index 100% rename from drizzle-orm-sqlite/src/db.ts rename to drizzle-orm/src/sqlite-common/db.ts diff --git a/drizzle-orm-sqlite/src/dialect.ts b/drizzle-orm/src/sqlite-common/dialect.ts similarity index 100% rename from drizzle-orm-sqlite/src/dialect.ts rename to drizzle-orm/src/sqlite-common/dialect.ts diff --git a/drizzle-orm-sqlite/src/expressions.ts b/drizzle-orm/src/sqlite-common/expressions.ts similarity index 100% rename from drizzle-orm-sqlite/src/expressions.ts rename to drizzle-orm/src/sqlite-common/expressions.ts diff --git a/drizzle-orm-sqlite/src/foreign-keys.ts b/drizzle-orm/src/sqlite-common/foreign-keys.ts similarity index 100% rename from drizzle-orm-sqlite/src/foreign-keys.ts rename to drizzle-orm/src/sqlite-common/foreign-keys.ts diff --git a/drizzle-orm-sqlite/src/index.ts b/drizzle-orm/src/sqlite-common/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/index.ts rename to drizzle-orm/src/sqlite-common/index.ts diff --git a/drizzle-orm-sqlite/src/indexes.ts b/drizzle-orm/src/sqlite-common/indexes.ts similarity index 100% rename from drizzle-orm-sqlite/src/indexes.ts rename to drizzle-orm/src/sqlite-common/indexes.ts diff --git a/drizzle-orm-sqlite/src/operations.ts b/drizzle-orm/src/sqlite-common/operations.ts similarity index 100% rename from drizzle-orm-sqlite/src/operations.ts rename to drizzle-orm/src/sqlite-common/operations.ts diff --git a/drizzle-orm-sqlite/src/primary-keys.ts b/drizzle-orm/src/sqlite-common/primary-keys.ts similarity index 100% rename from drizzle-orm-sqlite/src/primary-keys.ts rename to drizzle-orm/src/sqlite-common/primary-keys.ts diff --git a/drizzle-orm-sqlite/src/query-builders/delete.ts b/drizzle-orm/src/sqlite-common/query-builders/delete.ts similarity index 100% rename from drizzle-orm-sqlite/src/query-builders/delete.ts rename to drizzle-orm/src/sqlite-common/query-builders/delete.ts diff --git a/drizzle-orm-sqlite/src/query-builders/index.ts b/drizzle-orm/src/sqlite-common/query-builders/index.ts similarity index 100% rename from drizzle-orm-sqlite/src/query-builders/index.ts rename to drizzle-orm/src/sqlite-common/query-builders/index.ts diff --git a/drizzle-orm-sqlite/src/query-builders/insert.ts b/drizzle-orm/src/sqlite-common/query-builders/insert.ts similarity index 100% rename from drizzle-orm-sqlite/src/query-builders/insert.ts rename to drizzle-orm/src/sqlite-common/query-builders/insert.ts diff --git a/drizzle-orm-sqlite/src/query-builders/select.ts b/drizzle-orm/src/sqlite-common/query-builders/select.ts similarity index 100% rename from drizzle-orm-sqlite/src/query-builders/select.ts rename to drizzle-orm/src/sqlite-common/query-builders/select.ts diff --git a/drizzle-orm-sqlite/src/query-builders/select.types.ts b/drizzle-orm/src/sqlite-common/query-builders/select.types.ts similarity index 100% rename from drizzle-orm-sqlite/src/query-builders/select.types.ts rename to drizzle-orm/src/sqlite-common/query-builders/select.types.ts diff --git a/drizzle-orm-sqlite/src/query-builders/update.ts b/drizzle-orm/src/sqlite-common/query-builders/update.ts similarity index 100% rename from drizzle-orm-sqlite/src/query-builders/update.ts rename to drizzle-orm/src/sqlite-common/query-builders/update.ts diff --git a/drizzle-orm-sqlite/src/session.ts b/drizzle-orm/src/sqlite-common/session.ts similarity index 100% rename from drizzle-orm-sqlite/src/session.ts rename to drizzle-orm/src/sqlite-common/session.ts diff --git a/drizzle-orm-sqlite/src/table.ts b/drizzle-orm/src/sqlite-common/table.ts similarity index 100% rename from drizzle-orm-sqlite/src/table.ts rename to drizzle-orm/src/sqlite-common/table.ts diff --git a/drizzle-orm-sqlite/src/unique-constraint.ts b/drizzle-orm/src/sqlite-common/unique-constraint.ts similarity index 100% rename from drizzle-orm-sqlite/src/unique-constraint.ts rename to drizzle-orm/src/sqlite-common/unique-constraint.ts diff --git a/drizzle-orm-sqlite/src/utils.ts b/drizzle-orm/src/sqlite-common/utils.ts similarity index 100% rename from drizzle-orm-sqlite/src/utils.ts rename to drizzle-orm/src/sqlite-common/utils.ts diff --git a/drizzle-orm-mysql/tests/dan/1-to-1-fk.ts b/drizzle-orm/tests/mysql/dan/1-to-1-fk.ts similarity index 100% rename from drizzle-orm-mysql/tests/dan/1-to-1-fk.ts rename to drizzle-orm/tests/mysql/dan/1-to-1-fk.ts diff --git a/drizzle-orm-mysql/tests/dan/db.ts b/drizzle-orm/tests/mysql/dan/db.ts similarity index 100% rename from drizzle-orm-mysql/tests/dan/db.ts rename to drizzle-orm/tests/mysql/dan/db.ts diff --git a/drizzle-orm-mysql/tests/dan/delete.ts b/drizzle-orm/tests/mysql/dan/delete.ts similarity index 100% rename from drizzle-orm-mysql/tests/dan/delete.ts rename to drizzle-orm/tests/mysql/dan/delete.ts diff --git a/drizzle-orm-mysql/tests/dan/insert.ts b/drizzle-orm/tests/mysql/dan/insert.ts similarity index 100% rename from drizzle-orm-mysql/tests/dan/insert.ts rename to drizzle-orm/tests/mysql/dan/insert.ts diff --git a/drizzle-orm-mysql/tests/dan/select.ts b/drizzle-orm/tests/mysql/dan/select.ts similarity index 100% rename from drizzle-orm-mysql/tests/dan/select.ts rename to drizzle-orm/tests/mysql/dan/select.ts diff --git a/drizzle-orm-mysql/tests/dan/tables.ts b/drizzle-orm/tests/mysql/dan/tables.ts similarity index 100% rename from drizzle-orm-mysql/tests/dan/tables.ts rename to drizzle-orm/tests/mysql/dan/tables.ts diff --git a/drizzle-orm-mysql/tests/tsconfig.json b/drizzle-orm/tests/mysql/tsconfig.json similarity index 100% rename from drizzle-orm-mysql/tests/tsconfig.json rename to drizzle-orm/tests/mysql/tsconfig.json diff --git a/drizzle-orm-mysql/tests/utils.ts b/drizzle-orm/tests/mysql/utils.ts similarity index 100% rename from drizzle-orm-mysql/tests/utils.ts rename to drizzle-orm/tests/mysql/utils.ts diff --git a/drizzle-orm-pg/tests/dan/1-to-1-fk.ts b/drizzle-orm/tests/pg/dan/1-to-1-fk.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/1-to-1-fk.ts rename to drizzle-orm/tests/pg/dan/1-to-1-fk.ts diff --git a/drizzle-orm-pg/tests/dan/db.ts b/drizzle-orm/tests/pg/dan/db.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/db.ts rename to drizzle-orm/tests/pg/dan/db.ts diff --git a/drizzle-orm-pg/tests/dan/delete.ts b/drizzle-orm/tests/pg/dan/delete.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/delete.ts rename to drizzle-orm/tests/pg/dan/delete.ts diff --git a/drizzle-orm-pg/tests/dan/insert.ts b/drizzle-orm/tests/pg/dan/insert.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/insert.ts rename to drizzle-orm/tests/pg/dan/insert.ts diff --git a/drizzle-orm-pg/tests/dan/other.ts b/drizzle-orm/tests/pg/dan/other.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/other.ts rename to drizzle-orm/tests/pg/dan/other.ts diff --git a/drizzle-orm-pg/tests/dan/select.ts b/drizzle-orm/tests/pg/dan/select.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/select.ts rename to drizzle-orm/tests/pg/dan/select.ts diff --git a/drizzle-orm-pg/tests/dan/tables.ts b/drizzle-orm/tests/pg/dan/tables.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/tables.ts rename to drizzle-orm/tests/pg/dan/tables.ts diff --git a/drizzle-orm-pg/tests/dan/update.ts b/drizzle-orm/tests/pg/dan/update.ts similarity index 100% rename from drizzle-orm-pg/tests/dan/update.ts rename to drizzle-orm/tests/pg/dan/update.ts diff --git a/drizzle-orm-pg/tests/tsconfig.json b/drizzle-orm/tests/pg/tsconfig.json similarity index 100% rename from drizzle-orm-pg/tests/tsconfig.json rename to drizzle-orm/tests/pg/tsconfig.json diff --git a/drizzle-orm-pg/tests/utils.ts b/drizzle-orm/tests/pg/utils.ts similarity index 100% rename from drizzle-orm-pg/tests/utils.ts rename to drizzle-orm/tests/pg/utils.ts diff --git a/drizzle-orm-sqlite/tests/.gitignore b/drizzle-orm/tests/sqlite/.gitignore similarity index 100% rename from drizzle-orm-sqlite/tests/.gitignore rename to drizzle-orm/tests/sqlite/.gitignore diff --git a/drizzle-orm-sqlite/tests/dan/db.ts b/drizzle-orm/tests/sqlite/dan/db.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/db.ts rename to drizzle-orm/tests/sqlite/dan/db.ts diff --git a/drizzle-orm-sqlite/tests/dan/delete.ts b/drizzle-orm/tests/sqlite/dan/delete.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/delete.ts rename to drizzle-orm/tests/sqlite/dan/delete.ts diff --git a/drizzle-orm-sqlite/tests/dan/insert.ts b/drizzle-orm/tests/sqlite/dan/insert.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/insert.ts rename to drizzle-orm/tests/sqlite/dan/insert.ts diff --git a/drizzle-orm-sqlite/tests/dan/other.ts b/drizzle-orm/tests/sqlite/dan/other.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/other.ts rename to drizzle-orm/tests/sqlite/dan/other.ts diff --git a/drizzle-orm-sqlite/tests/dan/select.ts b/drizzle-orm/tests/sqlite/dan/select.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/select.ts rename to drizzle-orm/tests/sqlite/dan/select.ts diff --git a/drizzle-orm-sqlite/tests/dan/tables.ts b/drizzle-orm/tests/sqlite/dan/tables.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/tables.ts rename to drizzle-orm/tests/sqlite/dan/tables.ts diff --git a/drizzle-orm-sqlite/tests/dan/update.ts b/drizzle-orm/tests/sqlite/dan/update.ts similarity index 100% rename from drizzle-orm-sqlite/tests/dan/update.ts rename to drizzle-orm/tests/sqlite/dan/update.ts diff --git a/drizzle-orm-sqlite/tests/tsconfig.json b/drizzle-orm/tests/sqlite/tsconfig.json similarity index 100% rename from drizzle-orm-sqlite/tests/tsconfig.json rename to drizzle-orm/tests/sqlite/tsconfig.json diff --git a/drizzle-orm-sqlite/tests/utils.ts b/drizzle-orm/tests/sqlite/utils.ts similarity index 100% rename from drizzle-orm-sqlite/tests/utils.ts rename to drizzle-orm/tests/sqlite/utils.ts diff --git a/drizzle-orm/tsconfig.json b/drizzle-orm/tsconfig.json index 796b17474..9483f4389 100644 --- a/drizzle-orm/tsconfig.json +++ b/drizzle-orm/tsconfig.json @@ -3,7 +3,11 @@ "compilerOptions": { "rootDir": "src", "outDir": "./dist", - "baseUrl": "." + "baseUrl": ".", + "paths": { + "~/*": ["src/*"] + } }, - "include": ["src"] + "include": ["src"], + "types": ["bun-types", "@cloudflare/workers-types"] } diff --git a/drizzle-zod/package.json b/drizzle-zod/package.json index be4baea7c..0fd8effb0 100644 --- a/drizzle-zod/package.json +++ b/drizzle-zod/package.json @@ -52,9 +52,6 @@ "devDependencies": { "ava": "^5.1.0", "drizzle-orm": "link:../drizzle-orm/dist", - "drizzle-orm-mysql": "link:../drizzle-orm-mysql/dist", - "drizzle-orm-pg": "link:../drizzle-orm-pg/dist", - "drizzle-orm-sqlite": "link:../drizzle-orm-sqlite/dist", "tsx": "^3.12.2", "zod": "^3.20.2" } diff --git a/integration-tests/package.json b/integration-tests/package.json index 29c08946a..b228dbcef 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -36,9 +36,6 @@ "better-sqlite3": "^7.6.2", "dockerode": "^3.3.4", "drizzle-orm": "workspace:../drizzle-orm/dist", - "drizzle-orm-mysql": "workspace:../drizzle-orm-mysql/dist", - "drizzle-orm-pg": "workspace:../drizzle-orm-pg/dist", - "drizzle-orm-sqlite": "workspace:../drizzle-orm-sqlite/dist", "get-port": "^6.1.2", "mysql2": "^2.3.3", "pg": "^8.8.0", From 0ba0a1ad43ba675667a908b358ef6e720655a069 Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Wed, 25 Jan 2023 12:23:42 +0100 Subject: [PATCH 2/8] [WIP] Merge all ORM packages into drizzle-orm, add GitHub release workflow --- .github/workflows/release-feature-branch.yaml | 3 - .github/workflows/release-latest.yaml | 39 ++- .../unpublish-release-feature-branch.yaml | 3 - .markdownlint.yaml | 1 + CONTRIBUTING.md | 39 ++- README.md | 25 +- changelogs/drizzle-orm/0.17.0.md | 27 ++ docs/custom-types.md | 24 +- drizzle-orm/README.md | 0 drizzle-orm/package.json | 33 +- drizzle-orm/src/better-sqlite3/driver.ts | 6 +- drizzle-orm/src/better-sqlite3/migrator.ts | 2 +- drizzle-orm/src/better-sqlite3/session.ts | 12 +- drizzle-orm/src/{bun => bun-sqlite}/driver.ts | 8 +- drizzle-orm/src/{bun => bun-sqlite}/index.ts | 0 .../src/{bun => bun-sqlite}/migrator.ts | 2 +- .../src/{bun => bun-sqlite}/session.ts | 14 +- drizzle-orm/src/d1/driver.ts | 8 +- drizzle-orm/src/d1/migrator.ts | 2 +- drizzle-orm/src/d1/session.ts | 16 +- drizzle-orm/src/index.ts | 2 +- drizzle-orm/src/{connection.ts => logger.ts} | 0 .../{mysql-common => mysql-core}/README.md | 54 ++-- .../src/{mysql-common => mysql-core}/alias.ts | 2 +- .../{mysql-common => mysql-core}/checks.ts | 2 +- .../columns/bigint.ts | 6 +- .../columns/binary.ts | 6 +- .../columns/boolean.ts | 6 +- .../columns/char.ts | 6 +- .../columns/common.ts | 21 +- .../columns/custom.ts | 8 +- .../columns/date.common.ts | 5 +- .../columns/date.ts | 6 +- .../columns/datetime.ts | 16 +- .../columns/decimal.ts | 6 +- .../columns/double.ts | 6 +- .../columns/enum.ts | 4 +- .../columns/float.ts | 6 +- .../columns/index.ts | 0 .../columns/int.ts | 6 +- .../columns/json.ts | 6 +- .../columns/mediumint.ts | 6 +- .../columns/real.ts | 6 +- .../columns/serial.ts | 2 +- .../columns/smallint.ts | 6 +- .../columns/text.ts | 6 +- .../columns/time.ts | 6 +- .../columns/timestamp.ts | 6 +- .../columns/tinyint.ts | 6 +- .../columns/varbinary.ts | 6 +- .../columns/varchar.ts | 6 +- .../columns/year.ts | 6 +- .../src/{mysql-common => mysql-core}/db.ts | 7 +- .../{mysql-common => mysql-core}/dialect.ts | 7 +- .../expressions.ts | 5 +- .../foreign-keys.ts | 0 .../src/{mysql-common => mysql-core}/index.ts | 0 .../{mysql-common => mysql-core}/indexes.ts | 2 +- .../operations.ts | 8 +- .../query-builders/delete.ts | 13 +- .../query-builders/index.ts | 0 .../query-builders/insert.ts | 20 +- .../query-builders/select.ts | 19 +- .../query-builders/select.types.ts | 22 +- .../query-builders/update.ts | 18 +- .../{mysql-common => mysql-core}/session.ts | 2 +- .../src/{mysql-common => mysql-core}/table.ts | 32 +- .../tsconfig.build.json | 0 .../src/{mysql-common => mysql-core}/utils.ts | 18 +- drizzle-orm/src/mysql2/driver.ts | 6 +- drizzle-orm/src/mysql2/migrator.ts | 4 +- drizzle-orm/src/mysql2/session.ts | 18 +- drizzle-orm/src/{neondb => neon}/driver.ts | 6 +- drizzle-orm/src/{neondb => neon}/index.ts | 0 drizzle-orm/src/{neondb => neon}/migrator.ts | 2 +- drizzle-orm/src/{neondb => neon}/session.ts | 12 +- .../node => node-postgres}/driver.ts | 6 +- .../node => node-postgres}/index.ts | 0 .../node => node-postgres}/migrator.ts | 2 +- .../node => node-postgres}/session.ts | 10 +- .../src/{pg-common => pg-core}/README.md | 56 ++-- .../src/{pg-common => pg-core}/alias.ts | 2 +- .../src/{pg-common => pg-core}/checks.ts | 2 +- .../{pg-common => pg-core}/columns/bigint.ts | 6 +- .../columns/bigserial.ts | 0 .../{pg-common => pg-core}/columns/boolean.ts | 6 +- .../{pg-common => pg-core}/columns/common.ts | 21 +- .../{pg-common => pg-core}/columns/custom.ts | 8 +- .../columns/date.common.ts | 5 +- .../{pg-common => pg-core}/columns/date.ts | 6 +- .../columns/double-precision.ts | 6 +- .../{pg-common => pg-core}/columns/enum.ts | 8 +- .../{pg-common => pg-core}/columns/index.ts | 0 .../{pg-common => pg-core}/columns/integer.ts | 4 +- .../columns/interval.ts | 6 +- .../{pg-common => pg-core}/columns/json.ts | 6 +- .../{pg-common => pg-core}/columns/jsonb.ts | 6 +- .../{pg-common => pg-core}/columns/numeric.ts | 6 +- .../{pg-common => pg-core}/columns/real.ts | 6 +- .../{pg-common => pg-core}/columns/serial.ts | 2 +- .../columns/smallint.ts | 6 +- .../columns/smallserial.ts | 2 +- .../{pg-common => pg-core}/columns/text.ts | 6 +- .../{pg-common => pg-core}/columns/time.ts | 16 +- .../columns/timestamp.ts | 6 +- .../{pg-common => pg-core}/columns/uuid.ts | 7 +- .../{pg-common => pg-core}/columns/varchar.ts | 6 +- drizzle-orm/src/{pg-common => pg-core}/db.ts | 12 +- .../src/{pg-common => pg-core}/dialect.ts | 17 +- .../src/{pg-common => pg-core}/expressions.ts | 7 +- .../{pg-common => pg-core}/foreign-keys.ts | 0 .../src/{pg-common => pg-core}/index.ts | 0 .../src/{pg-common => pg-core}/indexes.ts | 2 +- .../src/{pg-common => pg-core}/operations.ts | 12 +- .../query-builders/delete.ts | 14 +- .../query-builders/index.ts | 0 .../query-builders/insert.ts | 20 +- .../query-builders/select.ts | 20 +- .../query-builders/select.types.ts | 16 +- .../query-builders/update.ts | 20 +- .../src/{pg-common => pg-core}/session.ts | 2 +- .../src/{pg-common => pg-core}/table.ts | 10 +- .../src/{pg-common => pg-core}/utils.ts | 14 +- drizzle-orm/src/postgres.js/README.md | 14 +- drizzle-orm/src/postgres.js/driver.ts | 6 +- drizzle-orm/src/postgres.js/migrator.ts | 2 +- drizzle-orm/src/postgres.js/session.ts | 12 +- drizzle-orm/src/sql.js/driver.ts | 6 +- drizzle-orm/src/sql.js/migrator.ts | 2 +- drizzle-orm/src/sql.js/session.ts | 12 +- .../{sqlite-common => sqlite-core}/README.md | 306 +++++++++--------- .../{sqlite-common => sqlite-core}/alias.ts | 2 +- .../{sqlite-common => sqlite-core}/checks.ts | 2 +- .../columns/blob.ts | 6 +- .../columns/common.ts | 21 +- .../columns/index.ts | 0 .../columns/integer.ts | 8 +- .../columns/numeric.ts | 6 +- .../columns/real.ts | 4 +- .../columns/text.ts | 6 +- .../src/{sqlite-common => sqlite-core}/db.ts | 12 +- .../{sqlite-common => sqlite-core}/dialect.ts | 20 +- .../expressions.ts | 7 +- .../foreign-keys.ts | 0 .../{sqlite-common => sqlite-core}/index.ts | 0 .../{sqlite-common => sqlite-core}/indexes.ts | 2 +- .../operations.ts | 12 +- .../primary-keys.ts | 0 .../query-builders/delete.ts | 12 +- .../query-builders/index.ts | 0 .../query-builders/insert.ts | 20 +- .../query-builders/select.ts | 18 +- .../query-builders/select.types.ts | 27 +- .../query-builders/update.ts | 17 +- .../{sqlite-common => sqlite-core}/session.ts | 4 +- .../{sqlite-common => sqlite-core}/table.ts | 10 +- .../unique-constraint.ts | 0 .../{sqlite-common => sqlite-core}/utils.ts | 14 +- drizzle-orm/src/utils.ts | 2 + drizzle-orm/tsconfig.json | 3 +- drizzle-zod/README.md | 2 +- drizzle-zod/package.json | 7 +- drizzle-zod/src/pg/index.ts | 4 +- drizzle-zod/tests/pg.test.ts | 2 +- examples/bun-sqlite/README.md | 4 +- examples/bun-sqlite/src/index.ts | 10 +- examples/bun-sqlite/src/schema.ts | 154 +++++---- examples/cloudflare-d1/README.md | 11 +- examples/cloudflare-d1/package.json | 1 - examples/cloudflare-d1/src/index.ts | 2 +- examples/cloudflare-d1/src/schema.ts | 8 +- integration-tests/tests/better-sqlite.test.ts | 13 +- integration-tests/tests/bun/sqlite-nw.test.ts | 12 +- integration-tests/tests/bun/sqlite.test.ts | 11 +- integration-tests/tests/mysql-schema.test.ts | 18 +- integration-tests/tests/mysql.custom.test.ts | 29 +- integration-tests/tests/mysql.test.ts | 13 +- integration-tests/tests/pg-schema.test.ts | 4 +- integration-tests/tests/pg.custom.test.ts | 26 +- integration-tests/tests/pg.test.ts | 6 +- integration-tests/tests/postgres.js.test.ts | 6 +- integration-tests/tests/sql.js.test.ts | 6 +- package.json | 5 +- pnpm-lock.yaml | 28 ++ pnpm-workspace.yaml | 3 - 185 files changed, 1083 insertions(+), 1013 deletions(-) create mode 100644 changelogs/drizzle-orm/0.17.0.md delete mode 100644 drizzle-orm/README.md rename drizzle-orm/src/{bun => bun-sqlite}/driver.ts (71%) rename drizzle-orm/src/{bun => bun-sqlite}/index.ts (100%) rename drizzle-orm/src/{bun => bun-sqlite}/migrator.ts (74%) rename drizzle-orm/src/{bun => bun-sqlite}/session.ts (88%) rename drizzle-orm/src/{connection.ts => logger.ts} (100%) rename drizzle-orm/src/{mysql-common => mysql-core}/README.md (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/alias.ts (84%) rename drizzle-orm/src/{mysql-common => mysql-core}/checks.ts (93%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/bigint.ts (93%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/binary.ts (89%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/boolean.ts (85%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/char.ts (89%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/common.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/custom.ts (97%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/date.common.ts (90%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/date.ts (93%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/datetime.ts (89%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/decimal.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/double.ts (92%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/enum.ts (96%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/float.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/index.ts (100%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/int.ts (86%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/json.ts (85%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/mediumint.ts (86%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/real.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/serial.ts (94%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/smallint.ts (86%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/text.ts (92%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/time.ts (89%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/timestamp.ts (95%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/tinyint.ts (86%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/varbinary.ts (89%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/varchar.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/columns/year.ts (84%) rename drizzle-orm/src/{mysql-common => mysql-core}/db.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/dialect.ts (98%) rename drizzle-orm/src/{mysql-common => mysql-core}/expressions.ts (80%) rename drizzle-orm/src/{mysql-common => mysql-core}/foreign-keys.ts (100%) rename drizzle-orm/src/{mysql-common => mysql-core}/index.ts (100%) rename drizzle-orm/src/{mysql-common => mysql-core}/indexes.ts (98%) rename drizzle-orm/src/{mysql-common => mysql-core}/operations.ts (84%) rename drizzle-orm/src/{mysql-common => mysql-core}/query-builders/delete.ts (79%) rename drizzle-orm/src/{mysql-common => mysql-core}/query-builders/index.ts (100%) rename drizzle-orm/src/{mysql-common => mysql-core}/query-builders/insert.ts (84%) rename drizzle-orm/src/{mysql-common => mysql-core}/query-builders/select.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/query-builders/select.types.ts (93%) rename drizzle-orm/src/{mysql-common => mysql-core}/query-builders/update.ts (81%) rename drizzle-orm/src/{mysql-common => mysql-core}/session.ts (97%) rename drizzle-orm/src/{mysql-common => mysql-core}/table.ts (91%) rename drizzle-orm/src/{mysql-common => mysql-core}/tsconfig.build.json (100%) rename drizzle-orm/src/{mysql-common => mysql-core}/utils.ts (95%) rename drizzle-orm/src/{neondb => neon}/driver.ts (89%) rename drizzle-orm/src/{neondb => neon}/index.ts (100%) rename drizzle-orm/src/{neondb => neon}/migrator.ts (78%) rename drizzle-orm/src/{neondb => neon}/session.ts (91%) rename drizzle-orm/src/{pg-common/node => node-postgres}/driver.ts (89%) rename drizzle-orm/src/{pg-common/node => node-postgres}/index.ts (100%) rename drizzle-orm/src/{pg-common/node => node-postgres}/migrator.ts (75%) rename drizzle-orm/src/{pg-common/node => node-postgres}/session.ts (93%) rename drizzle-orm/src/{pg-common => pg-core}/README.md (89%) rename drizzle-orm/src/{pg-common => pg-core}/alias.ts (84%) rename drizzle-orm/src/{pg-common => pg-core}/checks.ts (93%) rename drizzle-orm/src/{pg-common => pg-core}/columns/bigint.ts (93%) rename drizzle-orm/src/{pg-common => pg-core}/columns/bigserial.ts (100%) rename drizzle-orm/src/{pg-common => pg-core}/columns/boolean.ts (83%) rename drizzle-orm/src/{pg-common => pg-core}/columns/common.ts (90%) rename drizzle-orm/src/{pg-common => pg-core}/columns/custom.ts (97%) rename drizzle-orm/src/{pg-common => pg-core}/columns/date.common.ts (82%) rename drizzle-orm/src/{pg-common => pg-core}/columns/date.ts (93%) rename drizzle-orm/src/{pg-common => pg-core}/columns/double-precision.ts (89%) rename drizzle-orm/src/{pg-common => pg-core}/columns/enum.ts (94%) rename drizzle-orm/src/{pg-common => pg-core}/columns/index.ts (100%) rename drizzle-orm/src/{pg-common => pg-core}/columns/integer.ts (89%) rename drizzle-orm/src/{pg-common => pg-core}/columns/interval.ts (92%) rename drizzle-orm/src/{pg-common => pg-core}/columns/json.ts (89%) rename drizzle-orm/src/{pg-common => pg-core}/columns/jsonb.ts (89%) rename drizzle-orm/src/{pg-common => pg-core}/columns/numeric.ts (91%) rename drizzle-orm/src/{pg-common => pg-core}/columns/real.ts (88%) rename drizzle-orm/src/{pg-common => pg-core}/columns/serial.ts (94%) rename drizzle-orm/src/{pg-common => pg-core}/columns/smallint.ts (86%) rename drizzle-orm/src/{pg-common => pg-core}/columns/smallserial.ts (95%) rename drizzle-orm/src/{pg-common => pg-core}/columns/text.ts (92%) rename drizzle-orm/src/{pg-common => pg-core}/columns/time.ts (79%) rename drizzle-orm/src/{pg-common => pg-core}/columns/timestamp.ts (96%) rename drizzle-orm/src/{pg-common => pg-core}/columns/uuid.ts (85%) rename drizzle-orm/src/{pg-common => pg-core}/columns/varchar.ts (89%) rename drizzle-orm/src/{pg-common => pg-core}/db.ts (78%) rename drizzle-orm/src/{pg-common => pg-core}/dialect.ts (94%) rename drizzle-orm/src/{pg-common => pg-core}/expressions.ts (73%) rename drizzle-orm/src/{pg-common => pg-core}/foreign-keys.ts (100%) rename drizzle-orm/src/{pg-common => pg-core}/index.ts (100%) rename drizzle-orm/src/{pg-common => pg-core}/indexes.ts (98%) rename drizzle-orm/src/{pg-common => pg-core}/operations.ts (75%) rename drizzle-orm/src/{pg-common => pg-core}/query-builders/delete.ts (87%) rename drizzle-orm/src/{pg-common => pg-core}/query-builders/index.ts (100%) rename drizzle-orm/src/{pg-common => pg-core}/query-builders/insert.ts (92%) rename drizzle-orm/src/{pg-common => pg-core}/query-builders/select.ts (91%) rename drizzle-orm/src/{pg-common => pg-core}/query-builders/select.types.ts (94%) rename drizzle-orm/src/{pg-common => pg-core}/query-builders/update.ts (89%) rename drizzle-orm/src/{pg-common => pg-core}/session.ts (97%) rename drizzle-orm/src/{pg-common => pg-core}/table.ts (95%) rename drizzle-orm/src/{pg-common => pg-core}/utils.ts (90%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/README.md (60%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/alias.ts (84%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/checks.ts (94%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/blob.ts (92%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/common.ts (89%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/index.ts (100%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/integer.ts (96%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/numeric.ts (83%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/real.ts (87%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/columns/text.ts (83%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/db.ts (84%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/dialect.ts (93%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/expressions.ts (75%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/foreign-keys.ts (100%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/index.ts (100%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/indexes.ts (97%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/operations.ts (75%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/primary-keys.ts (100%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/query-builders/delete.ts (86%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/query-builders/index.ts (100%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/query-builders/insert.ts (90%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/query-builders/select.ts (91%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/query-builders/select.types.ts (92%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/query-builders/update.ts (89%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/session.ts (96%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/table.ts (94%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/unique-constraint.ts (100%) rename drizzle-orm/src/{sqlite-common => sqlite-core}/utils.ts (86%) diff --git a/.github/workflows/release-feature-branch.yaml b/.github/workflows/release-feature-branch.yaml index 58227d6a8..cf3bae51d 100644 --- a/.github/workflows/release-feature-branch.yaml +++ b/.github/workflows/release-feature-branch.yaml @@ -11,9 +11,6 @@ jobs: matrix: package: - drizzle-orm - - drizzle-orm-mysql - - drizzle-orm-pg - - drizzle-orm-sqlite - drizzle-zod runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/release-latest.yaml b/.github/workflows/release-latest.yaml index c1c422212..b90002870 100644 --- a/.github/workflows/release-latest.yaml +++ b/.github/workflows/release-latest.yaml @@ -8,9 +8,6 @@ jobs: matrix: package: - drizzle-orm - - drizzle-orm-mysql - - drizzle-orm-pg - - drizzle-orm-sqlite - drizzle-zod runs-on: ubuntu-20.04 steps: @@ -47,6 +44,10 @@ jobs: # Post release message to Discord curl -X POST -H "Content-Type: application/json" -d "{\"embeds\": [{\"title\": \"New \`${{ matrix.package }}\` release! 🎉\", \"url\": \"https://www.npmjs.com/package/${{ matrix.package }}\", \"color\": \"12907856\", \"fields\": [{\"name\": \"Tag\", \"value\": \"\`$tag\`\"}]}]}" ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }} + + # Put version to outputs + echo "::set-output name=version::$version" + echo "::set-output name=has_new_release::true" else echo "Already up to date: $version" fi @@ -54,3 +55,35 @@ jobs: shell: bash env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + + - name: Create GitHub release + uses: actions/github-script@v6 + if: ${{ steps.release.outputs.has_new_release == 'true' }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + const fs = require("fs"); + const path = require("path"); + + const changelog = fs.readFileSync(path.join(__dirname, "changelogs", "${{ matrix.package }}", "${{ steps.release.outputs.version }}.md"), "utf8"); + const version = "${{ steps.release.outputs.version }}"; + const tag = "latest"; + const release = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: tag, + name: `${{ matrix.package }} v${version}`, + body: changelog, + draft: true, + }); + await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.data.id, + name: `${{ matrix.package }}-${version}.tgz`, + data: fs.readFileSync(path.join(__dirname, "${{ matrix.package }}", "package.tgz")), + }); + } catch (e) { + core.setFailed(error.message); + } diff --git a/.github/workflows/unpublish-release-feature-branch.yaml b/.github/workflows/unpublish-release-feature-branch.yaml index a960d2a43..add070721 100644 --- a/.github/workflows/unpublish-release-feature-branch.yaml +++ b/.github/workflows/unpublish-release-feature-branch.yaml @@ -9,9 +9,6 @@ jobs: matrix: package: - drizzle-orm - - drizzle-orm-mysql - - drizzle-orm-pg - - drizzle-orm-sqlite - drizzle-zod runs-on: ubuntu-20.04 steps: diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 6d1450b6d..07b8bbbda 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -3,3 +3,4 @@ first-line-h1: false line-length: false MD010: spaces_per_tab: 2 + code_blocks: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a908aad9..89f93ed7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,18 +32,23 @@ There are several ways how you can provide a feedback ## Contribution guidelines --- -1. [General setup](#general-setup) - - [Install node](#installing-node) - - [Install pnpm](#installing-pnpm) - - [Install docker](#installing-docker) -2. [Local project setup](#local-project-setup) - - [Clone project](#clone-project) -3. [Building project](#building-project) - - [Build project](#build-project) - - [Run tests](#run-tests) -4. [Commits and PRs](#commits-pr) - - [Commit guideline](#commit-guideline) - - [PR guideline](#pr-guideline) +- [Contributing](#contributing) + - [ Submitting bug report](#-submitting-bug-report) + - [ Submitting feature request](#-submitting-feature-request) + - [ Providing feedback](#-providing-feedback) + - [ Contribution guidelines](#-contribution-guidelines) + - [ General setup](#-general-setup) + - [ Installing node](#-installing-node) + - [ Install pnpm](#-install-pnpm) + - [ Install docker](#-install-docker) + - [ Local project setup](#-local-project-setup) + - [ Clone project](#-clone-project) + - [ Building project](#-building-project) + - [ Build project](#-build-project) + - [ Run tests](#-run-tests) + - [ Commits and PRs](#-commits-and-prs) + - [ Commit guideline](#-commit-guideline) + - [ PR guideline](#-pr-guideline) ## General setup ### Installing node @@ -84,11 +89,11 @@ Project sctructure 📂 changelogs/ - all changelogs by modules -📂 drizzle-orm-pg/ - package with all resources for PostgreSQL database support +📂 drizzle-orm/src/pg-core/ - package with all resources for PostgreSQL database support -📂 drizzle-orm-sqlite/ - package with all resources for SQLite database support +📂 drizzle-orm/src/sqlite-core/ - package with all resources for SQLite database support -📂 drizzle-orm-mysql/ - package with all resources for MySQL database support +📂 drizzle-orm/src/mysql-core/ - package with all resources for MySQL database support 📂 examples/ - package with Drizzle ORM usage examples @@ -118,7 +123,7 @@ Commit message patten ``` Example ``` -drizzle-orm-pg: Add groupBy error message +drizzle-orm: [Pg] Add groupBy error message In specific case, groupBy was responding with unreadable error ... @@ -145,4 +150,4 @@ List of possible types for branch name --- Each PR should contain: - Tests on feature, that was created -- Tests on bugs, that was fixed \ No newline at end of file +- Tests on bugs, that was fixed diff --git a/README.md b/README.md index 7576a6b0e..97ea878c5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The ORM main philosophy is "If you know SQL, you know Drizzle ORM". We follow th Drizzle ORM is being battle-tested on production projects by multiple teams 🚀 Give it a try and let us know if you have any questions or feedback on [Discord](https://discord.gg/yfjTbVXMW4). -### Feature list +## Feature list - Full type safety - [Smart automated migrations generation](https://github.com/drizzle-team/drizzle-kit-mirror) @@ -25,27 +25,22 @@ Drizzle ORM is being battle-tested on production projects by multiple teams 🚀 - Auto-inferring of TS types for DB models for selections and insertions separately - Zero dependencies +## Database support status + | Database | Support | | |:------------|:-------:|:---| -| PostgreSQL | ✅ |[Docs](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-pg)| -| MySQL | ✅ |[Docs](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-mysql)| -| SQLite | ✅ |[Docs](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-sqlite)| +| PostgreSQL | ✅ | [Docs](./drizzle-orm/src/pg-core/README.md)| +| MySQL | ✅ |[Docs](./drizzle-orm/src/mysql-core/README.md)| +| SQLite | ✅ |[Docs](./drizzle-orm/src/sqlite-core/README.md)| | DynamoDB | ⏳ | | | MS SQL | ⏳ | | | CockroachDB | ⏳ | | -### Installation +## Installation ```bash -# postgresql -npm install drizzle-orm drizzle-orm-pg -npm install -D drizzle-kit - -# mysql -npm install drizzle-orm drizzle-orm-mysql -npm install -D drizzle-kit - -# sqlite -npm install drizzle-orm drizzle-orm-sqlite +npm install drizzle-orm npm install -D drizzle-kit ``` + +See [dialect-specific docs](#database-support-status) for more details. diff --git a/changelogs/drizzle-orm/0.17.0.md b/changelogs/drizzle-orm/0.17.0.md new file mode 100644 index 000000000..9ae73f8e0 --- /dev/null +++ b/changelogs/drizzle-orm/0.17.0.md @@ -0,0 +1,27 @@ +# drizzle-orm 0.17.0 + +## ❗ All ORM packages are now merged into `drizzle-orm` + +Starting from release `0.17.0` and onwards, all dialect-specific packages are merged into `drizzle-orm`. Legacy ORM packages will be archived. + +### Import paths changes + +#### PostgreSQL + +- `import { ... } from 'drizzle-orm-pg'` -> `import { ... } from 'drizzle-orm/pg-core'` +- `import { ... } from 'drizzle-orm-pg/node'` -> `import { ... } from 'drizzle-orm/node-postgres'` +- `import { ... } from 'drizzle-orm-pg/neondb'` -> `import { ... } from 'drizzle-orm/neon'` +- `import { ... } from 'drizzle-orm-pg/postgres.js'` -> `import { ... } from 'drizzle-orm/postgres.js'` + +#### MySQL + +- `import { ... } from 'drizzle-orm-mysql'` -> `import { ... } from 'drizzle-orm/mysql-core'` +- `import { ... } from 'drizzle-orm-mysql/mysql2'` -> `import { ... } from 'drizzle-orm/mysql2'` + +#### SQLite + +- `import { ... } from 'drizzle-orm-sqlite'` -> `import { ... } from 'drizzle-orm/sqlite-core'` +- `import { ... } from 'drizzle-orm-sqlite/better-sqlite3'` -> `import { ... } from 'drizzle-orm/better-sqlite3'` +- `import { ... } from 'drizzle-orm-sqlite/d1'` -> `import { ... } from 'drizzle-orm/d1'` +- `import { ... } from 'drizzle-orm-sqlite/bun'` -> `import { ... } from 'drizzle-orm/bun-sqlite'` +- `import { ... } from 'drizzle-orm-sqlite/sql.js'` -> `import { ... } from 'drizzle-orm/sql.js'` diff --git a/docs/custom-types.md b/docs/custom-types.md index 0ed268b52..4e4ce008b 100644 --- a/docs/custom-types.md +++ b/docs/custom-types.md @@ -27,6 +27,7 @@ Each type creation should use 2 classes: - Builder class is responsible for storing TS return type for specific database datatype and override build function to return ready to use column in table - `TData` - extends return type for column. Current example will infer string type for current datatype used in schema definition + ```typescript export class PgTextBuilder extends PgColumnBuilder< @@ -47,16 +48,18 @@ export class PgTextBuilder > `$pgColumnBuilderBrand` should be changed and be equal to class name for new data type builder ### Column class explanation - (postgresql text data type example) + --- Column class has set of types/functions, that could be overridden to get needed behavior for custom type - `TData` - extends return type for column. Current example will infer string type for current datatype used in schema definition -- `getSQLType()` - function, that shows datatype name in database and will be used in migration generation +- `getSQLType()` - function, that shows datatype name in database and will be used in migration generation -- `mapFromDriverValue` - interceptor between database and select query execution. If you want to modify/map/change value for specific data type, it could be done here +- `mapFromDriverValue()` - interceptor between database and select query execution. If you want to modify/map/change value for specific data type, it could be done here + +#### Usage example for jsonb type -#### Usage example for jsonb type: ```typescript override mapToDriverValue(value: TData): string { return JSON.stringify(value); @@ -65,7 +68,8 @@ override mapToDriverValue(value: TData): string { - `mapToDriverValue` - interceptor between user input for insert/update queries and database query. If you want to modify/map/change value for specific data type, it could be done here -#### Usage example for int type: +#### Usage example for int type + ```typescript override mapFromDriverValue(value: number | string): number { if (typeof value === 'string') { @@ -76,6 +80,7 @@ override mapFromDriverValue(value: number | string): number { ``` #### Column class example + ```typescript export class PgText extends PgColumn> { @@ -105,9 +110,9 @@ export class PgText
-### Full text data type for postgresql looks like: +### Full text data type for PostgreSQL example -For more postgres data type examples you could check [here](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-pg/src/columns) +For more postgres data type examples you could check [here](/drizzle-orm/src/pg-core/columns) ```typescript import { ColumnConfig } from 'drizzle-orm'; @@ -166,12 +171,14 @@ export function text(
### Setting up CITEXT datatype + --- > **Note** - This type is available only with extensions and used for example, just to show how you could setup any data type you want. Extension support will come soon + This type is available only with extensions and used for example, just to show how you could setup any data type you want. Extension support will come soon
### CITEXT data type example + ```typescript export class PgCITextBuilder extends PgColumnBuilder< ColumnBuilderConfig<{ data: TData; driverParam: string }> @@ -203,6 +210,7 @@ export function citext(name: string): PgCITextBuilder ``` #### Usage example + ```typescript const table = pgTable('table', { id: integer('id').primaryKey(), @@ -210,7 +218,7 @@ const table = pgTable('table', { }) ``` -# Contributing by adding new custom types in Drizzle ORM +## Contributing by adding new custom types in Drizzle ORM You could add your created custom data types to Drizzle ORM, so everyone can use it. diff --git a/drizzle-orm/README.md b/drizzle-orm/README.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/drizzle-orm/package.json b/drizzle-orm/package.json index 0a6b15bbc..75ec6376b 100644 --- a/drizzle-orm/package.json +++ b/drizzle-orm/package.json @@ -1,6 +1,6 @@ { "name": "drizzle-orm", - "version": "0.16.0", + "version": "0.17.0", "description": "Drizzle ORM package for SQL databases", "scripts": { "build": "tsc && resolve-tspaths && cp ../README.md package.json dist/", @@ -33,17 +33,18 @@ }, "homepage": "https://github.com/drizzle-team/drizzle-orm#readme", "peerDependencies": { - "mysql2": ">=2 <3", "@cloudflare/workers-types": ">=3", + "@neondatabase/serverless": ">=0.1 <0.2", "@types/better-sqlite3": "*", - "better-sqlite3": ">=7 <9", - "sqlite3": ">=5 <6", - "sql.js": ">=1 <2", - "@types/sql.js": "*", "@types/pg": "*", + "@types/sql.js": "*", + "better-sqlite3": ">=7 <9", + "mysql2": ">=2 <3", "pg": ">=8 <9", "postgres": ">=3 <4", - "@neondatabase/serverless": ">=0.1 <0.2" + "sql.js": ">=1 <2", + "sqlite3": ">=5 <6", + "bun-types": "*" }, "peerDependenciesMeta": { "mysql2": { @@ -78,20 +79,24 @@ }, "@neondatabase/serverless": { "optional": true + }, + "bun-types": { + "optional": true } }, "devDependencies": { - "@types/node": "^18.11.9", - "mysql2": "^2.3.3", "@cloudflare/workers-types": "^3.18.0", + "@neondatabase/serverless": "^0.1.13", "@types/better-sqlite3": "^7.6.2", + "@types/node": "^18.11.9", + "@types/pg": "^8.6.5", "@types/sql.js": "^1.4.4", "better-sqlite3": "^7.6.2", - "sql.js": "^1.8.0", - "sqlite3": "^5.1.2", - "@neondatabase/serverless": "^0.1.13", - "@types/pg": "^8.6.5", + "bun-types": "^0.5.0", + "mysql2": "^2.3.3", "pg": "^8.8.0", - "postgres": "^3.3.3" + "postgres": "^3.3.3", + "sql.js": "^1.8.0", + "sqlite3": "^5.1.2" } } diff --git a/drizzle-orm/src/better-sqlite3/driver.ts b/drizzle-orm/src/better-sqlite3/driver.ts index ba65031f3..be07a599e 100644 --- a/drizzle-orm/src/better-sqlite3/driver.ts +++ b/drizzle-orm/src/better-sqlite3/driver.ts @@ -1,7 +1,7 @@ import { Database, RunResult } from 'better-sqlite3'; -import { Logger } from 'drizzle-orm'; -import { BaseSQLiteDatabase } from '~/db'; -import { SQLiteSyncDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { BaseSQLiteDatabase } from '~/sqlite-core/db'; +import { SQLiteSyncDialect } from '~/sqlite-core/dialect'; import { BetterSQLiteSession } from './session'; export interface DrizzleConfig { diff --git a/drizzle-orm/src/better-sqlite3/migrator.ts b/drizzle-orm/src/better-sqlite3/migrator.ts index f33dd61a5..2b3dc25bf 100644 --- a/drizzle-orm/src/better-sqlite3/migrator.ts +++ b/drizzle-orm/src/better-sqlite3/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { BetterSQLite3Database } from './driver'; export function migrate(db: BetterSQLite3Database, config: string | MigrationConfig) { diff --git a/drizzle-orm/src/better-sqlite3/session.ts b/drizzle-orm/src/better-sqlite3/session.ts index e21222080..a149ee503 100644 --- a/drizzle-orm/src/better-sqlite3/session.ts +++ b/drizzle-orm/src/better-sqlite3/session.ts @@ -1,14 +1,14 @@ import { Database, RunResult, Statement } from 'better-sqlite3'; -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; -import { SQLiteSyncDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; +import { Logger, NoopLogger } from '~/logger'; +import { fillPlaceholders, Query } from '~/sql'; +import { SQLiteSyncDialect } from '~/sqlite-core/dialect'; +import { SelectFieldsOrdered } from '~/sqlite-core/operations'; import { PreparedQuery as PreparedQueryBase, PreparedQueryConfig as PreparedQueryConfigBase, SQLiteSession, -} from '~/session'; +} from '~/sqlite-core/session'; +import { mapResultRow } from '~/utils'; export interface BetterSQLiteSessionOptions { logger?: Logger; diff --git a/drizzle-orm/src/bun/driver.ts b/drizzle-orm/src/bun-sqlite/driver.ts similarity index 71% rename from drizzle-orm/src/bun/driver.ts rename to drizzle-orm/src/bun-sqlite/driver.ts index a8fb88dc7..7be7fc23b 100644 --- a/drizzle-orm/src/bun/driver.ts +++ b/drizzle-orm/src/bun-sqlite/driver.ts @@ -1,7 +1,9 @@ +/// + import { Database } from 'bun:sqlite'; -import { Logger } from 'drizzle-orm'; -import { BaseSQLiteDatabase } from '~/db'; -import { SQLiteSyncDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { BaseSQLiteDatabase } from '~/sqlite-core/db'; +import { SQLiteSyncDialect } from '~/sqlite-core/dialect'; import { SQLiteBunSession } from './session'; export interface DrizzleConfig { diff --git a/drizzle-orm/src/bun/index.ts b/drizzle-orm/src/bun-sqlite/index.ts similarity index 100% rename from drizzle-orm/src/bun/index.ts rename to drizzle-orm/src/bun-sqlite/index.ts diff --git a/drizzle-orm/src/bun/migrator.ts b/drizzle-orm/src/bun-sqlite/migrator.ts similarity index 74% rename from drizzle-orm/src/bun/migrator.ts rename to drizzle-orm/src/bun-sqlite/migrator.ts index c0b16f19e..15599f1c7 100644 --- a/drizzle-orm/src/bun/migrator.ts +++ b/drizzle-orm/src/bun-sqlite/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { BunSQLiteDatabase } from './driver'; export function migrate(db: BunSQLiteDatabase, config: string | MigrationConfig) { diff --git a/drizzle-orm/src/bun/session.ts b/drizzle-orm/src/bun-sqlite/session.ts similarity index 88% rename from drizzle-orm/src/bun/session.ts rename to drizzle-orm/src/bun-sqlite/session.ts index 12d03374c..6b81919c3 100644 --- a/drizzle-orm/src/bun/session.ts +++ b/drizzle-orm/src/bun-sqlite/session.ts @@ -1,14 +1,16 @@ +/// + import { Database, Statement as BunStatement } from 'bun:sqlite'; -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; -import { SQLiteSyncDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; +import { Logger, NoopLogger } from '~/logger'; +import { fillPlaceholders, Query } from '~/sql'; +import { SQLiteSyncDialect } from '~/sqlite-core/dialect'; +import { SelectFieldsOrdered } from '~/sqlite-core/operations'; import { PreparedQuery as PreparedQueryBase, PreparedQueryConfig as PreparedQueryConfigBase, SQLiteSession, -} from '~/session'; +} from '~/sqlite-core/session'; +import { mapResultRow } from '~/utils'; export interface SQLiteBunSessionOptions { logger?: Logger; diff --git a/drizzle-orm/src/d1/driver.ts b/drizzle-orm/src/d1/driver.ts index 468df4bb6..a2d848e97 100644 --- a/drizzle-orm/src/d1/driver.ts +++ b/drizzle-orm/src/d1/driver.ts @@ -1,6 +1,8 @@ -import { Logger } from 'drizzle-orm'; -import { BaseSQLiteDatabase } from '~/db'; -import { SQLiteAsyncDialect } from '~/dialect'; +/// + +import { Logger } from '~/logger'; +import { BaseSQLiteDatabase } from '~/sqlite-core/db'; +import { SQLiteAsyncDialect } from '~/sqlite-core/dialect'; import { SQLiteD1Session } from './session'; export interface DrizzleConfig { diff --git a/drizzle-orm/src/d1/migrator.ts b/drizzle-orm/src/d1/migrator.ts index cb6f1859f..bd16cca2c 100644 --- a/drizzle-orm/src/d1/migrator.ts +++ b/drizzle-orm/src/d1/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { DrizzleD1Database } from './driver'; export async function migrate(db: DrizzleD1Database, config: string | MigrationConfig) { diff --git a/drizzle-orm/src/d1/session.ts b/drizzle-orm/src/d1/session.ts index dfc125bf2..c115c74b3 100644 --- a/drizzle-orm/src/d1/session.ts +++ b/drizzle-orm/src/d1/session.ts @@ -1,13 +1,15 @@ -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; -import { SQLiteAsyncDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; +/// + +import { Logger, NoopLogger } from '~/logger'; +import { fillPlaceholders, Query } from '~/sql'; +import { SQLiteAsyncDialect } from '~/sqlite-core/dialect'; +import { SelectFieldsOrdered } from '~/sqlite-core/operations'; import { PreparedQuery as PreparedQueryBase, PreparedQueryConfig as PreparedQueryConfigBase, SQLiteSession, -} from '~/session'; +} from '~/sqlite-core/session'; +import { mapResultRow } from '~/utils'; export interface SQLiteD1SessionOptions { logger?: Logger; @@ -28,7 +30,7 @@ export class SQLiteD1Session extends SQLiteSession<'async', D1Result> { } exec(query: string): void { - throw Error('To implement: D1 migrator') + throw Error('To implement: D1 migrator'); // await this.client.exec(query.sql); } diff --git a/drizzle-orm/src/index.ts b/drizzle-orm/src/index.ts index b0b4eb0db..507ca0e0d 100644 --- a/drizzle-orm/src/index.ts +++ b/drizzle-orm/src/index.ts @@ -1,4 +1,4 @@ export * from './column'; -export * from './connection'; +export * from './logger'; export { param, sql } from './sql'; export { Table } from './table'; diff --git a/drizzle-orm/src/connection.ts b/drizzle-orm/src/logger.ts similarity index 100% rename from drizzle-orm/src/connection.ts rename to drizzle-orm/src/logger.ts diff --git a/drizzle-orm/src/mysql-common/README.md b/drizzle-orm/src/mysql-core/README.md similarity index 91% rename from drizzle-orm/src/mysql-common/README.md rename to drizzle-orm/src/mysql-core/README.md index bcec81cba..08578251e 100644 --- a/drizzle-orm/src/mysql-common/README.md +++ b/drizzle-orm/src/mysql-core/README.md @@ -1,10 +1,10 @@
-

Drizzle ORM | MySQL npm

-npm -pg version -npm bundle size +

Drizzle ORM | MySQL npm

+npm +Driver version +npm bundle size Discord -NPM +NPM
If you know SQL, you know Drizzle ORM

@@ -15,15 +15,15 @@ Drizzle ORM is a TypeScript ORM for SQL databases designed with maximum type saf ```bash # npm -npm i drizzle-orm drizzle-orm-mysql mysql2 +npm i drizzle-orm mysql2 npm i -D drizzle-kit # yarn -yarn add drizzle-orm drizzle-orm-mysql mysql2 +yarn add drizzle-orm mysql2 yarn add -D drizzle-kit # pnpm -pnpm add drizzle-orm drizzle-orm-mysql2 mysql2 +pnpm add drizzle-orm mysql2 pnpm add -D drizzle-kit ``` @@ -71,7 +71,7 @@ export const users = mysqlTable('users', { ```typescript // db.ts -import { drizzle } from 'drizzle-orm-mysql/mysql2'; +import { drizzle } from 'drizzle-orm/mysql2'; import mysql from 'mysql2/promise'; import { users } from './schema'; @@ -92,7 +92,7 @@ const allUsers = await db.select(users); ```typescript // db.ts -import { drizzle } from 'drizzle-orm-mysql/mysql2'; +import { drizzle } from 'drizzle-orm/mysql2'; import mysql from 'mysql2/promise'; import { users } from './schema'; @@ -115,7 +115,7 @@ This is how you declare SQL schema in `schema.ts`. You can declare tables, index ```typescript // db.ts -import { int, mysqlEnum, mysqlTable, serial, uniqueIndex, varchar } from 'drizzle-orm-mysql'; +import { int, mysqlEnum, mysqlTable, serial, uniqueIndex, varchar } from 'drizzle-orm/mysql-core'; // declaring enum in database export const countries = mysqlTable('countries', { @@ -137,9 +137,9 @@ export const cities = mysqlTable('cities', { ```typescript // db.ts -import { InferModel, MySqlDatabase, MySqlRawQueryResult, mysqlTable, serial, text, varchar } from 'drizzle-orm-mysql'; +import { InferModel, MySqlDatabase, MySqlRawQueryResult, mysqlTable, serial, text, varchar } from 'drizzle-orm/mysql-core'; import mysql from 'mysql2/promise'; -import { drizzle } from 'drizzle-orm-mysql/mysql2'; +import { drizzle } from 'drizzle-orm/mysql2'; const users = mysqlTable('users', { id: serial('id').primaryKey(), @@ -183,7 +183,7 @@ export async function insertUser(user: NewUser): Promise { ```typescript // db.ts -import { foreignKey, index, int, mysqlTable, serial, uniqueIndex, varchar } from 'drizzle-orm-mysql'; +import { foreignKey, index, int, mysqlTable, serial, uniqueIndex, varchar } from 'drizzle-orm/mysql-core'; export const countries = mysqlTable('countries', { id: serial('id').primaryKey(), @@ -265,14 +265,16 @@ json('name'); ``` ## Table schemas + > **Warning** -> If you will have tables with same names in different schemas then drizzle will respond with `never[]` error in result types and error from database -> -> In this case you may use [alias syntax](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-mysql#join-aliases-and-self-joins) +> If you have tables with same names in different schemas, Drizzle will set result types to `never[]` and return an error from the database. +> +> In this case you may use [alias syntax](/drizzle-orm/src/mysql-core/README.md#join-aliases-and-self-joins). --- Usage example + ```typescript // Table in default schema const publicUsersTable = mysqlTable('users', { @@ -304,8 +306,8 @@ Querying, sorting and filtering. We also support partial select. ```typescript ... -import { mysqlTable, serial, text, varchar } from 'drizzle-orm-mysql'; -import { drizzle } from 'drizzle-orm-mysql/mysql2'; +import { mysqlTable, serial, text, varchar } from 'drizzle-orm/mysql-core'; +import { drizzle } from 'drizzle-orm/mysql2'; import { and, asc, desc, eq, or } from 'drizzle-orm/expressions'; const users = mysqlTable('users', { @@ -386,8 +388,8 @@ or(expressions: SQL[]) ### Insert ```typescript -import { mysqlTable, serial, text, timestamp, InferModel } from 'drizzle-orm-mysql'; -import { drizzle } from 'drizzle-orm-mysql/mysql2'; +import { mysqlTable, serial, text, timestamp, InferModel } from 'drizzle-orm/mysql-core'; +import { drizzle } from 'drizzle-orm/mysql2'; const users = mysqlTable('users', { id: serial('id').primaryKey(), @@ -493,7 +495,7 @@ const result = await db.select(usersToChatGroups) #### Join aliases and self-joins ```typescript -import { ..., alias } from 'drizzle-orm-mysql'; +import { ..., alias } from 'drizzle-orm/mysql-core'; export const files = mysqlTable('folders', { name: text('name').notNull(), @@ -543,7 +545,7 @@ const result = await query.execute(); ### Prepared statements with parameters ```typescript -import { placeholder } from 'drizzle-orm-mysql'; +import { placeholder } from 'drizzle-orm/mysql-core'; const query = db.select(users) .where(eq(users.name, placeholder('name'))) @@ -572,7 +574,7 @@ Check out the [docs for DrizzleKit](https://github.com/drizzle-team/drizzle-kit- For schema file: ```typescript -import { index, integer, mysqlTable, serial, varchar } from 'drizzle-orm-mysql'; +import { index, integer, mysqlTable, serial, varchar } from 'drizzle-orm/mysql-core'; export const users = mysqlTable('users', { id: serial('id').primaryKey(), @@ -611,8 +613,8 @@ CREATE INDEX name_idx ON users (`full_name`); And you can run migrations manually or using our embedded migrations module ```typescript -import { drizzle } from 'drizzle-orm-mysql/mysql2'; -import { migrate } from 'drizzle-orm-mysql/mysql2/migrator'; +import { drizzle } from 'drizzle-orm/mysql2'; +import { migrate } from 'drizzle-orm/mysql2/migrator'; import mysql from 'mysql2/promise'; // create the connection diff --git a/drizzle-orm/src/mysql-common/alias.ts b/drizzle-orm/src/mysql-core/alias.ts similarity index 84% rename from drizzle-orm/src/mysql-common/alias.ts rename to drizzle-orm/src/mysql-core/alias.ts index fa250cd2e..be6d4b785 100644 --- a/drizzle-orm/src/mysql-common/alias.ts +++ b/drizzle-orm/src/mysql-core/alias.ts @@ -1,4 +1,4 @@ -import { TableAliasProxyHandler } from 'drizzle-orm/alias'; +import { TableAliasProxyHandler } from '~/alias'; import { BuildAliasTable } from './query-builders/select.types'; import { AnyMySqlTable } from './table'; diff --git a/drizzle-orm/src/mysql-common/checks.ts b/drizzle-orm/src/mysql-core/checks.ts similarity index 93% rename from drizzle-orm/src/mysql-common/checks.ts rename to drizzle-orm/src/mysql-core/checks.ts index 3b4c37d98..638bc432d 100644 --- a/drizzle-orm/src/mysql-common/checks.ts +++ b/drizzle-orm/src/mysql-core/checks.ts @@ -1,4 +1,4 @@ -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { AnyMySqlTable } from './table'; export class CheckBuilder { diff --git a/drizzle-orm/src/mysql-common/columns/bigint.ts b/drizzle-orm/src/mysql-core/columns/bigint.ts similarity index 93% rename from drizzle-orm/src/mysql-common/columns/bigint.ts rename to drizzle-orm/src/mysql-core/columns/bigint.ts index ee72e4834..9f1ecc7cd 100644 --- a/drizzle-orm/src/mysql-common/columns/bigint.ts +++ b/drizzle-orm/src/mysql-core/columns/bigint.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; diff --git a/drizzle-orm/src/mysql-common/columns/binary.ts b/drizzle-orm/src/mysql-core/columns/binary.ts similarity index 89% rename from drizzle-orm/src/mysql-common/columns/binary.ts rename to drizzle-orm/src/mysql-core/columns/binary.ts index 308648b88..6f5db71c2 100644 --- a/drizzle-orm/src/mysql-common/columns/binary.ts +++ b/drizzle-orm/src/mysql-core/columns/binary.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlBinaryBuilder extends MySqlColumnBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/boolean.ts b/drizzle-orm/src/mysql-core/columns/boolean.ts similarity index 85% rename from drizzle-orm/src/mysql-common/columns/boolean.ts rename to drizzle-orm/src/mysql-core/columns/boolean.ts index 0570d59f5..fafc673c5 100644 --- a/drizzle-orm/src/mysql-common/columns/boolean.ts +++ b/drizzle-orm/src/mysql-core/columns/boolean.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlBooleanBuilder extends MySqlColumnBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/char.ts b/drizzle-orm/src/mysql-core/columns/char.ts similarity index 89% rename from drizzle-orm/src/mysql-common/columns/char.ts rename to drizzle-orm/src/mysql-core/columns/char.ts index c19a77592..684ff4ed4 100644 --- a/drizzle-orm/src/mysql-common/columns/char.ts +++ b/drizzle-orm/src/mysql-core/columns/char.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlCharBuilder extends MySqlColumnBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/common.ts b/drizzle-orm/src/mysql-core/columns/common.ts similarity index 91% rename from drizzle-orm/src/mysql-common/columns/common.ts rename to drizzle-orm/src/mysql-core/columns/common.ts index 02333159d..4b7609100 100644 --- a/drizzle-orm/src/mysql-common/columns/common.ts +++ b/drizzle-orm/src/mysql-core/columns/common.ts @@ -1,16 +1,11 @@ -import { Column, ColumnBaseConfig } from 'drizzle-orm'; -import { - ColumnBuilder, - ColumnBuilderBaseConfig, - ColumnBuilderWithConfig, - UpdateCBConfig, -} from 'drizzle-orm/column-builder'; -import { SQL } from 'drizzle-orm/sql'; -import { Update } from 'drizzle-orm/utils'; -import { Simplify } from 'drizzle-orm/utils'; - -import { ForeignKey, ForeignKeyBuilder, UpdateDeleteAction } from '~/foreign-keys'; -import { AnyMySqlTable } from '~/table'; +import { Column, ColumnBaseConfig } from '~/column'; +import { ColumnBuilder, ColumnBuilderBaseConfig, ColumnBuilderWithConfig, UpdateCBConfig } from '~/column-builder'; +import { SQL } from '~/sql'; +import { Update } from '~/utils'; +import { Simplify } from '~/utils'; + +import { ForeignKey, ForeignKeyBuilder, UpdateDeleteAction } from '~/mysql-core/foreign-keys'; +import { AnyMySqlTable } from '~/mysql-core/table'; export interface ReferenceConfig { ref: () => AnyMySqlColumn; diff --git a/drizzle-orm/src/mysql-common/columns/custom.ts b/drizzle-orm/src/mysql-core/columns/custom.ts similarity index 97% rename from drizzle-orm/src/mysql-common/columns/custom.ts rename to drizzle-orm/src/mysql-core/columns/custom.ts index 237b5867d..cafbafcfa 100644 --- a/drizzle-orm/src/mysql-common/columns/custom.ts +++ b/drizzle-orm/src/mysql-core/columns/custom.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export type CustomColumnBuildeConfig = { @@ -105,7 +105,7 @@ export type CustomTypeValues = { /** * If your custom data type has default you can use `default: true` - * + * * @example * const customSerial = customType<{ data: number, notNull: true, default: true }>({ * dataType() { diff --git a/drizzle-orm/src/mysql-common/columns/date.common.ts b/drizzle-orm/src/mysql-core/columns/date.common.ts similarity index 90% rename from drizzle-orm/src/mysql-common/columns/date.common.ts rename to drizzle-orm/src/mysql-core/columns/date.common.ts index 75119a702..73a1f8cb4 100644 --- a/drizzle-orm/src/mysql-common/columns/date.common.ts +++ b/drizzle-orm/src/mysql-core/columns/date.common.ts @@ -1,6 +1,5 @@ -import { sql } from 'drizzle-orm'; -import { ColumnBuilderBaseConfig, UpdateCBConfig } from 'drizzle-orm/column-builder'; -import { SQL } from 'drizzle-orm/sql'; +import { ColumnBuilderBaseConfig, UpdateCBConfig } from '~/column-builder'; +import { SQL, sql } from '~/sql'; import { MySqlColumnBuilder } from './common'; diff --git a/drizzle-orm/src/mysql-common/columns/date.ts b/drizzle-orm/src/mysql-core/columns/date.ts similarity index 93% rename from drizzle-orm/src/mysql-common/columns/date.ts rename to drizzle-orm/src/mysql-core/columns/date.ts index 1268de80a..c39da8583 100644 --- a/drizzle-orm/src/mysql-common/columns/date.ts +++ b/drizzle-orm/src/mysql-core/columns/date.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlDateBuilder diff --git a/drizzle-orm/src/mysql-common/columns/datetime.ts b/drizzle-orm/src/mysql-core/columns/datetime.ts similarity index 89% rename from drizzle-orm/src/mysql-common/columns/datetime.ts rename to drizzle-orm/src/mysql-core/columns/datetime.ts index 95dac0755..f76021ff3 100644 --- a/drizzle-orm/src/mysql-common/columns/datetime.ts +++ b/drizzle-orm/src/mysql-core/columns/datetime.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlDateTimeBuilder extends MySqlColumnBuilder< @@ -54,12 +54,10 @@ export class MySqlDateTime< } } -export class MySqlDateTimeStringBuilder - extends MySqlColumnBuilder< - ColumnBuilderConfig<{ data: string; driverParam: string | number }>, - { fsp: number | undefined } - > -{ +export class MySqlDateTimeStringBuilder extends MySqlColumnBuilder< + ColumnBuilderConfig<{ data: string; driverParam: string | number }>, + { fsp: number | undefined } +> { constructor( name: string, fsp: number | undefined, diff --git a/drizzle-orm/src/mysql-common/columns/decimal.ts b/drizzle-orm/src/mysql-core/columns/decimal.ts similarity index 91% rename from drizzle-orm/src/mysql-common/columns/decimal.ts rename to drizzle-orm/src/mysql-core/columns/decimal.ts index df7c49e60..8ef88cb65 100644 --- a/drizzle-orm/src/mysql-common/columns/decimal.ts +++ b/drizzle-orm/src/mysql-core/columns/decimal.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlDecimalBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/double.ts b/drizzle-orm/src/mysql-core/columns/double.ts similarity index 92% rename from drizzle-orm/src/mysql-common/columns/double.ts rename to drizzle-orm/src/mysql-core/columns/double.ts index c7a025075..07547afe5 100644 --- a/drizzle-orm/src/mysql-common/columns/double.ts +++ b/drizzle-orm/src/mysql-core/columns/double.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlDoubleBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/enum.ts b/drizzle-orm/src/mysql-core/columns/enum.ts similarity index 96% rename from drizzle-orm/src/mysql-common/columns/enum.ts rename to drizzle-orm/src/mysql-core/columns/enum.ts index 30e35d717..fe022fce1 100644 --- a/drizzle-orm/src/mysql-common/columns/enum.ts +++ b/drizzle-orm/src/mysql-core/columns/enum.ts @@ -1,5 +1,5 @@ -import { Update } from 'drizzle-orm/utils'; -import { AnyMySqlTable } from '~/table'; +import { AnyMySqlTable } from '~/mysql-core/table'; +import { Update } from '~/utils'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export interface MySqlEnumColumnBuilderConfig { diff --git a/drizzle-orm/src/mysql-common/columns/float.ts b/drizzle-orm/src/mysql-core/columns/float.ts similarity index 91% rename from drizzle-orm/src/mysql-common/columns/float.ts rename to drizzle-orm/src/mysql-core/columns/float.ts index 1b83ff395..eb75db265 100644 --- a/drizzle-orm/src/mysql-common/columns/float.ts +++ b/drizzle-orm/src/mysql-core/columns/float.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlFloatBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/index.ts b/drizzle-orm/src/mysql-core/columns/index.ts similarity index 100% rename from drizzle-orm/src/mysql-common/columns/index.ts rename to drizzle-orm/src/mysql-core/columns/index.ts diff --git a/drizzle-orm/src/mysql-common/columns/int.ts b/drizzle-orm/src/mysql-core/columns/int.ts similarity index 86% rename from drizzle-orm/src/mysql-common/columns/int.ts rename to drizzle-orm/src/mysql-core/columns/int.ts index 7b3e823b1..17dce78e0 100644 --- a/drizzle-orm/src/mysql-common/columns/int.ts +++ b/drizzle-orm/src/mysql-core/columns/int.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlIntegerBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/json.ts b/drizzle-orm/src/mysql-core/columns/json.ts similarity index 85% rename from drizzle-orm/src/mysql-common/columns/json.ts rename to drizzle-orm/src/mysql-core/columns/json.ts index a27b01aa1..faec9cc18 100644 --- a/drizzle-orm/src/mysql-common/columns/json.ts +++ b/drizzle-orm/src/mysql-core/columns/json.ts @@ -1,7 +1,7 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlJsonBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/mediumint.ts b/drizzle-orm/src/mysql-core/columns/mediumint.ts similarity index 86% rename from drizzle-orm/src/mysql-common/columns/mediumint.ts rename to drizzle-orm/src/mysql-core/columns/mediumint.ts index d2404c923..44114ac13 100644 --- a/drizzle-orm/src/mysql-common/columns/mediumint.ts +++ b/drizzle-orm/src/mysql-core/columns/mediumint.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlMediumIntBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/real.ts b/drizzle-orm/src/mysql-core/columns/real.ts similarity index 91% rename from drizzle-orm/src/mysql-common/columns/real.ts rename to drizzle-orm/src/mysql-core/columns/real.ts index 697098449..ac0bbb20d 100644 --- a/drizzle-orm/src/mysql-common/columns/real.ts +++ b/drizzle-orm/src/mysql-core/columns/real.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder, diff --git a/drizzle-orm/src/mysql-common/columns/serial.ts b/drizzle-orm/src/mysql-core/columns/serial.ts similarity index 94% rename from drizzle-orm/src/mysql-common/columns/serial.ts rename to drizzle-orm/src/mysql-core/columns/serial.ts index c1646fb16..5d8b3c911 100644 --- a/drizzle-orm/src/mysql-common/columns/serial.ts +++ b/drizzle-orm/src/mysql-core/columns/serial.ts @@ -1,4 +1,4 @@ -import { AnyMySqlTable } from '~/table'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlSerialBuilder extends MySqlColumnBuilder<{ diff --git a/drizzle-orm/src/mysql-common/columns/smallint.ts b/drizzle-orm/src/mysql-core/columns/smallint.ts similarity index 86% rename from drizzle-orm/src/mysql-common/columns/smallint.ts rename to drizzle-orm/src/mysql-core/columns/smallint.ts index 0baf44484..eac2f6ab0 100644 --- a/drizzle-orm/src/mysql-common/columns/smallint.ts +++ b/drizzle-orm/src/mysql-core/columns/smallint.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlSmallIntBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/text.ts b/drizzle-orm/src/mysql-core/columns/text.ts similarity index 92% rename from drizzle-orm/src/mysql-common/columns/text.ts rename to drizzle-orm/src/mysql-core/columns/text.ts index 8ed22779c..ae752ea8b 100644 --- a/drizzle-orm/src/mysql-common/columns/text.ts +++ b/drizzle-orm/src/mysql-core/columns/text.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export type MySqlTextColumnType = 'tinytext' | 'text' | 'mediumtext' | 'longtext'; diff --git a/drizzle-orm/src/mysql-common/columns/time.ts b/drizzle-orm/src/mysql-core/columns/time.ts similarity index 89% rename from drizzle-orm/src/mysql-common/columns/time.ts rename to drizzle-orm/src/mysql-core/columns/time.ts index 14082daf7..a21baa5a3 100644 --- a/drizzle-orm/src/mysql-common/columns/time.ts +++ b/drizzle-orm/src/mysql-core/columns/time.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlTimeBuilder extends MySqlColumnBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/timestamp.ts b/drizzle-orm/src/mysql-core/columns/timestamp.ts similarity index 95% rename from drizzle-orm/src/mysql-common/columns/timestamp.ts rename to drizzle-orm/src/mysql-core/columns/timestamp.ts index 9d6683555..69f0f7806 100644 --- a/drizzle-orm/src/mysql-common/columns/timestamp.ts +++ b/drizzle-orm/src/mysql-core/columns/timestamp.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn } from './common'; import { MySqlDateColumnBaseBuilder } from './date.common'; export class MySqlTimestampBuilder extends MySqlDateColumnBaseBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/tinyint.ts b/drizzle-orm/src/mysql-core/columns/tinyint.ts similarity index 86% rename from drizzle-orm/src/mysql-common/columns/tinyint.ts rename to drizzle-orm/src/mysql-core/columns/tinyint.ts index f7ed0f887..dbe4d3585 100644 --- a/drizzle-orm/src/mysql-common/columns/tinyint.ts +++ b/drizzle-orm/src/mysql-core/columns/tinyint.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common'; export class MySqlTinyIntBuilder extends MySqlColumnBuilderWithAutoIncrement< diff --git a/drizzle-orm/src/mysql-common/columns/varbinary.ts b/drizzle-orm/src/mysql-core/columns/varbinary.ts similarity index 89% rename from drizzle-orm/src/mysql-common/columns/varbinary.ts rename to drizzle-orm/src/mysql-core/columns/varbinary.ts index 81288e5bb..0a0c3ba04 100644 --- a/drizzle-orm/src/mysql-common/columns/varbinary.ts +++ b/drizzle-orm/src/mysql-core/columns/varbinary.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlVarBinaryBuilder extends MySqlColumnBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/varchar.ts b/drizzle-orm/src/mysql-core/columns/varchar.ts similarity index 91% rename from drizzle-orm/src/mysql-common/columns/varchar.ts rename to drizzle-orm/src/mysql-core/columns/varchar.ts index 44b0f94ca..95a644058 100644 --- a/drizzle-orm/src/mysql-common/columns/varchar.ts +++ b/drizzle-orm/src/mysql-core/columns/varchar.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlVarCharBuilder< diff --git a/drizzle-orm/src/mysql-common/columns/year.ts b/drizzle-orm/src/mysql-core/columns/year.ts similarity index 84% rename from drizzle-orm/src/mysql-common/columns/year.ts rename to drizzle-orm/src/mysql-core/columns/year.ts index aa8a402ce..d82c2303b 100644 --- a/drizzle-orm/src/mysql-common/columns/year.ts +++ b/drizzle-orm/src/mysql-core/columns/year.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyMySqlTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyMySqlTable } from '~/mysql-core/table'; import { MySqlColumn, MySqlColumnBuilder } from './common'; export class MySqlYearBuilder diff --git a/drizzle-orm/src/mysql-common/db.ts b/drizzle-orm/src/mysql-core/db.ts similarity index 91% rename from drizzle-orm/src/mysql-common/db.ts rename to drizzle-orm/src/mysql-core/db.ts index fc1c3050c..b55e84209 100644 --- a/drizzle-orm/src/mysql-common/db.ts +++ b/drizzle-orm/src/mysql-core/db.ts @@ -1,5 +1,5 @@ -import { SQLWrapper } from 'drizzle-orm/sql'; import { ResultSetHeader } from 'mysql2/promise'; +import { SQLWrapper } from '~/sql'; import { MySqlDialect } from './dialect'; import { MySqlDelete, MySqlInsertBuilder, MySqlSelect, MySqlUpdateBuilder } from './query-builders'; import { MySqlQueryResult, MySqlSession } from './session'; @@ -9,9 +9,10 @@ import { orderSelectedFields } from './utils'; export class MySqlDatabase { constructor( /** @internal */ - readonly dialect: MySqlDialect, + readonly dialect: MySqlDialect, /** @internal */ - readonly session: MySqlSession) {} + readonly session: MySqlSession, + ) {} select(from: TTable): MySqlSelect { const fields = orderSelectedFields(from[MySqlTable.Symbol.Columns]); diff --git a/drizzle-orm/src/mysql-common/dialect.ts b/drizzle-orm/src/mysql-core/dialect.ts similarity index 98% rename from drizzle-orm/src/mysql-common/dialect.ts rename to drizzle-orm/src/mysql-core/dialect.ts index f5f455b0d..39a5491e6 100644 --- a/drizzle-orm/src/mysql-common/dialect.ts +++ b/drizzle-orm/src/mysql-core/dialect.ts @@ -1,7 +1,8 @@ -import { AnyColumn, Column, Table } from 'drizzle-orm'; -import { MigrationMeta } from 'drizzle-orm/migrator'; -import { Name, Query, SQL, sql, SQLResponse, SQLSourceParam } from 'drizzle-orm/sql'; +import { AnyColumn, Column } from '~/column'; +import { MigrationMeta } from '~/migrator'; import { SelectFieldsOrdered } from '~/operations'; +import { Name, Query, SQL, sql, SQLResponse, SQLSourceParam } from '~/sql'; +import { Table } from '~/table'; import { AnyMySqlColumn, MySqlColumn } from './columns/common'; import { MySqlDatabase } from './db'; import { MySqlDeleteConfig } from './query-builders/delete'; diff --git a/drizzle-orm/src/mysql-common/expressions.ts b/drizzle-orm/src/mysql-core/expressions.ts similarity index 80% rename from drizzle-orm/src/mysql-common/expressions.ts rename to drizzle-orm/src/mysql-core/expressions.ts index b6f62d318..c476c6748 100644 --- a/drizzle-orm/src/mysql-common/expressions.ts +++ b/drizzle-orm/src/mysql-core/expressions.ts @@ -1,8 +1,7 @@ -import { sql } from 'drizzle-orm'; -import { param, SQL, SQLSourceParam } from 'drizzle-orm/sql'; +import { param, SQL, sql, SQLSourceParam } from '~/sql'; import { AnyMySqlColumn } from './columns/common'; -export * from 'drizzle-orm/expressions'; +export * from '~/expressions'; export function concat(column: AnyMySqlColumn, value: string): SQL { return sql`${column} || ${param(value, column)}`; diff --git a/drizzle-orm/src/mysql-common/foreign-keys.ts b/drizzle-orm/src/mysql-core/foreign-keys.ts similarity index 100% rename from drizzle-orm/src/mysql-common/foreign-keys.ts rename to drizzle-orm/src/mysql-core/foreign-keys.ts diff --git a/drizzle-orm/src/mysql-common/index.ts b/drizzle-orm/src/mysql-core/index.ts similarity index 100% rename from drizzle-orm/src/mysql-common/index.ts rename to drizzle-orm/src/mysql-core/index.ts diff --git a/drizzle-orm/src/mysql-common/indexes.ts b/drizzle-orm/src/mysql-core/indexes.ts similarity index 98% rename from drizzle-orm/src/mysql-common/indexes.ts rename to drizzle-orm/src/mysql-core/indexes.ts index cc6278091..fb970eebb 100644 --- a/drizzle-orm/src/mysql-common/indexes.ts +++ b/drizzle-orm/src/mysql-core/indexes.ts @@ -1,4 +1,4 @@ -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { AnyMySqlColumn } from './columns'; import { AnyMySqlTable } from './table'; diff --git a/drizzle-orm/src/mysql-common/operations.ts b/drizzle-orm/src/mysql-core/operations.ts similarity index 84% rename from drizzle-orm/src/mysql-common/operations.ts rename to drizzle-orm/src/mysql-core/operations.ts index 65bcd8b02..b2a7481a7 100644 --- a/drizzle-orm/src/mysql-common/operations.ts +++ b/drizzle-orm/src/mysql-core/operations.ts @@ -1,7 +1,7 @@ -import { GetColumnData } from 'drizzle-orm'; -import { SelectFieldsOrdered as SelectFieldsOrderedBase } from 'drizzle-orm/operations'; -import { SQL, SQLResponse } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; +import { GetColumnData } from '~/column'; +import { SelectFieldsOrdered as SelectFieldsOrderedBase } from '~/operations'; +import { SQL, SQLResponse } from '~/sql'; +import { Simplify } from '~/utils'; import { AnyMySqlColumn } from './columns/common'; import { AnyMySqlTable, GetTableConfig } from './table'; diff --git a/drizzle-orm/src/mysql-common/query-builders/delete.ts b/drizzle-orm/src/mysql-core/query-builders/delete.ts similarity index 79% rename from drizzle-orm/src/mysql-common/query-builders/delete.ts rename to drizzle-orm/src/mysql-core/query-builders/delete.ts index 2cf3f7dbd..e83837ac8 100644 --- a/drizzle-orm/src/mysql-common/query-builders/delete.ts +++ b/drizzle-orm/src/mysql-core/query-builders/delete.ts @@ -1,10 +1,9 @@ -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { MySqlDialect } from '~/dialect'; -import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/operations'; -import { MySqlQueryResult, MySqlRawQueryResult, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/session'; -import { AnyMySqlTable, InferModel, MySqlTable } from '~/table'; -import { orderSelectedFields } from '~/utils'; +import { MySqlDialect } from '~/mysql-core/dialect'; +import { SelectFieldsOrdered } from '~/mysql-core/operations'; +import { MySqlRawQueryResult, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/mysql-core/session'; +import { AnyMySqlTable } from '~/mysql-core/table'; +import { QueryPromise } from '~/query-promise'; +import { Query, SQL, SQLWrapper } from '~/sql'; export interface MySqlDeleteConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/mysql-common/query-builders/index.ts b/drizzle-orm/src/mysql-core/query-builders/index.ts similarity index 100% rename from drizzle-orm/src/mysql-common/query-builders/index.ts rename to drizzle-orm/src/mysql-core/query-builders/index.ts diff --git a/drizzle-orm/src/mysql-common/query-builders/insert.ts b/drizzle-orm/src/mysql-core/query-builders/insert.ts similarity index 84% rename from drizzle-orm/src/mysql-common/query-builders/insert.ts rename to drizzle-orm/src/mysql-core/query-builders/insert.ts index e70224f5d..21a326e8f 100644 --- a/drizzle-orm/src/mysql-common/query-builders/insert.ts +++ b/drizzle-orm/src/mysql-core/query-builders/insert.ts @@ -1,12 +1,11 @@ -import { Table } from 'drizzle-orm'; -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Param, Placeholder, Query, sql, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { MySqlDialect } from '~/dialect'; -import { IndexColumn } from '~/indexes'; -import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/operations'; -import { MySqlQueryResult, MySqlRawQueryResult, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/session'; -import { AnyMySqlTable, InferModel, MySqlTable } from '~/table'; -import { mapUpdateSet, orderSelectedFields } from '~/utils'; +import { MySqlDialect } from '~/mysql-core/dialect'; +import { SelectFieldsOrdered } from '~/mysql-core/operations'; +import { MySqlRawQueryResult, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/mysql-core/session'; +import { AnyMySqlTable, InferModel } from '~/mysql-core/table'; +import { mapUpdateSet } from '~/mysql-core/utils'; +import { QueryPromise } from '~/query-promise'; +import { Param, Placeholder, Query, SQL, sql, SQLWrapper } from '~/sql'; +import { Table } from '~/table'; import { MySqlUpdateSetSource } from './update'; export interface MySqlInsertConfig { table: TTable; @@ -50,8 +49,7 @@ export class MySqlInsertBuilder { export interface MySqlInsert extends QueryPromise, SQLWrapper {} -export class MySqlInsert - extends QueryPromise +export class MySqlInsert extends QueryPromise implements SQLWrapper { declare protected $table: TTable; diff --git a/drizzle-orm/src/mysql-common/query-builders/select.ts b/drizzle-orm/src/mysql-core/query-builders/select.ts similarity index 91% rename from drizzle-orm/src/mysql-common/query-builders/select.ts rename to drizzle-orm/src/mysql-core/query-builders/select.ts index 1e0b7fc30..f5a7b8b60 100644 --- a/drizzle-orm/src/mysql-common/query-builders/select.ts +++ b/drizzle-orm/src/mysql-core/query-builders/select.ts @@ -1,13 +1,12 @@ -import { Table } from 'drizzle-orm'; -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { AnyMySqlColumn } from '~/columns/common'; -import { MySqlDialect } from '~/dialect'; -import { SelectFields } from '~/operations'; -import { MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/session'; -import { AnyMySqlTable, GetTableConfig, InferModel, MySqlTable } from '~/table'; -import { orderSelectedFields } from '~/utils'; - +import { AnyMySqlColumn } from '~/mysql-core/columns/common'; +import { MySqlDialect } from '~/mysql-core/dialect'; +import { SelectFields } from '~/mysql-core/operations'; +import { MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/mysql-core/session'; +import { AnyMySqlTable, GetTableConfig, InferModel } from '~/mysql-core/table'; +import { orderSelectedFields } from '~/mysql-core/utils'; +import { QueryPromise } from '~/query-promise'; +import { Query, SQL, SQLWrapper } from '~/sql'; +import { Table } from '~/table'; import { AnyMySqlSelect, diff --git a/drizzle-orm/src/mysql-common/query-builders/select.types.ts b/drizzle-orm/src/mysql-core/query-builders/select.types.ts similarity index 93% rename from drizzle-orm/src/mysql-common/query-builders/select.types.ts rename to drizzle-orm/src/mysql-core/query-builders/select.types.ts index 547bf4977..2c1d613bf 100644 --- a/drizzle-orm/src/mysql-common/query-builders/select.types.ts +++ b/drizzle-orm/src/mysql-core/query-builders/select.types.ts @@ -1,11 +1,17 @@ -import { GetColumnConfig } from 'drizzle-orm'; -import { Placeholder, SQL, SQLResponse } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; - -import { AnyMySqlColumn } from '~/columns'; -import { ChangeColumnTableName } from '~/columns/common'; -import { SelectFields, SelectFieldsOrdered, SelectResultField, SelectResultFields } from '~/operations'; -import { AnyMySqlTable, GetTableConfig, MySqlTableWithColumns, TableConfig, UpdateTableConfig } from '~/table'; +import { GetColumnConfig } from '~/column'; +import { Placeholder, SQL, SQLResponse } from '~/sql'; +import { Simplify } from '~/utils'; + +import { AnyMySqlColumn } from '~/mysql-core/columns'; +import { ChangeColumnTableName } from '~/mysql-core/columns/common'; +import { SelectFields, SelectFieldsOrdered, SelectResultField, SelectResultFields } from '~/mysql-core/operations'; +import { + AnyMySqlTable, + GetTableConfig, + MySqlTableWithColumns, + TableConfig, + UpdateTableConfig, +} from '~/mysql-core/table'; import { MySqlSelect } from './select'; diff --git a/drizzle-orm/src/mysql-common/query-builders/update.ts b/drizzle-orm/src/mysql-core/query-builders/update.ts similarity index 81% rename from drizzle-orm/src/mysql-common/query-builders/update.ts rename to drizzle-orm/src/mysql-core/query-builders/update.ts index fd4932de6..64f5aa472 100644 --- a/drizzle-orm/src/mysql-common/query-builders/update.ts +++ b/drizzle-orm/src/mysql-core/query-builders/update.ts @@ -1,12 +1,12 @@ -import { GetColumnData } from 'drizzle-orm'; -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Param, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; -import { MySqlDialect } from '~/dialect'; -import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/operations'; -import { MySqlQueryResult, MySqlRawQueryResult, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/session'; -import { AnyMySqlTable, GetTableConfig, InferModel, MySqlTable } from '~/table'; -import { mapUpdateSet, orderSelectedFields } from '~/utils'; +import { GetColumnData } from '~/column'; +import { MySqlDialect } from '~/mysql-core/dialect'; +import { SelectFieldsOrdered } from '~/mysql-core/operations'; +import { MySqlRawQueryResult, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/mysql-core/session'; +import { AnyMySqlTable, GetTableConfig } from '~/mysql-core/table'; +import { mapUpdateSet } from '~/mysql-core/utils'; +import { QueryPromise } from '~/query-promise'; +import { Param, Query, SQL, SQLWrapper } from '~/sql'; +import { Simplify } from '~/utils'; export interface MySqlUpdateConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/mysql-common/session.ts b/drizzle-orm/src/mysql-core/session.ts similarity index 97% rename from drizzle-orm/src/mysql-common/session.ts rename to drizzle-orm/src/mysql-core/session.ts index e863f08ee..fe07a16ae 100644 --- a/drizzle-orm/src/mysql-common/session.ts +++ b/drizzle-orm/src/mysql-core/session.ts @@ -1,5 +1,5 @@ -import { Query, SQL } from 'drizzle-orm/sql'; import { FieldPacket, OkPacket, ResultSetHeader, RowDataPacket } from 'mysql2/promise'; +import { Query, SQL } from '~/sql'; import { MySqlDialect } from './dialect'; import { SelectFieldsOrdered } from './operations'; diff --git a/drizzle-orm/src/mysql-common/table.ts b/drizzle-orm/src/mysql-core/table.ts similarity index 91% rename from drizzle-orm/src/mysql-common/table.ts rename to drizzle-orm/src/mysql-core/table.ts index 301f53795..73f0436b2 100644 --- a/drizzle-orm/src/mysql-common/table.ts +++ b/drizzle-orm/src/mysql-core/table.ts @@ -1,8 +1,8 @@ -import { GetColumnData } from 'drizzle-orm'; -import { OptionalKeyOnly, RequiredKeyOnly } from 'drizzle-orm/operations'; -import { Table } from 'drizzle-orm/table'; -import { Update } from 'drizzle-orm/utils'; -import { Simplify } from 'drizzle-orm/utils'; +import { GetColumnData } from '~/column'; +import { OptionalKeyOnly, RequiredKeyOnly } from '~/operations'; +import { Table } from '~/table'; +import { Update } from '~/utils'; +import { Simplify } from '~/utils'; import { Check, CheckBuilder } from './checks'; import { AnyMySqlColumn, AnyMySqlColumnBuilder, BuildColumns } from './columns/common'; @@ -121,23 +121,23 @@ export function isMySqlSchema(obj: unknown): obj is MySqlSchema { /** * mysqlDatabase is same as {@link mysqlSchema} function - * + * * https://dev.mysql.com/doc/refman/8.0/en/create-database.html - * - * @param databaseName - mysql use database name - * @returns + * + * @param databaseName - mysql use database name + * @returns */ export function mysqlDatabase(databaseName: T) { - return mysqlSchema(databaseName) + return mysqlSchema(databaseName); } /** * mysqlSchema is same as {@link mysqlDatabase} function - * + * * https://dev.mysql.com/doc/refman/8.0/en/create-database.html - * - * @param schemaName - mysql use schema name - * @returns + * + * @param schemaName - mysql use schema name + * @returns */ export function mysqlSchema(schemaName: T) { const schemaValue: MySqlSchema = { @@ -190,7 +190,9 @@ export function mysqlTableWithSchema< table[MySqlTable.Symbol.Columns] = builtColumns; if (extraConfig) { - table[MySqlTable.Symbol.ExtraConfig] = extraConfig as (self: Record) => MySqlTableExtraConfig; + table[MySqlTable.Symbol.ExtraConfig] = extraConfig as ( + self: Record, + ) => MySqlTableExtraConfig; } return table; diff --git a/drizzle-orm/src/mysql-common/tsconfig.build.json b/drizzle-orm/src/mysql-core/tsconfig.build.json similarity index 100% rename from drizzle-orm/src/mysql-common/tsconfig.build.json rename to drizzle-orm/src/mysql-core/tsconfig.build.json diff --git a/drizzle-orm/src/mysql-common/utils.ts b/drizzle-orm/src/mysql-core/utils.ts similarity index 95% rename from drizzle-orm/src/mysql-common/utils.ts rename to drizzle-orm/src/mysql-core/utils.ts index aa78ea829..88b1f65c3 100644 --- a/drizzle-orm/src/mysql-common/utils.ts +++ b/drizzle-orm/src/mysql-core/utils.ts @@ -1,12 +1,12 @@ -import { AnyMySqlTable, MySqlTable } from './table'; -import { SelectFields, SelectFieldsOrdered } from '~/operations'; -import { Param, SQL, SQLResponse } from 'drizzle-orm/sql'; -import { MySqlUpdateSet } from './query-builders/update'; -import { MySqlColumn } from './columns/common'; -import { Table } from 'drizzle-orm/table'; -import { Index, IndexBuilder } from './indexes'; +import { SelectFields, SelectFieldsOrdered } from '~/mysql-core/operations'; +import { Param, SQL, SQLResponse } from '~/sql'; +import { Table } from '~/table'; import { Check, CheckBuilder } from './checks'; +import { MySqlColumn } from './columns/common'; import { ForeignKey, ForeignKeyBuilder } from './foreign-keys'; +import { Index, IndexBuilder } from './indexes'; +import { MySqlUpdateSet } from './query-builders/update'; +import { AnyMySqlTable, MySqlTable } from './table'; /** @internal */ export const tableIndexes = Symbol('tableIndexes'); @@ -34,7 +34,7 @@ export function getTableConfig(table: TTable) { foreignKeys, checks, name, - schema + schema, }; } @@ -55,7 +55,7 @@ export function getTableConfig(table: TTable) { foreignKeys, checks, name, - schema + schema, }; } diff --git a/drizzle-orm/src/mysql2/driver.ts b/drizzle-orm/src/mysql2/driver.ts index a295a3c9c..8233bd85f 100644 --- a/drizzle-orm/src/mysql2/driver.ts +++ b/drizzle-orm/src/mysql2/driver.ts @@ -1,5 +1,5 @@ -import { Logger } from 'drizzle-orm'; -import { MySqlDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { MySqlDialect } from '~/mysql-core/dialect'; import { MySqlDatabase } from '.'; import { MySql2Client, MySql2Session } from './session'; @@ -24,7 +24,7 @@ export interface DrizzleConfig { logger?: Logger; } -export { MySqlDatabase } from '~/db'; +export { MySqlDatabase } from '~/mysql-core/db'; export function drizzle(client: MySql2Client, config: DrizzleConfig = {}): MySqlDatabase { const dialect = new MySqlDialect(); diff --git a/drizzle-orm/src/mysql2/migrator.ts b/drizzle-orm/src/mysql2/migrator.ts index 146df8a15..36d848214 100644 --- a/drizzle-orm/src/mysql2/migrator.ts +++ b/drizzle-orm/src/mysql2/migrator.ts @@ -1,5 +1,5 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; -import { MySqlDatabase } from '~/db'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; +import { MySqlDatabase } from '~/mysql-core/db'; export async function migrate(db: MySqlDatabase, config: string | MigrationConfig) { const migrations = readMigrationFiles(config); diff --git a/drizzle-orm/src/mysql2/session.ts b/drizzle-orm/src/mysql2/session.ts index a819391ae..e914ee8eb 100644 --- a/drizzle-orm/src/mysql2/session.ts +++ b/drizzle-orm/src/mysql2/session.ts @@ -1,10 +1,16 @@ -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; import { Connection, Pool, QueryOptions } from 'mysql2/promise'; -import { MySqlDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; -import { MySqlQueryResult, MySqlQueryResultType, MySqlSession, PreparedQuery, PreparedQueryConfig } from '~/session'; +import { Logger, NoopLogger } from '~/logger'; +import { MySqlDialect } from '~/mysql-core/dialect'; +import { SelectFieldsOrdered } from '~/mysql-core/operations'; +import { + MySqlQueryResult, + MySqlQueryResultType, + MySqlSession, + PreparedQuery, + PreparedQueryConfig, +} from '~/mysql-core/session'; +import { fillPlaceholders, Query } from '~/sql'; +import { mapResultRow } from '~/utils'; export type MySql2Client = Pool | Connection; diff --git a/drizzle-orm/src/neondb/driver.ts b/drizzle-orm/src/neon/driver.ts similarity index 89% rename from drizzle-orm/src/neondb/driver.ts rename to drizzle-orm/src/neon/driver.ts index 2f32ee442..832b7d2eb 100644 --- a/drizzle-orm/src/neondb/driver.ts +++ b/drizzle-orm/src/neon/driver.ts @@ -1,7 +1,7 @@ import { types } from '@neondatabase/serverless'; -import { Logger } from 'drizzle-orm'; -import { PgDatabase } from '~/db'; -import { PgDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { PgDatabase } from '~/pg-core/db'; +import { PgDialect } from '~/pg-core/dialect'; import { NeonClient, NeonQueryResultHKT, NeonSession } from './session'; export interface NeonDriverOptions { diff --git a/drizzle-orm/src/neondb/index.ts b/drizzle-orm/src/neon/index.ts similarity index 100% rename from drizzle-orm/src/neondb/index.ts rename to drizzle-orm/src/neon/index.ts diff --git a/drizzle-orm/src/neondb/migrator.ts b/drizzle-orm/src/neon/migrator.ts similarity index 78% rename from drizzle-orm/src/neondb/migrator.ts rename to drizzle-orm/src/neon/migrator.ts index 859c77182..ac7631cb6 100644 --- a/drizzle-orm/src/neondb/migrator.ts +++ b/drizzle-orm/src/neon/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { NeonDatabase } from './driver'; import { NeonQueryResultHKT } from './session'; diff --git a/drizzle-orm/src/neondb/session.ts b/drizzle-orm/src/neon/session.ts similarity index 91% rename from drizzle-orm/src/neondb/session.ts rename to drizzle-orm/src/neon/session.ts index f42bb3721..6b05dd6f7 100644 --- a/drizzle-orm/src/neondb/session.ts +++ b/drizzle-orm/src/neon/session.ts @@ -7,13 +7,13 @@ import { QueryResult, QueryResultRow, } from '@neondatabase/serverless'; -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; -import { PgDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT } from '~/session'; +import { Logger, NoopLogger } from '~/logger'; +import { PgDialect } from '~/pg-core/dialect'; +import { SelectFieldsOrdered } from '~/pg-core/operations'; +import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT } from '~/pg-core/session'; +import { fillPlaceholders, Query } from '~/sql'; import { Assume } from '~/utils'; +import { mapResultRow } from '~/utils'; export type NeonClient = Pool | PoolClient | Client; diff --git a/drizzle-orm/src/pg-common/node/driver.ts b/drizzle-orm/src/node-postgres/driver.ts similarity index 89% rename from drizzle-orm/src/pg-common/node/driver.ts rename to drizzle-orm/src/node-postgres/driver.ts index f05ea9baa..25cbd48aa 100644 --- a/drizzle-orm/src/pg-common/node/driver.ts +++ b/drizzle-orm/src/node-postgres/driver.ts @@ -1,7 +1,7 @@ -import { Logger } from 'drizzle-orm'; import { types } from 'pg'; -import { PgDatabase } from '~/db'; -import { PgDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { PgDatabase } from '~/pg-core/db'; +import { PgDialect } from '~/pg-core/dialect'; import { NodePgClient, NodePgQueryResultHKT, NodePgSession } from './session'; export interface PgDriverOptions { diff --git a/drizzle-orm/src/pg-common/node/index.ts b/drizzle-orm/src/node-postgres/index.ts similarity index 100% rename from drizzle-orm/src/pg-common/node/index.ts rename to drizzle-orm/src/node-postgres/index.ts diff --git a/drizzle-orm/src/pg-common/node/migrator.ts b/drizzle-orm/src/node-postgres/migrator.ts similarity index 75% rename from drizzle-orm/src/pg-common/node/migrator.ts rename to drizzle-orm/src/node-postgres/migrator.ts index e5badee86..6518f1942 100644 --- a/drizzle-orm/src/pg-common/node/migrator.ts +++ b/drizzle-orm/src/node-postgres/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { NodePgDatabase } from './driver'; export async function migrate(db: NodePgDatabase, config: string | MigrationConfig) { diff --git a/drizzle-orm/src/pg-common/node/session.ts b/drizzle-orm/src/node-postgres/session.ts similarity index 93% rename from drizzle-orm/src/pg-common/node/session.ts rename to drizzle-orm/src/node-postgres/session.ts index 88cf6a087..67cce4008 100644 --- a/drizzle-orm/src/pg-common/node/session.ts +++ b/drizzle-orm/src/node-postgres/session.ts @@ -1,10 +1,10 @@ -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; import { Client, Pool, PoolClient, QueryArrayConfig, QueryConfig, QueryResult, QueryResultRow } from 'pg'; -import { PgDialect } from '~/dialect'; +import { Logger, NoopLogger } from '~/logger'; import { SelectFieldsOrdered } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT } from '~/session'; +import { PgDialect } from '~/pg-core/dialect'; +import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT } from '~/pg-core/session'; +import { fillPlaceholders, Query } from '~/sql'; +import { mapResultRow } from '~/utils'; import { Assume } from '~/utils'; export type NodePgClient = Pool | PoolClient | Client; diff --git a/drizzle-orm/src/pg-common/README.md b/drizzle-orm/src/pg-core/README.md similarity index 89% rename from drizzle-orm/src/pg-common/README.md rename to drizzle-orm/src/pg-core/README.md index 6ee9eb9ff..e6e9fc086 100644 --- a/drizzle-orm/src/pg-common/README.md +++ b/drizzle-orm/src/pg-core/README.md @@ -1,9 +1,9 @@
-

Drizzle ORM | PostgreSQL npm

-npm -npm bundle size +

Drizzle ORM | PostgreSQL npm

+npm +npm bundle size Discord -License +License
If you know SQL, you know Drizzle ORM

@@ -12,25 +12,25 @@ Drizzle ORM is a TypeScript ORM for SQL databases designed with maximum type saf | Driver | Support | | Driver version | | :- | :-: | :-: | :-: | -| [node-postgres](https://github.com/brianc/node-postgres) | ✅ | | driver version | -| [postgres.js](https://github.com/porsager/postgres) | ✅ | [Docs](/drizzle-orm-pg/src/postgres.js/README.md) | driver version | -| [NeonDB Serverless](https://github.com/neondatabase/serverless) | ✅ | | driver version | +| [node-postgres](https://github.com/brianc/node-postgres) | ✅ | | driver version | +| [postgres.js](https://github.com/porsager/postgres) | ✅ | [Docs](/drizzle-orm/src/postgres.js/README.md) | driver version | +| [NeonDB Serverless](https://github.com/neondatabase/serverless) | ✅ | | driver version | ## Installation ```bash # npm -npm i drizzle-orm drizzle-orm-pg pg +npm i drizzle-orm pg npm i -D @types/pg npm i -D drizzle-kit # yarn -yarn add drizzle-orm drizzle-orm-pg pg +yarn add drizzle-orm pg yarn add -D @types/pg yarn add -D drizzle-kit # pnpm -pnpm add drizzle-orm drizzle-orm-pg pg +pnpm add drizzle-orm pg pnpm add -D @types/pg pnpm add -D drizzle-kit ``` @@ -79,8 +79,8 @@ export const users = pgTable('users', { ```typescript // db.ts -import { pgTable, serial, text, varchar } from 'drizzle-orm-pg'; -import { drizzle } from 'drizzle-orm-pg/node'; +import { pgTable, serial, text, varchar } from 'drizzle-orm/pg-core'; +import { drizzle } from 'drizzle-orm/node-pg'; import { Pool } from 'pg'; import { users } from './schema'; @@ -106,8 +106,8 @@ const allUsers = await db.select(users); ```typescript // db.ts -import { pgTable, serial, text, varchar } from 'drizzle-orm-pg'; -import { drizzle } from 'drizzle-orm-pg/node'; +import { pgTable, serial, text, varchar } from 'drizzle-orm/pg-core'; +import { drizzle } from 'drizzle-orm/node-pg'; import { Client } from 'pg'; import { users } from './schema'; @@ -136,7 +136,7 @@ const allUsers = await db.select(users); This is how you declare SQL schema in `schema.ts`. You can declare tables, indexes and constraints, foreign keys and enums. Please pay attention to `export` keyword, they are mandatory if you'll be using [drizzle-kit SQL migrations generator](#migrations). ```typescript -import { pgEnum, pgTable, serial, uniqueIndex, varchar } from 'drizzle-orm-pg'; +import { pgEnum, pgTable, serial, uniqueIndex, varchar } from 'drizzle-orm/pg-core'; // declaring enum in database export const popularityEnum = pgEnum('popularity', ['unknown', 'known', 'popular']); @@ -161,8 +161,8 @@ export const cities = pgTable('cities', { ### Database and table entity types ```typescript -import { pgTable, InferModel, serial, text, varchar } from 'drizzle-orm-pg'; -import { drizzle, NodePgDatabase } from 'drizzle-orm-pg/node'; +import { pgTable, InferModel, serial, text, varchar } from 'drizzle-orm/pg-core'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; const users = pgTable('users', { id: serial('id').primaryKey(), @@ -189,7 +189,7 @@ export async function insertUser(user: NewUser): Promise { ### Declaring indexes and foreign keys ```typescript -import { foreignKey, index, uniqueIndex, integer, pgTable, serial, varchar } from 'drizzle-orm-pg'; +import { foreignKey, index, uniqueIndex, integer, pgTable, serial, varchar } from 'drizzle-orm/pg-core'; export const countries = pgTable('countries', { id: serial('id').primaryKey(), @@ -296,7 +296,7 @@ But if you will specify any custom schema you want, then drizzle will generate - > **Warning** > If you will have tables with same names in different schemas then drizzle will respond with `never[]` error in result types and error from database > -> In this case you may use [alias syntax](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-pg#join-aliases-and-self-joins) +> In this case you may use [alias syntax](/drizzle-orm/src/pg-core/README.md#join-aliases-and-self-joins) ### Usage example @@ -331,8 +331,8 @@ Querying, sorting and filtering. We also support partial select. ```typescript ... -import { pgTable, serial, text, varchar } from 'drizzle-orm-pg'; -import { drizzle } from 'drizzle-orm-pg/node'; +import { pgTable, serial, text, varchar } from 'drizzle-orm/pg-core'; +import { drizzle } from 'drizzle-orm/node-pg';; import { and, asc, desc, eq, or } from 'drizzle-orm/expressions'; const users = pgTable('users', { @@ -413,8 +413,8 @@ or(expressions: SQL[]) ### Insert ```typescript -import { pgTable, serial, text, timestamp, InferModel } from 'drizzle-orm-pg'; -import { drizzle } from 'drizzle-orm-pg/node'; +import { pgTable, serial, text, timestamp, InferModel } from 'drizzle-orm/pg-core'; +import { drizzle } from 'drizzle-orm/node-pg';; const users = pgTable('users', { id: serial('id').primaryKey(), @@ -568,7 +568,7 @@ const result = await db.select(usersToChatGroups) #### Join aliases and self-joins ```typescript -import { ..., alias } from 'drizzle-orm-pg'; +import { ..., alias } from 'drizzle-orm/pg-core'; export const files = pgTable('folders', { name: text('name').notNull(), @@ -617,7 +617,7 @@ const result = await query.execute(); ### Prepared statements with parameters ```typescript -import { placeholder } from 'drizzle-orm-pg'; +import { placeholder } from 'drizzle-orm/pg-core'; const query = db.select(users) .where(eq(users.name, placeholder('name'))) @@ -648,7 +648,7 @@ Check out the [docs for DrizzleKit](https://github.com/drizzle-team/drizzle-kit- For schema file: ```typescript -import { index, integer, pgTable, serial, varchar } from 'drizzle-orm-pg'; +import { index, integer, pgTable, serial, varchar } from 'drizzle-orm/pg-core'; export const users = pgTable('users', { id: serial('id').primaryKey(), @@ -690,8 +690,8 @@ CREATE INDEX IF NOT EXISTS users_full_name_index ON users (full_name); And you can run migrations manually or using our embedded migrations module ```typescript -import { drizzle } from 'drizzle-orm-pg/node'; -import { migrate } from 'drizzle-orm-pg/node/migrator'; +import { drizzle } from 'drizzle-orm/node-pg';; +import { migrate } from 'drizzle-orm/node-pg/migrator'; import { Pool } from 'pg'; const pool = new Pool({ diff --git a/drizzle-orm/src/pg-common/alias.ts b/drizzle-orm/src/pg-core/alias.ts similarity index 84% rename from drizzle-orm/src/pg-common/alias.ts rename to drizzle-orm/src/pg-core/alias.ts index ebaa749b3..3554d0946 100644 --- a/drizzle-orm/src/pg-common/alias.ts +++ b/drizzle-orm/src/pg-core/alias.ts @@ -1,4 +1,4 @@ -import { TableAliasProxyHandler } from 'drizzle-orm/alias'; +import { TableAliasProxyHandler } from '~/alias'; import { BuildAliasTable } from './query-builders/select.types'; import { AnyPgTable } from './table'; diff --git a/drizzle-orm/src/pg-common/checks.ts b/drizzle-orm/src/pg-core/checks.ts similarity index 93% rename from drizzle-orm/src/pg-common/checks.ts rename to drizzle-orm/src/pg-core/checks.ts index 6107d4d8f..c3ca4c3a8 100644 --- a/drizzle-orm/src/pg-common/checks.ts +++ b/drizzle-orm/src/pg-core/checks.ts @@ -1,4 +1,4 @@ -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { AnyPgTable } from './table'; export class CheckBuilder { diff --git a/drizzle-orm/src/pg-common/columns/bigint.ts b/drizzle-orm/src/pg-core/columns/bigint.ts similarity index 93% rename from drizzle-orm/src/pg-common/columns/bigint.ts rename to drizzle-orm/src/pg-core/columns/bigint.ts index dff561277..b051ce04b 100644 --- a/drizzle-orm/src/pg-common/columns/bigint.ts +++ b/drizzle-orm/src/pg-core/columns/bigint.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; diff --git a/drizzle-orm/src/pg-common/columns/bigserial.ts b/drizzle-orm/src/pg-core/columns/bigserial.ts similarity index 100% rename from drizzle-orm/src/pg-common/columns/bigserial.ts rename to drizzle-orm/src/pg-core/columns/bigserial.ts diff --git a/drizzle-orm/src/pg-common/columns/boolean.ts b/drizzle-orm/src/pg-core/columns/boolean.ts similarity index 83% rename from drizzle-orm/src/pg-common/columns/boolean.ts rename to drizzle-orm/src/pg-core/columns/boolean.ts index f7385b782..9fd4b436f 100644 --- a/drizzle-orm/src/pg-common/columns/boolean.ts +++ b/drizzle-orm/src/pg-core/columns/boolean.ts @@ -1,7 +1,7 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; -import { AnyPgTable } from '~/table'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgBooleanBuilder extends PgColumnBuilder< diff --git a/drizzle-orm/src/pg-common/columns/common.ts b/drizzle-orm/src/pg-core/columns/common.ts similarity index 90% rename from drizzle-orm/src/pg-common/columns/common.ts rename to drizzle-orm/src/pg-core/columns/common.ts index d7124ff1e..7ea1c284d 100644 --- a/drizzle-orm/src/pg-common/columns/common.ts +++ b/drizzle-orm/src/pg-core/columns/common.ts @@ -1,16 +1,11 @@ -import { Column, ColumnBaseConfig } from 'drizzle-orm'; -import { - ColumnBuilder, - ColumnBuilderBaseConfig, - ColumnBuilderWithConfig, - UpdateCBConfig, -} from 'drizzle-orm/column-builder'; -import { SQL } from 'drizzle-orm/sql'; -import { Update } from 'drizzle-orm/utils'; -import { Simplify } from 'drizzle-orm/utils'; - -import { ForeignKey, ForeignKeyBuilder, UpdateDeleteAction } from '~/foreign-keys'; -import { AnyPgTable } from '~/table'; +import { Column, ColumnBaseConfig } from '~/column'; +import { ColumnBuilder, ColumnBuilderBaseConfig, ColumnBuilderWithConfig, UpdateCBConfig } from '~/column-builder'; +import { SQL } from '~/sql'; +import { Update } from '~/utils'; +import { Simplify } from '~/utils'; + +import { ForeignKey, ForeignKeyBuilder, UpdateDeleteAction } from '~/pg-core/foreign-keys'; +import { AnyPgTable } from '~/pg-core/table'; import { PgEnumColumn, PgEnumColumnBuilder } from './enum'; import { PgText, PgTextBuilder } from './text'; diff --git a/drizzle-orm/src/pg-common/columns/custom.ts b/drizzle-orm/src/pg-core/columns/custom.ts similarity index 97% rename from drizzle-orm/src/pg-common/columns/custom.ts rename to drizzle-orm/src/pg-core/columns/custom.ts index a9808c70e..0335f2d97 100644 --- a/drizzle-orm/src/pg-common/columns/custom.ts +++ b/drizzle-orm/src/pg-core/columns/custom.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export type CustomColumnBuildeConfig = { @@ -105,7 +105,7 @@ export type CustomTypeValues = { /** * If your custom data type has default you can use `default: true` - * + * * @example * const customSerial = customType<{ data: number, notNull: true, default: true }>({ * dataType() { diff --git a/drizzle-orm/src/pg-common/columns/date.common.ts b/drizzle-orm/src/pg-core/columns/date.common.ts similarity index 82% rename from drizzle-orm/src/pg-common/columns/date.common.ts rename to drizzle-orm/src/pg-core/columns/date.common.ts index 8f9e5ede8..438d5e076 100644 --- a/drizzle-orm/src/pg-common/columns/date.common.ts +++ b/drizzle-orm/src/pg-core/columns/date.common.ts @@ -1,6 +1,5 @@ -import { sql } from 'drizzle-orm'; -import { ColumnBuilderBaseConfig, UpdateCBConfig } from 'drizzle-orm/column-builder'; -import { SQL } from 'drizzle-orm/sql'; +import { ColumnBuilderBaseConfig, UpdateCBConfig } from '~/column-builder'; +import { SQL, sql } from '~/sql'; import { PgColumnBuilder } from './common'; diff --git a/drizzle-orm/src/pg-common/columns/date.ts b/drizzle-orm/src/pg-core/columns/date.ts similarity index 93% rename from drizzle-orm/src/pg-common/columns/date.ts rename to drizzle-orm/src/pg-core/columns/date.ts index 335719221..c10771191 100644 --- a/drizzle-orm/src/pg-common/columns/date.ts +++ b/drizzle-orm/src/pg-core/columns/date.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn } from './common'; import { PgDateColumnBaseBuilder } from './date.common'; diff --git a/drizzle-orm/src/pg-common/columns/double-precision.ts b/drizzle-orm/src/pg-core/columns/double-precision.ts similarity index 89% rename from drizzle-orm/src/pg-common/columns/double-precision.ts rename to drizzle-orm/src/pg-core/columns/double-precision.ts index 68e418e96..35c1c043d 100644 --- a/drizzle-orm/src/pg-common/columns/double-precision.ts +++ b/drizzle-orm/src/pg-core/columns/double-precision.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgDoublePrecisionBuilder extends PgColumnBuilder< diff --git a/drizzle-orm/src/pg-common/columns/enum.ts b/drizzle-orm/src/pg-core/columns/enum.ts similarity index 94% rename from drizzle-orm/src/pg-common/columns/enum.ts rename to drizzle-orm/src/pg-core/columns/enum.ts index 87424fe69..f1c4f6ceb 100644 --- a/drizzle-orm/src/pg-common/columns/enum.ts +++ b/drizzle-orm/src/pg-core/columns/enum.ts @@ -1,7 +1,7 @@ -import { UpdateCBConfig } from 'drizzle-orm/column-builder'; -import { SQL } from 'drizzle-orm/sql'; -import { Update } from 'drizzle-orm/utils'; -import { AnyPgTable } from '~/table'; +import { UpdateCBConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; +import { SQL } from '~/sql'; +import { Update } from '~/utils'; import { PgColumn, PgColumnBuilder } from './common'; const isPgEnumSym = Symbol('isPgEnum'); diff --git a/drizzle-orm/src/pg-common/columns/index.ts b/drizzle-orm/src/pg-core/columns/index.ts similarity index 100% rename from drizzle-orm/src/pg-common/columns/index.ts rename to drizzle-orm/src/pg-core/columns/index.ts diff --git a/drizzle-orm/src/pg-common/columns/integer.ts b/drizzle-orm/src/pg-core/columns/integer.ts similarity index 89% rename from drizzle-orm/src/pg-common/columns/integer.ts rename to drizzle-orm/src/pg-core/columns/integer.ts index 8e3574315..1c34a7381 100644 --- a/drizzle-orm/src/pg-common/columns/integer.ts +++ b/drizzle-orm/src/pg-core/columns/integer.ts @@ -1,5 +1,5 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; import { AnyPgTable } from '../table'; import { PgColumn, PgColumnBuilder } from './common'; diff --git a/drizzle-orm/src/pg-common/columns/interval.ts b/drizzle-orm/src/pg-core/columns/interval.ts similarity index 92% rename from drizzle-orm/src/pg-common/columns/interval.ts rename to drizzle-orm/src/pg-core/columns/interval.ts index f3373d49a..24befec92 100644 --- a/drizzle-orm/src/pg-common/columns/interval.ts +++ b/drizzle-orm/src/pg-core/columns/interval.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; import { Precision } from './timestamp'; diff --git a/drizzle-orm/src/pg-common/columns/json.ts b/drizzle-orm/src/pg-core/columns/json.ts similarity index 89% rename from drizzle-orm/src/pg-common/columns/json.ts rename to drizzle-orm/src/pg-core/columns/json.ts index f8f4dd293..05f66712c 100644 --- a/drizzle-orm/src/pg-common/columns/json.ts +++ b/drizzle-orm/src/pg-core/columns/json.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgJsonBuilder diff --git a/drizzle-orm/src/pg-common/columns/jsonb.ts b/drizzle-orm/src/pg-core/columns/jsonb.ts similarity index 89% rename from drizzle-orm/src/pg-common/columns/jsonb.ts rename to drizzle-orm/src/pg-core/columns/jsonb.ts index e946a918e..b718a7dc0 100644 --- a/drizzle-orm/src/pg-common/columns/jsonb.ts +++ b/drizzle-orm/src/pg-core/columns/jsonb.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgJsonbBuilder diff --git a/drizzle-orm/src/pg-common/columns/numeric.ts b/drizzle-orm/src/pg-core/columns/numeric.ts similarity index 91% rename from drizzle-orm/src/pg-common/columns/numeric.ts rename to drizzle-orm/src/pg-core/columns/numeric.ts index 95922b1b1..7e6e9c03d 100644 --- a/drizzle-orm/src/pg-common/columns/numeric.ts +++ b/drizzle-orm/src/pg-core/columns/numeric.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgNumericBuilder extends PgColumnBuilder< diff --git a/drizzle-orm/src/pg-common/columns/real.ts b/drizzle-orm/src/pg-core/columns/real.ts similarity index 88% rename from drizzle-orm/src/pg-common/columns/real.ts rename to drizzle-orm/src/pg-core/columns/real.ts index 691aece69..8a4e9902b 100644 --- a/drizzle-orm/src/pg-common/columns/real.ts +++ b/drizzle-orm/src/pg-core/columns/real.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgRealBuilder extends PgColumnBuilder< diff --git a/drizzle-orm/src/pg-common/columns/serial.ts b/drizzle-orm/src/pg-core/columns/serial.ts similarity index 94% rename from drizzle-orm/src/pg-common/columns/serial.ts rename to drizzle-orm/src/pg-core/columns/serial.ts index c9de11921..287bb69e4 100644 --- a/drizzle-orm/src/pg-common/columns/serial.ts +++ b/drizzle-orm/src/pg-core/columns/serial.ts @@ -1,4 +1,4 @@ -import { AnyPgTable } from '~/table'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; diff --git a/drizzle-orm/src/pg-common/columns/smallint.ts b/drizzle-orm/src/pg-core/columns/smallint.ts similarity index 86% rename from drizzle-orm/src/pg-common/columns/smallint.ts rename to drizzle-orm/src/pg-core/columns/smallint.ts index 04ab4b189..e03f9fc3f 100644 --- a/drizzle-orm/src/pg-common/columns/smallint.ts +++ b/drizzle-orm/src/pg-core/columns/smallint.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgSmallIntBuilder extends PgColumnBuilder< diff --git a/drizzle-orm/src/pg-common/columns/smallserial.ts b/drizzle-orm/src/pg-core/columns/smallserial.ts similarity index 95% rename from drizzle-orm/src/pg-common/columns/smallserial.ts rename to drizzle-orm/src/pg-core/columns/smallserial.ts index 35682b49e..94994412c 100644 --- a/drizzle-orm/src/pg-common/columns/smallserial.ts +++ b/drizzle-orm/src/pg-core/columns/smallserial.ts @@ -1,4 +1,4 @@ -import { AnyPgTable } from '~/table'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgSmallSerialBuilder extends PgColumnBuilder<{ diff --git a/drizzle-orm/src/pg-common/columns/text.ts b/drizzle-orm/src/pg-core/columns/text.ts similarity index 92% rename from drizzle-orm/src/pg-common/columns/text.ts rename to drizzle-orm/src/pg-core/columns/text.ts index 1dd7b4c6e..afb0121cf 100644 --- a/drizzle-orm/src/pg-common/columns/text.ts +++ b/drizzle-orm/src/pg-core/columns/text.ts @@ -1,7 +1,7 @@ -import { UpdateCBConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { UpdateCBConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { PgColumn, PgColumnBuilder } from './common'; export interface PgTextBuilderConfig { diff --git a/drizzle-orm/src/pg-common/columns/time.ts b/drizzle-orm/src/pg-core/columns/time.ts similarity index 79% rename from drizzle-orm/src/pg-common/columns/time.ts rename to drizzle-orm/src/pg-core/columns/time.ts index b632f4cf2..6f935b2b6 100644 --- a/drizzle-orm/src/pg-common/columns/time.ts +++ b/drizzle-orm/src/pg-core/columns/time.ts @@ -1,16 +1,14 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn } from './common'; import { PgDateColumnBaseBuilder } from './date.common'; import { Precision } from './timestamp'; -export class PgTimeBuilder - extends PgDateColumnBaseBuilder< - ColumnBuilderConfig<{ data: TData; driverParam: string }>, - { withTimezone: boolean; precision: number | undefined } - > -{ +export class PgTimeBuilder extends PgDateColumnBaseBuilder< + ColumnBuilderConfig<{ data: TData; driverParam: string }>, + { withTimezone: boolean; precision: number | undefined } +> { protected override $pgColumnBuilderBrand!: 'PgTimeBuilder'; constructor( diff --git a/drizzle-orm/src/pg-common/columns/timestamp.ts b/drizzle-orm/src/pg-core/columns/timestamp.ts similarity index 96% rename from drizzle-orm/src/pg-common/columns/timestamp.ts rename to drizzle-orm/src/pg-core/columns/timestamp.ts index 458e29c72..c2fe77f98 100644 --- a/drizzle-orm/src/pg-common/columns/timestamp.ts +++ b/drizzle-orm/src/pg-core/columns/timestamp.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn } from './common'; import { PgDateColumnBaseBuilder } from './date.common'; diff --git a/drizzle-orm/src/pg-common/columns/uuid.ts b/drizzle-orm/src/pg-core/columns/uuid.ts similarity index 85% rename from drizzle-orm/src/pg-common/columns/uuid.ts rename to drizzle-orm/src/pg-core/columns/uuid.ts index 7bfdd4289..10b7f8af1 100644 --- a/drizzle-orm/src/pg-common/columns/uuid.ts +++ b/drizzle-orm/src/pg-core/columns/uuid.ts @@ -1,7 +1,8 @@ -import { ColumnConfig, sql } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; -import { AnyPgTable } from '~/table'; +import { AnyPgTable } from '~/pg-core/table'; +import { sql } from '~/sql'; import { PgColumn, PgColumnBuilder } from './common'; diff --git a/drizzle-orm/src/pg-common/columns/varchar.ts b/drizzle-orm/src/pg-core/columns/varchar.ts similarity index 89% rename from drizzle-orm/src/pg-common/columns/varchar.ts rename to drizzle-orm/src/pg-core/columns/varchar.ts index 5ffb7be55..36ac309d6 100644 --- a/drizzle-orm/src/pg-common/columns/varchar.ts +++ b/drizzle-orm/src/pg-core/columns/varchar.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnyPgTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnyPgTable } from '~/pg-core/table'; import { PgColumn, PgColumnBuilder } from './common'; export class PgVarcharBuilder diff --git a/drizzle-orm/src/pg-common/db.ts b/drizzle-orm/src/pg-core/db.ts similarity index 78% rename from drizzle-orm/src/pg-common/db.ts rename to drizzle-orm/src/pg-core/db.ts index 5d14015a5..aba436732 100644 --- a/drizzle-orm/src/pg-common/db.ts +++ b/drizzle-orm/src/pg-core/db.ts @@ -1,9 +1,9 @@ -import { SQLWrapper } from 'drizzle-orm/sql'; -import { PgDialect } from '~/dialect'; -import { PgDelete, PgInsertBuilder, PgSelect, PgUpdateBuilder } from '~/query-builders'; -import { PgSession, QueryResultHKT, QueryResultKind } from '~/session'; -import { AnyPgTable, PgTable } from '~/table'; -import { orderSelectedFields } from '~/utils'; +import { PgDialect } from '~/pg-core/dialect'; +import { PgDelete, PgInsertBuilder, PgSelect, PgUpdateBuilder } from '~/pg-core/query-builders'; +import { PgSession, QueryResultHKT, QueryResultKind } from '~/pg-core/session'; +import { AnyPgTable, PgTable } from '~/pg-core/table'; +import { orderSelectedFields } from '~/pg-core/utils'; +import { SQLWrapper } from '~/sql'; export class PgDatabase { constructor( diff --git a/drizzle-orm/src/pg-common/dialect.ts b/drizzle-orm/src/pg-core/dialect.ts similarity index 94% rename from drizzle-orm/src/pg-common/dialect.ts rename to drizzle-orm/src/pg-core/dialect.ts index 3c4d9ec9e..4b4135e83 100644 --- a/drizzle-orm/src/pg-common/dialect.ts +++ b/drizzle-orm/src/pg-core/dialect.ts @@ -1,12 +1,13 @@ -import { AnyColumn, Column, Table } from 'drizzle-orm'; -import { MigrationMeta } from 'drizzle-orm/migrator'; -import { Name, Query, SQL, sql, SQLResponse, SQLSourceParam } from 'drizzle-orm/sql'; -import { AnyPgColumn, PgColumn } from '~/columns'; -import { PgDatabase } from '~/db'; +import { AnyColumn, Column } from '~/column'; +import { MigrationMeta } from '~/migrator'; import { SelectFieldsOrdered } from '~/operations'; -import { PgDeleteConfig, PgInsertConfig, PgUpdateConfig, PgUpdateSet } from '~/query-builders'; -import { PgSelectConfig } from '~/query-builders/select.types'; -import { AnyPgTable, PgTable } from '~/table'; +import { AnyPgColumn, PgColumn } from '~/pg-core/columns'; +import { PgDatabase } from '~/pg-core/db'; +import { PgDeleteConfig, PgInsertConfig, PgUpdateConfig, PgUpdateSet } from '~/pg-core/query-builders'; +import { PgSelectConfig } from '~/pg-core/query-builders/select.types'; +import { AnyPgTable, PgTable } from '~/pg-core/table'; +import { Name, Query, SQL, sql, SQLResponse, SQLSourceParam } from '~/sql'; +import { Table } from '~/table'; import { PgSession } from './session'; export class PgDialect { diff --git a/drizzle-orm/src/pg-common/expressions.ts b/drizzle-orm/src/pg-core/expressions.ts similarity index 73% rename from drizzle-orm/src/pg-common/expressions.ts rename to drizzle-orm/src/pg-core/expressions.ts index 5c96c6eb1..c834f7342 100644 --- a/drizzle-orm/src/pg-common/expressions.ts +++ b/drizzle-orm/src/pg-core/expressions.ts @@ -1,8 +1,7 @@ -import { sql } from 'drizzle-orm'; -import { param, SQL, SQLSourceParam } from 'drizzle-orm/sql'; -import { AnyPgColumn } from '~/columns'; +import { AnyPgColumn } from '~/pg-core/columns'; +import { param, SQL, sql, SQLSourceParam } from '~/sql'; -export * from 'drizzle-orm/expressions'; +export * from '~/expressions'; export function concat(column: AnyPgColumn, value: string): SQL { return sql`${column} || ${param(value, column)}`; diff --git a/drizzle-orm/src/pg-common/foreign-keys.ts b/drizzle-orm/src/pg-core/foreign-keys.ts similarity index 100% rename from drizzle-orm/src/pg-common/foreign-keys.ts rename to drizzle-orm/src/pg-core/foreign-keys.ts diff --git a/drizzle-orm/src/pg-common/index.ts b/drizzle-orm/src/pg-core/index.ts similarity index 100% rename from drizzle-orm/src/pg-common/index.ts rename to drizzle-orm/src/pg-core/index.ts diff --git a/drizzle-orm/src/pg-common/indexes.ts b/drizzle-orm/src/pg-core/indexes.ts similarity index 98% rename from drizzle-orm/src/pg-common/indexes.ts rename to drizzle-orm/src/pg-core/indexes.ts index f48792361..3fb08d1ab 100644 --- a/drizzle-orm/src/pg-common/indexes.ts +++ b/drizzle-orm/src/pg-core/indexes.ts @@ -1,4 +1,4 @@ -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { AnyPgColumn } from './columns'; import { AnyPgTable } from './table'; diff --git a/drizzle-orm/src/pg-common/operations.ts b/drizzle-orm/src/pg-core/operations.ts similarity index 75% rename from drizzle-orm/src/pg-common/operations.ts rename to drizzle-orm/src/pg-core/operations.ts index bf6f635a9..417fd04ce 100644 --- a/drizzle-orm/src/pg-common/operations.ts +++ b/drizzle-orm/src/pg-core/operations.ts @@ -1,10 +1,10 @@ -import { GetColumnData } from 'drizzle-orm'; -import { SelectFieldsOrdered as SelectFieldsOrderedBase } from 'drizzle-orm/operations'; -import { SQL, SQLResponse } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; +import { GetColumnData } from '~/column'; +import { SelectFieldsOrdered as SelectFieldsOrderedBase } from '~/operations'; +import { SQL, SQLResponse } from '~/sql'; +import { Simplify } from '~/utils'; -import { AnyPgColumn } from '~/columns/common'; -import { AnyPgTable, GetTableConfig } from '~/table'; +import { AnyPgColumn } from '~/pg-core/columns/common'; +import { AnyPgTable, GetTableConfig } from '~/pg-core/table'; export type SelectFields = { [Key: string]: SQL | SQLResponse | AnyPgColumn | SelectFields | AnyPgTable; diff --git a/drizzle-orm/src/pg-common/query-builders/delete.ts b/drizzle-orm/src/pg-core/query-builders/delete.ts similarity index 87% rename from drizzle-orm/src/pg-common/query-builders/delete.ts rename to drizzle-orm/src/pg-core/query-builders/delete.ts index aa95ee92c..93985aa7e 100644 --- a/drizzle-orm/src/pg-common/query-builders/delete.ts +++ b/drizzle-orm/src/pg-core/query-builders/delete.ts @@ -1,11 +1,11 @@ -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; +import { QueryPromise } from '~/query-promise'; +import { Query, SQL, SQLWrapper } from '~/sql'; -import { PgDialect } from '~/dialect'; -import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT, QueryResultKind } from '~/session'; -import { AnyPgTable, InferModel, PgTable } from '~/table'; -import { orderSelectedFields } from '~/utils'; +import { PgDialect } from '~/pg-core/dialect'; +import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/pg-core/operations'; +import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT, QueryResultKind } from '~/pg-core/session'; +import { AnyPgTable, InferModel, PgTable } from '~/pg-core/table'; +import { orderSelectedFields } from '~/pg-core/utils'; export interface PgDeleteConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/pg-common/query-builders/index.ts b/drizzle-orm/src/pg-core/query-builders/index.ts similarity index 100% rename from drizzle-orm/src/pg-common/query-builders/index.ts rename to drizzle-orm/src/pg-core/query-builders/index.ts diff --git a/drizzle-orm/src/pg-common/query-builders/insert.ts b/drizzle-orm/src/pg-core/query-builders/insert.ts similarity index 92% rename from drizzle-orm/src/pg-common/query-builders/insert.ts rename to drizzle-orm/src/pg-core/query-builders/insert.ts index eaa16dccd..b3cf594da 100644 --- a/drizzle-orm/src/pg-common/query-builders/insert.ts +++ b/drizzle-orm/src/pg-core/query-builders/insert.ts @@ -1,13 +1,13 @@ -import { Table } from 'drizzle-orm'; -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Param, Placeholder, Query, SQL, sql, SQLWrapper } from 'drizzle-orm/sql'; - -import { PgDialect } from '~/dialect'; -import { IndexColumn } from '~/indexes'; -import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT, QueryResultKind } from '~/session'; -import { AnyPgTable, InferModel, PgTable } from '~/table'; -import { mapUpdateSet, orderSelectedFields } from '~/utils'; +import { QueryPromise } from '~/query-promise'; +import { Param, Placeholder, Query, SQL, sql, SQLWrapper } from '~/sql'; +import { Table } from '~/table'; + +import { PgDialect } from '~/pg-core/dialect'; +import { IndexColumn } from '~/pg-core/indexes'; +import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/pg-core/operations'; +import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT, QueryResultKind } from '~/pg-core/session'; +import { AnyPgTable, InferModel, PgTable } from '~/pg-core/table'; +import { mapUpdateSet, orderSelectedFields } from '~/pg-core/utils'; import { PgUpdateSetSource } from './update'; export interface PgInsertConfig { diff --git a/drizzle-orm/src/pg-common/query-builders/select.ts b/drizzle-orm/src/pg-core/query-builders/select.ts similarity index 91% rename from drizzle-orm/src/pg-common/query-builders/select.ts rename to drizzle-orm/src/pg-core/query-builders/select.ts index 03653f332..9cbae76fa 100644 --- a/drizzle-orm/src/pg-common/query-builders/select.ts +++ b/drizzle-orm/src/pg-core/query-builders/select.ts @@ -1,13 +1,13 @@ -import { Table } from 'drizzle-orm'; -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; - -import { AnyPgColumn } from '~/columns'; -import { PgDialect } from '~/dialect'; -import { SelectFields } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig } from '~/session'; -import { AnyPgTable, GetTableConfig, InferModel } from '~/table'; -import { orderSelectedFields } from '~/utils'; +import { QueryPromise } from '~/query-promise'; +import { Query, SQL, SQLWrapper } from '~/sql'; +import { Table } from '~/table'; + +import { AnyPgColumn } from '~/pg-core/columns'; +import { PgDialect } from '~/pg-core/dialect'; +import { SelectFields } from '~/pg-core/operations'; +import { PgSession, PreparedQuery, PreparedQueryConfig } from '~/pg-core/session'; +import { AnyPgTable, GetTableConfig, InferModel } from '~/pg-core/table'; +import { orderSelectedFields } from '~/pg-core/utils'; import { AnyPgSelect, diff --git a/drizzle-orm/src/pg-common/query-builders/select.types.ts b/drizzle-orm/src/pg-core/query-builders/select.types.ts similarity index 94% rename from drizzle-orm/src/pg-common/query-builders/select.types.ts rename to drizzle-orm/src/pg-core/query-builders/select.types.ts index b2c2964c6..b4fb9ca59 100644 --- a/drizzle-orm/src/pg-common/query-builders/select.types.ts +++ b/drizzle-orm/src/pg-core/query-builders/select.types.ts @@ -1,11 +1,11 @@ -import { GetColumnConfig } from 'drizzle-orm'; -import { Placeholder, SQL, SQLResponse } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; - -import { AnyPgColumn } from '~/columns'; -import { ChangeColumnTableName } from '~/columns/common'; -import { SelectFields, SelectFieldsOrdered, SelectResultField, SelectResultFields } from '~/operations'; -import { AnyPgTable, GetTableConfig, PgTableWithColumns, TableConfig, UpdateTableConfig } from '~/table'; +import { GetColumnConfig } from '~/column'; +import { Placeholder, SQL, SQLResponse } from '~/sql'; +import { Simplify } from '~/utils'; + +import { AnyPgColumn } from '~/pg-core/columns'; +import { ChangeColumnTableName } from '~/pg-core/columns/common'; +import { SelectFields, SelectFieldsOrdered, SelectResultField, SelectResultFields } from '~/pg-core/operations'; +import { AnyPgTable, GetTableConfig, PgTableWithColumns, TableConfig, UpdateTableConfig } from '~/pg-core/table'; import { PgSelect } from './select'; diff --git a/drizzle-orm/src/pg-common/query-builders/update.ts b/drizzle-orm/src/pg-core/query-builders/update.ts similarity index 89% rename from drizzle-orm/src/pg-common/query-builders/update.ts rename to drizzle-orm/src/pg-core/query-builders/update.ts index 51d05482e..704eca677 100644 --- a/drizzle-orm/src/pg-common/query-builders/update.ts +++ b/drizzle-orm/src/pg-core/query-builders/update.ts @@ -1,13 +1,13 @@ -import { GetColumnData } from 'drizzle-orm'; -import { QueryPromise } from 'drizzle-orm/query-promise'; -import { Param, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; -import { PgDialect } from '~/dialect'; - -import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT, QueryResultKind } from '~/session'; -import { AnyPgTable, GetTableConfig, InferModel, PgTable } from '~/table'; -import { mapUpdateSet, orderSelectedFields } from '~/utils'; +import { GetColumnData } from '~/column'; +import { PgDialect } from '~/pg-core/dialect'; +import { QueryPromise } from '~/query-promise'; +import { Param, Query, SQL, SQLWrapper } from '~/sql'; +import { Simplify } from '~/utils'; + +import { SelectFields, SelectFieldsOrdered, SelectResultFields } from '~/pg-core/operations'; +import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT, QueryResultKind } from '~/pg-core/session'; +import { AnyPgTable, GetTableConfig, InferModel, PgTable } from '~/pg-core/table'; +import { mapUpdateSet, orderSelectedFields } from '~/pg-core/utils'; export interface PgUpdateConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/pg-common/session.ts b/drizzle-orm/src/pg-core/session.ts similarity index 97% rename from drizzle-orm/src/pg-common/session.ts rename to drizzle-orm/src/pg-core/session.ts index c9af41625..ee270b606 100644 --- a/drizzle-orm/src/pg-common/session.ts +++ b/drizzle-orm/src/pg-core/session.ts @@ -1,4 +1,4 @@ -import { Query, SQL } from 'drizzle-orm/sql'; +import { Query, SQL } from '~/sql'; import { PgDialect } from './dialect'; import { SelectFieldsOrdered } from './operations'; diff --git a/drizzle-orm/src/pg-common/table.ts b/drizzle-orm/src/pg-core/table.ts similarity index 95% rename from drizzle-orm/src/pg-common/table.ts rename to drizzle-orm/src/pg-core/table.ts index f15f6a382..8019ce0a7 100644 --- a/drizzle-orm/src/pg-common/table.ts +++ b/drizzle-orm/src/pg-core/table.ts @@ -1,8 +1,8 @@ -import { GetColumnData } from 'drizzle-orm'; -import { OptionalKeyOnly, RequiredKeyOnly } from 'drizzle-orm/operations'; -import { Table } from 'drizzle-orm/table'; -import { Update } from 'drizzle-orm/utils'; -import { Simplify } from 'drizzle-orm/utils'; +import { GetColumnData } from '~/column'; +import { OptionalKeyOnly, RequiredKeyOnly } from '~/operations'; +import { Table } from '~/table'; +import { Update } from '~/utils'; +import { Simplify } from '~/utils'; import { Check, CheckBuilder } from './checks'; import { AnyPgColumn, AnyPgColumnBuilder, BuildColumns } from './columns/common'; diff --git a/drizzle-orm/src/pg-common/utils.ts b/drizzle-orm/src/pg-core/utils.ts similarity index 90% rename from drizzle-orm/src/pg-common/utils.ts rename to drizzle-orm/src/pg-core/utils.ts index a3c825e67..ad3b9d68d 100644 --- a/drizzle-orm/src/pg-common/utils.ts +++ b/drizzle-orm/src/pg-core/utils.ts @@ -1,9 +1,9 @@ -import { Table } from 'drizzle-orm'; -import { Param, SQL, SQLResponse } from 'drizzle-orm/sql'; -import { AnyPgColumn, PgColumn } from '~/columns'; -import { SelectFields, SelectFieldsOrdered } from '~/operations'; -import { PgUpdateSet } from '~/query-builders'; -import { AnyPgTable, GetTableConfig, PgTable } from '~/table'; +import { AnyPgColumn, PgColumn } from '~/pg-core/columns'; +import { SelectFields, SelectFieldsOrdered } from '~/pg-core/operations'; +import { PgUpdateSet } from '~/pg-core/query-builders'; +import { AnyPgTable, GetTableConfig, PgTable } from '~/pg-core/table'; +import { Param, SQL, SQLResponse } from '~/sql'; +import { Table } from '~/table'; import { Check, CheckBuilder } from './checks'; import { ForeignKey, ForeignKeyBuilder } from './foreign-keys'; import { Index, IndexBuilder } from './indexes'; @@ -105,8 +105,6 @@ export function mapUpdateSet(table: AnyPgTable, values: Record) ); } -export type Assume = T extends U ? T : U; - export function orderSelectedFields(fields: SelectFields, pathPrefix?: string[]): SelectFieldsOrdered { return Object.entries(fields).reduce((result, [name, field]) => { if (typeof name !== 'string') { diff --git a/drizzle-orm/src/postgres.js/README.md b/drizzle-orm/src/postgres.js/README.md index 86c7993e5..914860c69 100644 --- a/drizzle-orm/src/postgres.js/README.md +++ b/drizzle-orm/src/postgres.js/README.md @@ -4,29 +4,29 @@ ```bash # npm -npm i drizzle-orm drizzle-orm-pg postgres +npm i drizzle-orm postgres npm i -D drizzle-kit # yarn -yarn add drizzle-orm drizzle-orm-pg postgres +yarn add drizzle-orm postgres yarn add -D drizzle-kit # pnpm -pnpm add drizzle-orm drizzle-orm-pg postgres +pnpm add drizzle-orm postgres pnpm add -D drizzle-kit ``` ## Connection ```typescript -import { drizzle, PostgresJsDatabase } from 'drizzle-orm-pg/postgres.js'; +import { drizzle, PostgresJsDatabase } from 'drizzle-orm/postgres.js'; import postgres from 'postgres'; const client = postgres(connectionString); const db: PostgresJsDatabase = drizzle(client); ``` -See [main docs](/drizzle-orm-pg/README.md#sql-schema-declaration) for further usage. +See [main docs](/drizzle-orm/src/pg-core/README.md#sql-schema-declaration) for further usage. ## Running migrations @@ -34,7 +34,7 @@ In order to run the migrations, [you need to use `max: 1` in the postgres.js con ```typescript import postgres from 'postgres'; -import { migrate } from 'drizzle-orm-pg/postgres.js/migrator'; +import { migrate } from 'drizzle-orm/postgres.js/migrator'; const migrationsClient = postgres(connectionString, { max: 1, @@ -43,4 +43,4 @@ const db = drizzle(migrationsClient); await migrate(db, { migrationsFolder: '...' }); ``` -See [main migrations docs](/drizzle-orm-pg/README.md#migrations) for further info. +See [main migrations docs](/drizzle-orm/src/pg-core/README.md#migrations) for further info. diff --git a/drizzle-orm/src/postgres.js/driver.ts b/drizzle-orm/src/postgres.js/driver.ts index 73d702dd3..70d103816 100644 --- a/drizzle-orm/src/postgres.js/driver.ts +++ b/drizzle-orm/src/postgres.js/driver.ts @@ -1,7 +1,7 @@ -import { Logger } from 'drizzle-orm'; import { Sql } from 'postgres'; -import { PgDatabase } from '~/db'; -import { PgDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { PgDatabase } from '~/pg-core/db'; +import { PgDialect } from '~/pg-core/dialect'; import { PostgresJsQueryResultHKT, PostgresJsSession } from './session'; export interface DrizzleConfig { diff --git a/drizzle-orm/src/postgres.js/migrator.ts b/drizzle-orm/src/postgres.js/migrator.ts index 6a0240434..a6adae165 100644 --- a/drizzle-orm/src/postgres.js/migrator.ts +++ b/drizzle-orm/src/postgres.js/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { PostgresJsDatabase } from './driver'; export async function migrate(db: PostgresJsDatabase, config: string | MigrationConfig) { diff --git a/drizzle-orm/src/postgres.js/session.ts b/drizzle-orm/src/postgres.js/session.ts index a6f970f04..d5e30b642 100644 --- a/drizzle-orm/src/postgres.js/session.ts +++ b/drizzle-orm/src/postgres.js/session.ts @@ -1,11 +1,11 @@ -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; import { Row, RowList, Sql } from 'postgres'; -import { PgDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; -import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT } from '~/session'; +import { Logger, NoopLogger } from '~/logger'; +import { PgDialect } from '~/pg-core/dialect'; +import { SelectFieldsOrdered } from '~/pg-core/operations'; +import { PgSession, PreparedQuery, PreparedQueryConfig, QueryResultHKT } from '~/pg-core/session'; +import { fillPlaceholders, Query } from '~/sql'; import { Assume } from '~/utils'; +import { mapResultRow } from '~/utils'; export class PostgresJsPreparedQuery extends PreparedQuery { private query: string; diff --git a/drizzle-orm/src/sql.js/driver.ts b/drizzle-orm/src/sql.js/driver.ts index 8e45a9b5d..b81112c48 100644 --- a/drizzle-orm/src/sql.js/driver.ts +++ b/drizzle-orm/src/sql.js/driver.ts @@ -1,7 +1,7 @@ -import { Logger } from 'drizzle-orm'; import { Database } from 'sql.js'; -import { BaseSQLiteDatabase } from '~/db'; -import { SQLiteSyncDialect } from '~/dialect'; +import { Logger } from '~/logger'; +import { BaseSQLiteDatabase } from '~/sqlite-core/db'; +import { SQLiteSyncDialect } from '~/sqlite-core/dialect'; import { SQLJsSession } from './session'; export interface DrizzleConfig { diff --git a/drizzle-orm/src/sql.js/migrator.ts b/drizzle-orm/src/sql.js/migrator.ts index 2b77cb8ad..2ae9ad314 100644 --- a/drizzle-orm/src/sql.js/migrator.ts +++ b/drizzle-orm/src/sql.js/migrator.ts @@ -1,4 +1,4 @@ -import { MigrationConfig, readMigrationFiles } from 'drizzle-orm/migrator'; +import { MigrationConfig, readMigrationFiles } from '~/migrator'; import { SQLJsDatabase } from './driver'; export function migrate(db: SQLJsDatabase, config: string | MigrationConfig) { diff --git a/drizzle-orm/src/sql.js/session.ts b/drizzle-orm/src/sql.js/session.ts index 7c9f606a2..9b3618eb2 100644 --- a/drizzle-orm/src/sql.js/session.ts +++ b/drizzle-orm/src/sql.js/session.ts @@ -1,14 +1,14 @@ -import { Logger, NoopLogger } from 'drizzle-orm'; -import { fillPlaceholders, Query } from 'drizzle-orm/sql'; -import { mapResultRow } from 'drizzle-orm/utils'; import { BindParams, Database, Statement } from 'sql.js'; -import { SQLiteSyncDialect } from '~/dialect'; -import { SelectFieldsOrdered } from '~/operations'; +import { Logger, NoopLogger } from '~/logger'; +import { fillPlaceholders, Query } from '~/sql'; +import { SQLiteSyncDialect } from '~/sqlite-core/dialect'; +import { SelectFieldsOrdered } from '~/sqlite-core/operations'; import { PreparedQuery as PreparedQueryBase, PreparedQueryConfig as PreparedQueryConfigBase, SQLiteSession, -} from '~/session'; +} from '~/sqlite-core/session'; +import { mapResultRow } from '~/utils'; export interface SQLJsSessionOptions { logger?: Logger; diff --git a/drizzle-orm/src/sqlite-common/README.md b/drizzle-orm/src/sqlite-core/README.md similarity index 60% rename from drizzle-orm/src/sqlite-common/README.md rename to drizzle-orm/src/sqlite-core/README.md index 2284c5daf..4346e8c2e 100644 --- a/drizzle-orm/src/sqlite-common/README.md +++ b/drizzle-orm/src/sqlite-core/README.md @@ -1,9 +1,9 @@
-

Drizzle ORM | SQLite npm

-npm -npm bundle size +

Drizzle ORM | SQLite npm

+npm +npm bundle size Discord -License +License
If you know SQL, you know Drizzle ORM

@@ -13,8 +13,8 @@ Here you can find extensive docs for SQLite module. | Driver | Support | | Driver version | |:- | :-: | :-: | :-: | -| [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) | ✅ | | driver version | -| [sql.js](https://github.com/sql-js/sql.js/) | ✅ | | driver version | +| [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) | ✅ | | driver version | +| [sql.js](https://github.com/sql-js/sql.js/) | ✅ | | driver version | | [node-sqlite3](https://github.com/TryGhost/node-sqlite3) | ⏳ | | | | [bun:sqlite](https://github.com/oven-sh/bun#bunsqlite-sqlite3-module) | ✅ | [Example](https://github.com/drizzle-team/drizzle-orm/tree/main/examples/bun-sqlite)| | | [Cloudflare D1](https://developers.cloudflare.com/d1/) | ✅ | [Example](https://github.com/drizzle-team/drizzle-orm/tree/main/examples/cloudflare-d1)| | @@ -23,7 +23,7 @@ Here you can find extensive docs for SQLite module. ## 💾 Installation ```bash -npm install drizzle-orm drizzle-orm-sqlite better-sqlite3 +npm install drizzle-orm better-sqlite3 ## opt-in automatic migrations generator npm install -D drizzle-kit ``` @@ -31,16 +31,16 @@ npm install -D drizzle-kit ## 🚀 Quick start ```typescript -import { sqliteTable, text, integer } from "drizzle-orm-sqlite"; -import { drizzle } from 'drizzle-orm-sqlite/better-sqlite3'; -import Database from "better-sqlite3"; +import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; +import { drizzle } from 'drizzle-orm/better-sqlite3'; +import Database from 'better-sqlite3'; -const users = sqliteTable("users", { - id: integer("id").primaryKey(), +const users = sqliteTable('users', { + id: integer('id').primaryKey(), fullName: text('full_name'), }) -const sqlite = new Database("sqlite.db"); +const sqlite = new Database('sqlite.db'); const db = drizzle(sqlite); const users = db.select(users).all(); @@ -50,23 +50,23 @@ const users = db.select(users).all(); ```typescript // better-sqlite3 or fly.io LiteFS -import { drizzle, BetterSQLite3Database } from 'drizzle-orm-sqlite/better-sqlite3'; -import Database from "better-sqlite3"; +import { drizzle, BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'; +import Database from 'better-sqlite3'; -const sqlite = new Database("sqlite.db"); +const sqlite = new Database('sqlite.db'); const db: BetterSQLite3Database = drizzle(sqlite); const result = db.select(users).all() // bun js embedded sqlite connector -import { drizzle, BunSQLiteDatabase } from "drizzle-orm-sqlite/bun"; -import { Database } from "bun:sqlite"; +import { drizzle, BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite'; +import { Database } from 'bun:sqlite'; -const sqlite = new Database("nw.sqlite"); +const sqlite = new Database('nw.sqlite'); const db: BunSQLiteDatabase = drizzle(sqlite); const result = db.select(users).all() // Cloudflare D1 connector -import { drizzle, DrizzleD1Database } from 'drizzle-orm-sqlite/d1'; +import { drizzle, DrizzleD1Database } from 'drizzle-orm/d1'; // env.DB from cloudflare worker environment const db: DrizzleD1Database = drizzle(env.DB); @@ -105,41 +105,41 @@ With `drizzle-orm` you declare SQL schema in TypeScript. You can have either one This is how you declare SQL schema in `schema.ts`. You can declare tables, indexes and constraints, foreign keys and enums. Please pay attention to `export` keyword, they are mandatory if you'll be using [drizzle-kit SQL migrations generator](#-migrations). ```typescript -import { sqliteTable, text, integer, uniqueIndex } from "drizzle-orm-sqlite"; +import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core'; -export const countries = sqliteTable("countries", { - id: integer("id").primaryKey(), - name: text("name"), +export const countries = sqliteTable('countries', { + id: integer('id').primaryKey(), + name: text('name'), }, (countries) => ({ - nameIdx: uniqueIndex("nameIdx").on(countries.name), + nameIdx: uniqueIndex('nameIdx').on(countries.name), }) ); -export const cities = sqliteTable("cities", { - id: integer("id").primaryKey(), - name: text("name"), - countryId: integer("country_id").references(() => countries.id), +export const cities = sqliteTable('cities', { + id: integer('id').primaryKey(), + name: text('name'), + countryId: integer('country_id').references(() => countries.id), }) ``` Database and table entity types ```typescript -import { InferModel, text, integer, sqliteTable } from "drizzle-orm-sqlite"; +import { InferModel, text, integer, sqliteTable } from 'drizzle-orm/sqlite-core'; -const users = sqliteTable("users", { +const users = sqliteTable('users', { id: integer('id').primaryKey(), fullName: text('full_name'), phone: text('phone'), }) export type User = InferModel // return type when queried -export type InsertUser = InferModel // insert type +export type InsertUser = InferModel // insert type ... -import { drizzle, BetterSQLite3Database } from 'drizzle-orm-sqlite/better-sqlite3'; -import Database from "better-sqlite3"; +import { drizzle, BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'; +import Database from 'better-sqlite3'; -const sqlite = new Database("sqlite.db"); +const sqlite = new Database('sqlite.db'); const db: BetterSQLite3Database = drizzle(sqlite); const result: User[] = await db.select(users).all() @@ -152,15 +152,15 @@ const insertUser = (user: InsertUser) => { The list of all column types. You can also create custom types - [see here](https://github.com/drizzle-team/drizzle-orm/blob/main/docs/custom-types.md). ```typescript -integer("...") -integer("...", { mode: "number" | "timestamp" | "bigint" }) -real("...") -text("..."); -text<"union" | "string" | "type">("..."); +integer('...') +integer('...', { mode: 'number' | 'timestamp' | 'bigint' }) +real('...') +text('...'); +text<'union' | 'string' | 'type'>('...'); -blob("..."); -blob("...", { mode: "json" | "buffer" }); -blob<{ foo: string }>("..."); +blob('...'); +blob('...', { mode: 'json' | 'buffer' }); +blob<{ foo: string }>('...'); column.primaryKey() column.notNull() @@ -170,24 +170,24 @@ column.default(...) Declaring indexes, foreign keys and composite primary keys ```typescript -import { sqliteTable, foreignKey, text, integer, index, uniqueIndex } from "drizzle-orm-sqlite"; +import { sqliteTable, foreignKey, text, integer, index, uniqueIndex } from 'drizzle-orm/sqlite-core'; -export const countries = sqliteTable("countries", { - id: integer("id").primaryKey(), - name: text("name", { length: 256 }), - population: integer("population"), +export const countries = sqliteTable('countries', { + id: integer('id').primaryKey(), + name: text('name', { length: 256 }), + population: integer('population'), }, (countries) => ({ - nameIdx: index("name_idx").on(countries.name), // one column - namePopulationIdx: index("name_population_idx").on(countries.name, countries.population), // multiple columns - uniqueIdx: uniqueIndex("unique_idx").on(countries.name), // unique index + nameIdx: index('name_idx').on(countries.name), // one column + namePopulationIdx: index('name_population_idx').on(countries.name, countries.population), // multiple columns + uniqueIdx: uniqueIndex('unique_idx').on(countries.name), // unique index }) ); -export const cities = sqliteTable("cities", { - id: integer("id").primaryKey(), - name: text("name", { length: 256 }), - countryId: integer("country_id").references(() => countries.id), // inline foreign key - countryName: text("country_id"), +export const cities = sqliteTable('cities', { + id: integer('id').primaryKey(), + name: text('name', { length: 256 }), + countryId: integer('country_id').references(() => countries.id), // inline foreign key + countryName: text('country_id'), }, (cities) => ({ // explicit foreign key with 1 column countryFk: foreignKey(() => ({ @@ -211,7 +211,7 @@ const pkExample = sqliteTable('pk_example', { })); // you can have .where() on indexes -index("name_idx").on(table.column).where(sql``) +index('name_idx').on(table.column).where(sql``) ``` ### Create Read Update Delete @@ -220,24 +220,24 @@ Querying, sorting and filtering. We also support partial select. ```typescript ... -import { sqliteTable, text, integer } from "drizzle-orm-sqlite"; -import { and, asc, desc, eq, or } from "drizzle-orm/expressions" -import { drizzle } from 'drizzle-orm-sqlite/better-sqlite3'; -import Database from "better-sqlite3"; - -const users = sqliteTable("users", { - id: integer("id").primaryKey(), - name: text("full_name"), +import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; +import { and, asc, desc, eq, or } from 'drizzle-orm/expressions' +import { drizzle } from 'drizzle-orm/better-sqlite3'; +import Database from 'better-sqlite3'; + +const users = sqliteTable('users', { + id: integer('id').primaryKey(), + name: text('full_name'), }); -const sqlite = new Database("sqlite.db"); +const sqlite = new Database('sqlite.db'); const db = drizzle(sqlite); db.select(users).all(); db.select(users).where(eq(users.id, 42)).get(); // you can combine filters with and(...) or or(...) -db.select(users).where(and(eq(users.id, 42), eq(users.name, "Dan"))).all(); +db.select(users).where(and(eq(users.id, 42), eq(users.name, 'Dan'))).all(); db.select(users).where(or(eq(users.id, 42), eq(users.id, 1))).all(); @@ -295,39 +295,39 @@ notIlike(column, value) not(sqlExpression) -and(exressions: Expr[]) -or(exressions: Expr[]) +and(expressions: Expr[]) +or(expressions: Expr[]) ``` Inserting ```typescript -import { sqliteTable, text, integer } from "drizzle-orm-sqlite"; -import { drizzle } from 'drizzle-orm-sqlite/better-sqlite3'; -import Database from "better-sqlite3"; +import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; +import { drizzle } from 'drizzle-orm/better-sqlite3'; +import Database from 'better-sqlite3'; -const sqlite = new Database("sqlite.db"); +const sqlite = new Database('sqlite.db'); const db = drizzle(sqlite); -const users = sqliteTable("users", { - id: integer("id").primaryKey(), - name: text("name"), - createdAt: integer("created_at", { mode: "timestamp" }), +const users = sqliteTable('users', { + id: integer('id').primaryKey(), + name: text('name'), + createdAt: integer('created_at', { mode: 'timestamp' }), }); -db.insert(users).values({ name: "Andrew", createdAt: +new Date() }).run(); +db.insert(users).values({ name: 'Andrew', createdAt: +new Date() }).run(); // insert multiple users db.insert(users).values({ - name: "Andrew", + name: 'Andrew', createdAt: +new Date(), },{ - name: "Dan", + name: 'Dan', createdAt: +new Date(), }).run(); // insert with returning -const insertedUser = db.insert(users).values({ name: "Dan", createdAt: +new Date() }).returning().get() +const insertedUser = db.insert(users).values({ name: 'Dan', createdAt: +new Date() }).returning().get() ``` Update and Delete @@ -348,28 +348,28 @@ db.delete(users) They work just like they do in SQL, but you have them fully type safe ```typescript -const orders = sqliteTable("order", { - id: integer("id").primaryKey(), - orderDate: integer("order_date", { mode: "timestamp" }).notNull(), - requiredDate: integer("required_date", { mode: "timestamp" }).notNull(), - shippedDate: integer("shipped_date", { mode: "timestamp" }), - shipVia: integer("ship_via").notNull(), - freight: numeric("freight").notNull(), - shipName: text("ship_name").notNull(), - shipCity: text("ship_city").notNull(), - shipRegion: text("ship_region"), - shipPostalCode: text("ship_postal_code"), - shipCountry: text("ship_country").notNull(), - customerId: text("customer_id").notNull(), - employeeId: integer("employee_id").notNull(), +const orders = sqliteTable('order', { + id: integer('id').primaryKey(), + orderDate: integer('order_date', { mode: 'timestamp' }).notNull(), + requiredDate: integer('required_date', { mode: 'timestamp' }).notNull(), + shippedDate: integer('shipped_date', { mode: 'timestamp' }), + shipVia: integer('ship_via').notNull(), + freight: numeric('freight').notNull(), + shipName: text('ship_name').notNull(), + shipCity: text('ship_city').notNull(), + shipRegion: text('ship_region'), + shipPostalCode: text('ship_postal_code'), + shipCountry: text('ship_country').notNull(), + customerId: text('customer_id').notNull(), + employeeId: integer('employee_id').notNull(), }); -const details = sqliteTable("order_detail", { - unitPrice: numeric("unit_price").notNull(), - quantity: integer("quantity").notNull(), - discount: numeric("discount").notNull(), - orderId: integer("order_id").notNull(), - productId: integer("product_id").notNull(), +const details = sqliteTable('order_detail', { + unitPrice: numeric('unit_price').notNull(), + quantity: integer('quantity').notNull(), + discount: numeric('discount').notNull(), + orderId: integer('order_id').notNull(), + productId: integer('product_id').notNull(), }); @@ -396,18 +396,18 @@ Last but not least. Probably the most powerful feature in the library🚀 ### Many-to-one ```typescript -import { sqliteTable, text, integer } from "drizzle-orm-sqlite"; -import { drizzle } from 'drizzle-orm-sqlite/better-sqlite3'; +import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; +import { drizzle } from 'drizzle-orm/better-sqlite3'; -const cities = sqliteTable("cities", { - id: integer("id").primaryKey(), - name: text("name"), +const cities = sqliteTable('cities', { + id: integer('id').primaryKey(), + name: text('name'), }); -const users = sqliteTable("users", { - id: integer("id").primaryKey(), - name: text("name"), - cityId: integer("city_id").references(() => cities.id) +const users = sqliteTable('users', { + id: integer('id').primaryKey(), + name: text('name'), + cityId: integer('city_id').references(() => cities.id) }); const db = drizzle(sqlite); @@ -418,19 +418,19 @@ const result = db.select(cities).leftJoin(users, eq(cities2.id, users2.cityId)). ### Many-to-many ```typescript -const users = sqliteTable("users", { - id: integer("id").primaryKey(), - name: text("name"), +const users = sqliteTable('users', { + id: integer('id').primaryKey(), + name: text('name'), }); -const chatGroups = sqliteTable("chat_groups", { - id: integer("id").primaryKey(), - name: text("name"), +const chatGroups = sqliteTable('chat_groups', { + id: integer('id').primaryKey(), + name: text('name'), }); -const usersToChatGroups = sqliteTable("usersToChatGroups", { - userId: integer("user_id").notNull().references(() => users.id), - groupId: integer("group_id").notNull().references(() => chatGroups.id), +const usersToChatGroups = sqliteTable('usersToChatGroups', { + userId: integer('user_id').notNull().references(() => users.id), + groupId: integer('group_id').notNull().references(() => chatGroups.id), }); ... @@ -444,25 +444,25 @@ db.select(usersToChatGroups) .all(); ``` -### Join aliases and selfjoins +### Join aliases and self-joins ```typescript -import { ..., alias } from "drizzle-orm-sqlite"; +import { ..., alias } from 'drizzle-orm/sqlite-core'; -export const files = sqliteTable("folders", { - name: text("name").notNull(), - parent: text("parent_folder") +export const files = sqliteTable('folders', { + name: text('name').notNull(), + parent: text('parent_folder') }) ... const db = drizzle(...); -const nestedFiles = alias(files, "nested_files"); +const nestedFiles = alias(files, 'nested_files'); db.select(files) .leftJoin(nestedFiles, eq(files.name, nestedFiles.name)) - .where(eq(files.parent, "/")) + .where(eq(files.parent, '/')) .all(); -// will return files and folers and nested files for each folder at root dir +// will return files and folders and nested files for each folder at root dir ``` ### Join using partial field select @@ -483,48 +483,48 @@ db.select(cities).fields({ With Drizzle ORM you can go [**faster than better-sqlite3 driver**](https://twitter.com/_alexblokh/status/1593593415907909634) by utilizing our `prepared statements` and `placeholder` APIs ```typescript -import { placeholder } from "drizzle-orm/sql"; +import { placeholder } from 'drizzle-orm/sql'; const db = drizzle(...); const q = db.select(customers).prepare(); q.all() // SELECT * FROM customers -const q = db.select(customers).where(eq(customers.id, placeholder("id"))).prepare() +const q = db.select(customers).where(eq(customers.id, placeholder('id'))).prepare() q.get({ id: 10 }) // SELECT * FROM customers WHERE id = 10 q.get({ id: 12 }) // SELECT * FROM customers WHERE id = 12 const q = db.select(customers) - .where(sql`lower(${customers.name}) like ${placeholder("name")}`) + .where(sql`lower(${customers.name}) like ${placeholder('name')}`) .prepare(); -q.all({ name: "%an%" }) // SELECT * FROM customers WHERE name ilike '%an%' +q.all({ name: '%an%' }) // SELECT * FROM customers WHERE name ilike '%an%' ``` ## 🗄 Migrations ### Automatic SQL migrations generation with drizzle-kit -[DrizzleKit](https://www.npmjs.com/package/drizzle-kit) - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like delitions and renames by prompting user input.\ +[DrizzleKit](https://www.npmjs.com/package/drizzle-kit) - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input. Check out the [docs for DrizzleKit](https://github.com/drizzle-team/drizzle-kit-mirror) For schema file: ```typescript -import { index, integer, sqliteTable, text } from "drizzle-orm-sqlite"; +import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; -export const users = sqliteTable("users", { - id: serial("id").primaryKey(), - fullName: text("full_name"), +export const users = sqliteTable('users', { + id: serial('id').primaryKey(), + fullName: text('full_name'), }, (users) => ({ - nameIdx: index("name_idx", users.fullName), + nameIdx: index('name_idx', users.fullName), })); -export const authOtps = sqliteTable("auth_otp", { - id: integer("id").primaryKey(), - phone: text("phone"), - userId: integer("user_id").references(() => users.id), +export const authOtps = sqliteTable('auth_otp', { + id: integer('id').primaryKey(), + phone: text('phone'), + userId: integer('user_id').references(() => users.id), } ``` @@ -532,18 +532,18 @@ It will generate: ```SQL CREATE TABLE IF NOT EXISTS auth_otp ( - "id" INTEGER PRIMARY KEY, - "phone" TEXT, - "user_id" INTEGER + 'id' INTEGER PRIMARY KEY, + 'phone' TEXT, + 'user_id' INTEGER ); CREATE TABLE IF NOT EXISTS users ( - "id" INTEGER PRIMARY KEY, - "full_name" TEXT + 'id' INTEGER PRIMARY KEY, + 'full_name' TEXT ); DO $$ BEGIN - ALTER TABLE auth_otp ADD CONSTRAINT auth_otp_user_id_fkey FOREIGN KEY ("user_id") REFERENCES users(id); + ALTER TABLE auth_otp ADD CONSTRAINT auth_otp_user_id_fkey FOREIGN KEY ('user_id') REFERENCES users(id); EXCEPTION WHEN duplicate_object THEN null; END $$; @@ -554,15 +554,15 @@ CREATE INDEX IF NOT EXISTS users_full_name_index ON users (full_name); And you can run migrations manually or using our embedded migrations module ```typescript -import { drizzle } from 'drizzle-orm-sqlite/better-sqlite3'; -import { migrate } from 'drizzle-orm-sqlite/better-sqlite3/migrator'; -import Database from "better-sqlite3"; +import { drizzle } from 'drizzle-orm/better-sqlite3'; +import { migrate } from 'drizzle-orm/better-sqlite3/migrator'; +import Database from 'better-sqlite3'; -const sqlite = new Database("sqlite.db"); +const sqlite = new Database('sqlite.db'); const db = drizzle(sqlite); // this will automatically run needed migrations on the database -migrate(db, { migrationsFolder: "./drizzle" }) +migrate(db, { migrationsFolder: './drizzle' }) ``` ## Utility stuff @@ -576,7 +576,7 @@ const query = db.select(users) .toSQL(); // query: { - sql: 'select "id", "name" from "users" group by "users"."id"', + sql: 'select 'id', 'name' from 'users' group by 'users'.'id'', params: [], } ``` diff --git a/drizzle-orm/src/sqlite-common/alias.ts b/drizzle-orm/src/sqlite-core/alias.ts similarity index 84% rename from drizzle-orm/src/sqlite-common/alias.ts rename to drizzle-orm/src/sqlite-core/alias.ts index abab1c538..87d7198e6 100644 --- a/drizzle-orm/src/sqlite-common/alias.ts +++ b/drizzle-orm/src/sqlite-core/alias.ts @@ -1,4 +1,4 @@ -import { TableAliasProxyHandler } from 'drizzle-orm/alias'; +import { TableAliasProxyHandler } from '~/alias'; import { BuildAliasTable } from './query-builders/select.types'; import { AnySQLiteTable } from './table'; diff --git a/drizzle-orm/src/sqlite-common/checks.ts b/drizzle-orm/src/sqlite-core/checks.ts similarity index 94% rename from drizzle-orm/src/sqlite-common/checks.ts rename to drizzle-orm/src/sqlite-core/checks.ts index 097711e6c..8ba05e4f9 100644 --- a/drizzle-orm/src/sqlite-common/checks.ts +++ b/drizzle-orm/src/sqlite-core/checks.ts @@ -1,4 +1,4 @@ -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { AnySQLiteTable } from './table'; export class CheckBuilder { diff --git a/drizzle-orm/src/sqlite-common/columns/blob.ts b/drizzle-orm/src/sqlite-core/columns/blob.ts similarity index 92% rename from drizzle-orm/src/sqlite-common/columns/blob.ts rename to drizzle-orm/src/sqlite-core/columns/blob.ts index 9b4b70fa9..7e5f079a7 100644 --- a/drizzle-orm/src/sqlite-common/columns/blob.ts +++ b/drizzle-orm/src/sqlite-core/columns/blob.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnySQLiteTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnySQLiteTable } from '~/sqlite-core/table'; import { SQLiteColumn, SQLiteColumnBuilder } from './common'; diff --git a/drizzle-orm/src/sqlite-common/columns/common.ts b/drizzle-orm/src/sqlite-core/columns/common.ts similarity index 89% rename from drizzle-orm/src/sqlite-common/columns/common.ts rename to drizzle-orm/src/sqlite-core/columns/common.ts index d708ecb62..b78dee0a9 100644 --- a/drizzle-orm/src/sqlite-common/columns/common.ts +++ b/drizzle-orm/src/sqlite-core/columns/common.ts @@ -1,16 +1,11 @@ -import { Column, ColumnBaseConfig } from 'drizzle-orm'; -import { - ColumnBuilder, - ColumnBuilderBaseConfig, - ColumnBuilderWithConfig, - UpdateCBConfig, -} from 'drizzle-orm/column-builder'; -import { SQL } from 'drizzle-orm/sql'; -import { Update } from 'drizzle-orm/utils'; -import { Simplify } from 'drizzle-orm/utils'; - -import { ForeignKey, ForeignKeyBuilder, UpdateDeleteAction } from '~/foreign-keys'; -import { AnySQLiteTable } from '~/table'; +import { Column, ColumnBaseConfig } from '~/column'; +import { ColumnBuilder, ColumnBuilderBaseConfig, ColumnBuilderWithConfig, UpdateCBConfig } from '~/column-builder'; +import { SQL } from '~/sql'; +import { Update } from '~/utils'; +import { Simplify } from '~/utils'; + +import { ForeignKey, ForeignKeyBuilder, UpdateDeleteAction } from '~/sqlite-core/foreign-keys'; +import { AnySQLiteTable } from '~/sqlite-core/table'; export interface ReferenceConfig { ref: () => AnySQLiteColumn; diff --git a/drizzle-orm/src/sqlite-common/columns/index.ts b/drizzle-orm/src/sqlite-core/columns/index.ts similarity index 100% rename from drizzle-orm/src/sqlite-common/columns/index.ts rename to drizzle-orm/src/sqlite-core/columns/index.ts diff --git a/drizzle-orm/src/sqlite-common/columns/integer.ts b/drizzle-orm/src/sqlite-core/columns/integer.ts similarity index 96% rename from drizzle-orm/src/sqlite-common/columns/integer.ts rename to drizzle-orm/src/sqlite-core/columns/integer.ts index 2d5faffa8..31ba83791 100644 --- a/drizzle-orm/src/sqlite-common/columns/integer.ts +++ b/drizzle-orm/src/sqlite-core/columns/integer.ts @@ -1,7 +1,7 @@ -import { ColumnBaseConfig } from 'drizzle-orm'; -import { ColumnBuilderBaseConfig, ColumnBuilderConfig, UpdateCBConfig } from 'drizzle-orm/column-builder'; -import { SQL, sql } from 'drizzle-orm/sql'; -import { OnConflict } from '~/utils'; +import { ColumnBaseConfig } from '~/column'; +import { ColumnBuilderBaseConfig, ColumnBuilderConfig, UpdateCBConfig } from '~/column-builder'; +import { SQL, sql } from '~/sql'; +import { OnConflict } from '~/sqlite-core/utils'; import { AnySQLiteTable } from '../table'; import { SQLiteColumn, SQLiteColumnBuilder } from './common'; diff --git a/drizzle-orm/src/sqlite-common/columns/numeric.ts b/drizzle-orm/src/sqlite-core/columns/numeric.ts similarity index 83% rename from drizzle-orm/src/sqlite-common/columns/numeric.ts rename to drizzle-orm/src/sqlite-core/columns/numeric.ts index 25301294b..3808a1a2a 100644 --- a/drizzle-orm/src/sqlite-common/columns/numeric.ts +++ b/drizzle-orm/src/sqlite-core/columns/numeric.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnySQLiteTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnySQLiteTable } from '~/sqlite-core/table'; import { SQLiteColumn, SQLiteColumnBuilder } from './common'; export class SQLiteNumericBuilder diff --git a/drizzle-orm/src/sqlite-common/columns/real.ts b/drizzle-orm/src/sqlite-core/columns/real.ts similarity index 87% rename from drizzle-orm/src/sqlite-common/columns/real.ts rename to drizzle-orm/src/sqlite-core/columns/real.ts index c88fb21f4..45ccc46e2 100644 --- a/drizzle-orm/src/sqlite-common/columns/real.ts +++ b/drizzle-orm/src/sqlite-core/columns/real.ts @@ -1,5 +1,5 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; import { AnySQLiteTable } from '../table'; import { SQLiteColumn, SQLiteColumnBuilder } from './common'; diff --git a/drizzle-orm/src/sqlite-common/columns/text.ts b/drizzle-orm/src/sqlite-core/columns/text.ts similarity index 83% rename from drizzle-orm/src/sqlite-common/columns/text.ts rename to drizzle-orm/src/sqlite-core/columns/text.ts index 8b3eac1f4..f9375142d 100644 --- a/drizzle-orm/src/sqlite-common/columns/text.ts +++ b/drizzle-orm/src/sqlite-core/columns/text.ts @@ -1,6 +1,6 @@ -import { ColumnConfig } from 'drizzle-orm'; -import { ColumnBuilderConfig } from 'drizzle-orm/column-builder'; -import { AnySQLiteTable } from '~/table'; +import { ColumnConfig } from '~/column'; +import { ColumnBuilderConfig } from '~/column-builder'; +import { AnySQLiteTable } from '~/sqlite-core/table'; import { SQLiteColumn, SQLiteColumnBuilder } from './common'; diff --git a/drizzle-orm/src/sqlite-common/db.ts b/drizzle-orm/src/sqlite-core/db.ts similarity index 84% rename from drizzle-orm/src/sqlite-common/db.ts rename to drizzle-orm/src/sqlite-core/db.ts index a3a172411..30904f4a3 100644 --- a/drizzle-orm/src/sqlite-common/db.ts +++ b/drizzle-orm/src/sqlite-core/db.ts @@ -1,10 +1,10 @@ -import { Table } from 'drizzle-orm'; -import { SQLWrapper } from 'drizzle-orm/sql'; +import { SQLWrapper } from '~/sql'; +import { Table } from '~/table'; -import { SQLiteAsyncDialect, SQLiteSyncDialect } from '~/dialect'; -import { SQLiteDelete, SQLiteInsertBuilder, SQLiteSelect, SQLiteUpdateBuilder } from '~/query-builders'; -import { ResultKind, SQLiteSession } from '~/session'; -import { AnySQLiteTable } from '~/table'; +import { SQLiteAsyncDialect, SQLiteSyncDialect } from '~/sqlite-core/dialect'; +import { SQLiteDelete, SQLiteInsertBuilder, SQLiteSelect, SQLiteUpdateBuilder } from '~/sqlite-core/query-builders'; +import { ResultKind, SQLiteSession } from '~/sqlite-core/session'; +import { AnySQLiteTable } from '~/sqlite-core/table'; import { orderSelectedFields } from './utils'; export class BaseSQLiteDatabase { diff --git a/drizzle-orm/src/sqlite-common/dialect.ts b/drizzle-orm/src/sqlite-core/dialect.ts similarity index 93% rename from drizzle-orm/src/sqlite-common/dialect.ts rename to drizzle-orm/src/sqlite-core/dialect.ts index 6fdfd873b..5615c2907 100644 --- a/drizzle-orm/src/sqlite-common/dialect.ts +++ b/drizzle-orm/src/sqlite-core/dialect.ts @@ -1,10 +1,16 @@ -import { AnyColumn, Column, param, sql, Table } from 'drizzle-orm'; -import { MigrationMeta } from 'drizzle-orm/migrator'; -import { Name, Query, SQL, SQLResponse, SQLSourceParam } from 'drizzle-orm/sql'; -import { AnySQLiteColumn, SQLiteColumn } from '~/columns'; -import { SelectFieldsOrdered } from '~/operations'; -import { SQLiteDeleteConfig, SQLiteInsertConfig, SQLiteUpdateConfig, SQLiteUpdateSet } from '~/query-builders'; -import { AnySQLiteTable, SQLiteTable } from '~/table'; +import { AnyColumn, Column } from '~/column'; +import { MigrationMeta } from '~/migrator'; +import { Name, param, Query, SQL, sql, SQLResponse, SQLSourceParam } from '~/sql'; +import { AnySQLiteColumn, SQLiteColumn } from '~/sqlite-core/columns'; +import { SelectFieldsOrdered } from '~/sqlite-core/operations'; +import { + SQLiteDeleteConfig, + SQLiteInsertConfig, + SQLiteUpdateConfig, + SQLiteUpdateSet, +} from '~/sqlite-core/query-builders'; +import { AnySQLiteTable, SQLiteTable } from '~/sqlite-core/table'; +import { Table } from '~/table'; import { SQLiteSelectConfig } from './query-builders/select.types'; import { SQLiteSession } from './session'; diff --git a/drizzle-orm/src/sqlite-common/expressions.ts b/drizzle-orm/src/sqlite-core/expressions.ts similarity index 75% rename from drizzle-orm/src/sqlite-common/expressions.ts rename to drizzle-orm/src/sqlite-core/expressions.ts index 13fac102e..939ab8802 100644 --- a/drizzle-orm/src/sqlite-common/expressions.ts +++ b/drizzle-orm/src/sqlite-core/expressions.ts @@ -1,8 +1,7 @@ -import { sql } from 'drizzle-orm'; -import { param, SQL, SQLResponse, SQLSourceParam } from 'drizzle-orm/sql'; -import { AnySQLiteColumn } from '~/columns'; +import { param, SQL, sql, SQLResponse, SQLSourceParam } from '~/sql'; +import { AnySQLiteColumn } from '~/sqlite-core/columns'; -export * from 'drizzle-orm/expressions'; +export * from '~/expressions'; export function concat(column: AnySQLiteColumn, value: string): SQL { return sql`${column} || ${param(value, column)}`; diff --git a/drizzle-orm/src/sqlite-common/foreign-keys.ts b/drizzle-orm/src/sqlite-core/foreign-keys.ts similarity index 100% rename from drizzle-orm/src/sqlite-common/foreign-keys.ts rename to drizzle-orm/src/sqlite-core/foreign-keys.ts diff --git a/drizzle-orm/src/sqlite-common/index.ts b/drizzle-orm/src/sqlite-core/index.ts similarity index 100% rename from drizzle-orm/src/sqlite-common/index.ts rename to drizzle-orm/src/sqlite-core/index.ts diff --git a/drizzle-orm/src/sqlite-common/indexes.ts b/drizzle-orm/src/sqlite-core/indexes.ts similarity index 97% rename from drizzle-orm/src/sqlite-common/indexes.ts rename to drizzle-orm/src/sqlite-core/indexes.ts index 0fb0cad3b..95136a36e 100644 --- a/drizzle-orm/src/sqlite-common/indexes.ts +++ b/drizzle-orm/src/sqlite-core/indexes.ts @@ -1,4 +1,4 @@ -import { SQL } from 'drizzle-orm/sql'; +import { SQL } from '~/sql'; import { AnySQLiteColumn } from './columns'; import { AnySQLiteTable } from './table'; diff --git a/drizzle-orm/src/sqlite-common/operations.ts b/drizzle-orm/src/sqlite-core/operations.ts similarity index 75% rename from drizzle-orm/src/sqlite-common/operations.ts rename to drizzle-orm/src/sqlite-core/operations.ts index 89834e917..f6a7c2823 100644 --- a/drizzle-orm/src/sqlite-common/operations.ts +++ b/drizzle-orm/src/sqlite-core/operations.ts @@ -1,10 +1,10 @@ -import { GetColumnData } from 'drizzle-orm'; -import { SelectFieldsOrdered as SelectFieldsOrderedBase } from 'drizzle-orm/operations'; -import { SQL, SQLResponse } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; +import { GetColumnData } from '~/column'; +import { SelectFieldsOrdered as SelectFieldsOrderedBase } from '~/operations'; +import { SQL, SQLResponse } from '~/sql'; +import { Simplify } from '~/utils'; -import { AnySQLiteColumn } from '~/columns/common'; -import { AnySQLiteTable, GetTableConfig } from '~/table'; +import { AnySQLiteColumn } from '~/sqlite-core/columns/common'; +import { AnySQLiteTable, GetTableConfig } from '~/sqlite-core/table'; export type SQLiteSelectFields = { [Key: string]: SQL | SQLResponse | AnySQLiteColumn | SQLiteSelectFields | AnySQLiteTable; diff --git a/drizzle-orm/src/sqlite-common/primary-keys.ts b/drizzle-orm/src/sqlite-core/primary-keys.ts similarity index 100% rename from drizzle-orm/src/sqlite-common/primary-keys.ts rename to drizzle-orm/src/sqlite-core/primary-keys.ts diff --git a/drizzle-orm/src/sqlite-common/query-builders/delete.ts b/drizzle-orm/src/sqlite-core/query-builders/delete.ts similarity index 86% rename from drizzle-orm/src/sqlite-common/query-builders/delete.ts rename to drizzle-orm/src/sqlite-core/query-builders/delete.ts index 263b7cdc8..6430c3559 100644 --- a/drizzle-orm/src/sqlite-common/query-builders/delete.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/delete.ts @@ -1,10 +1,10 @@ -import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { SQLiteDialect } from '~/dialect'; +import { Query, SQL, SQLWrapper } from '~/sql'; +import { SQLiteDialect } from '~/sqlite-core/dialect'; -import { SelectFieldsOrdered, SelectResultFields, SQLiteSelectFields } from '~/operations'; -import { PreparedQuery, SQLiteSession } from '~/session'; -import { AnySQLiteTable, InferModel, SQLiteTable } from '~/table'; -import { orderSelectedFields } from '~/utils'; +import { SelectFieldsOrdered, SelectResultFields, SQLiteSelectFields } from '~/sqlite-core/operations'; +import { PreparedQuery, SQLiteSession } from '~/sqlite-core/session'; +import { AnySQLiteTable, InferModel, SQLiteTable } from '~/sqlite-core/table'; +import { orderSelectedFields } from '~/sqlite-core/utils'; export interface SQLiteDeleteConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/sqlite-common/query-builders/index.ts b/drizzle-orm/src/sqlite-core/query-builders/index.ts similarity index 100% rename from drizzle-orm/src/sqlite-common/query-builders/index.ts rename to drizzle-orm/src/sqlite-core/query-builders/index.ts diff --git a/drizzle-orm/src/sqlite-common/query-builders/insert.ts b/drizzle-orm/src/sqlite-core/query-builders/insert.ts similarity index 90% rename from drizzle-orm/src/sqlite-common/query-builders/insert.ts rename to drizzle-orm/src/sqlite-core/query-builders/insert.ts index 76fa16520..559360ebc 100644 --- a/drizzle-orm/src/sqlite-common/query-builders/insert.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/insert.ts @@ -1,13 +1,13 @@ -import { Table } from 'drizzle-orm'; -import { Param, Placeholder, Query, SQL, sql, SQLWrapper } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; - -import { SQLiteDialect } from '~/dialect'; -import { IndexColumn } from '~/indexes'; -import { SelectFieldsOrdered, SelectResultFields, SQLiteSelectFields } from '~/operations'; -import { PreparedQuery, SQLiteSession } from '~/session'; -import { AnySQLiteTable, InferModel, SQLiteTable } from '~/table'; -import { mapUpdateSet, orderSelectedFields } from '~/utils'; +import { Param, Placeholder, Query, SQL, sql, SQLWrapper } from '~/sql'; +import { Table } from '~/table'; +import { Simplify } from '~/utils'; + +import { SQLiteDialect } from '~/sqlite-core/dialect'; +import { IndexColumn } from '~/sqlite-core/indexes'; +import { SelectFieldsOrdered, SelectResultFields, SQLiteSelectFields } from '~/sqlite-core/operations'; +import { PreparedQuery, SQLiteSession } from '~/sqlite-core/session'; +import { AnySQLiteTable, InferModel, SQLiteTable } from '~/sqlite-core/table'; +import { mapUpdateSet, orderSelectedFields } from '~/sqlite-core/utils'; import { SQLiteUpdateSetSource } from './update'; export interface SQLiteInsertConfig { diff --git a/drizzle-orm/src/sqlite-common/query-builders/select.ts b/drizzle-orm/src/sqlite-core/query-builders/select.ts similarity index 91% rename from drizzle-orm/src/sqlite-common/query-builders/select.ts rename to drizzle-orm/src/sqlite-core/query-builders/select.ts index be9a0a2f5..03e44aeee 100644 --- a/drizzle-orm/src/sqlite-common/query-builders/select.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/select.ts @@ -1,12 +1,12 @@ -import { Table } from 'drizzle-orm'; -import { Placeholder, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { AnySQLiteColumn } from '~/columns'; -import { SQLiteDialect } from '~/dialect'; - -import { SQLiteSelectFields } from '~/operations'; -import { PreparedQuery, SQLiteSession } from '~/session'; -import { AnySQLiteTable, GetTableConfig, InferModel } from '~/table'; -import { orderSelectedFields } from '~/utils'; +import { Placeholder, Query, SQL, SQLWrapper } from '~/sql'; +import { AnySQLiteColumn } from '~/sqlite-core/columns'; +import { SQLiteDialect } from '~/sqlite-core/dialect'; +import { Table } from '~/table'; + +import { SQLiteSelectFields } from '~/sqlite-core/operations'; +import { PreparedQuery, SQLiteSession } from '~/sqlite-core/session'; +import { AnySQLiteTable, GetTableConfig, InferModel } from '~/sqlite-core/table'; +import { orderSelectedFields } from '~/sqlite-core/utils'; import { AnySQLiteSelect, diff --git a/drizzle-orm/src/sqlite-common/query-builders/select.types.ts b/drizzle-orm/src/sqlite-core/query-builders/select.types.ts similarity index 92% rename from drizzle-orm/src/sqlite-common/query-builders/select.types.ts rename to drizzle-orm/src/sqlite-core/query-builders/select.types.ts index 2cb67a6bc..b60e3bca4 100644 --- a/drizzle-orm/src/sqlite-common/query-builders/select.types.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/select.types.ts @@ -1,11 +1,22 @@ -import { GetColumnConfig } from 'drizzle-orm'; -import { Placeholder, SQL, SQLResponse } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; - -import { AnySQLiteColumn } from '~/columns'; -import { ChangeColumnTableName } from '~/columns/common'; -import { SelectFieldsOrdered, SelectResultField, SelectResultFields, SQLiteSelectFields } from '~/operations'; -import { AnySQLiteTable, GetTableConfig, SQLiteTableWithColumns, TableConfig, UpdateTableConfig } from '~/table'; +import { GetColumnConfig } from '~/column'; +import { Placeholder, SQL, SQLResponse } from '~/sql'; +import { Simplify } from '~/utils'; + +import { AnySQLiteColumn } from '~/sqlite-core/columns'; +import { ChangeColumnTableName } from '~/sqlite-core/columns/common'; +import { + SelectFieldsOrdered, + SelectResultField, + SelectResultFields, + SQLiteSelectFields, +} from '~/sqlite-core/operations'; +import { + AnySQLiteTable, + GetTableConfig, + SQLiteTableWithColumns, + TableConfig, + UpdateTableConfig, +} from '~/sqlite-core/table'; import { SQLiteSelect } from './select'; diff --git a/drizzle-orm/src/sqlite-common/query-builders/update.ts b/drizzle-orm/src/sqlite-core/query-builders/update.ts similarity index 89% rename from drizzle-orm/src/sqlite-common/query-builders/update.ts rename to drizzle-orm/src/sqlite-core/query-builders/update.ts index a55eb08b7..68abeaabe 100644 --- a/drizzle-orm/src/sqlite-common/query-builders/update.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/update.ts @@ -1,12 +1,11 @@ -import { GetColumnData } from 'drizzle-orm'; -import { Param, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; -import { Simplify } from 'drizzle-orm/utils'; -import { SQLiteDialect } from '~/dialect'; - -import { SelectFieldsOrdered, SelectResultFields, SQLiteSelectFields } from '~/operations'; -import { PreparedQuery, SQLiteSession } from '~/session'; -import { AnySQLiteTable, GetTableConfig, InferModel, SQLiteTable } from '~/table'; -import { mapUpdateSet, orderSelectedFields } from '~/utils'; +import { GetColumnData } from '~/column'; +import { Param, Query, SQL, SQLWrapper } from '~/sql'; +import { SQLiteDialect } from '~/sqlite-core/dialect'; +import { SelectFieldsOrdered, SelectResultFields, SQLiteSelectFields } from '~/sqlite-core/operations'; +import { PreparedQuery, SQLiteSession } from '~/sqlite-core/session'; +import { AnySQLiteTable, GetTableConfig, InferModel, SQLiteTable } from '~/sqlite-core/table'; +import { mapUpdateSet, orderSelectedFields } from '~/sqlite-core/utils'; +import { Simplify } from '~/utils'; export interface SQLiteUpdateConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/sqlite-common/session.ts b/drizzle-orm/src/sqlite-core/session.ts similarity index 96% rename from drizzle-orm/src/sqlite-common/session.ts rename to drizzle-orm/src/sqlite-core/session.ts index e4d2477f8..68e213334 100644 --- a/drizzle-orm/src/sqlite-common/session.ts +++ b/drizzle-orm/src/sqlite-core/session.ts @@ -1,5 +1,5 @@ -import { Query, SQL } from 'drizzle-orm/sql'; -import { SQLiteDialect } from '~/dialect'; +import { Query, SQL } from '~/sql'; +import { SQLiteDialect } from '~/sqlite-core/dialect'; import { SelectFieldsOrdered } from './operations'; export interface PreparedQueryConfig { diff --git a/drizzle-orm/src/sqlite-common/table.ts b/drizzle-orm/src/sqlite-core/table.ts similarity index 94% rename from drizzle-orm/src/sqlite-common/table.ts rename to drizzle-orm/src/sqlite-core/table.ts index 612d42ca3..1084c8401 100644 --- a/drizzle-orm/src/sqlite-common/table.ts +++ b/drizzle-orm/src/sqlite-core/table.ts @@ -1,8 +1,8 @@ -import { AnyColumn, ColumnConfig, GetColumnData } from 'drizzle-orm'; -import { OptionalKeyOnly, RequiredKeyOnly } from 'drizzle-orm/operations'; -import { Table } from 'drizzle-orm/table'; -import { Update } from 'drizzle-orm/utils'; -import { Simplify } from 'drizzle-orm/utils'; +import { AnyColumn, ColumnConfig, GetColumnData } from '~/column'; +import { OptionalKeyOnly, RequiredKeyOnly } from '~/operations'; +import { Table } from '~/table'; +import { Update } from '~/utils'; +import { Simplify } from '~/utils'; import { Check, CheckBuilder } from './checks'; import { AnySQLiteColumn, AnySQLiteColumnBuilder, BuildColumns } from './columns/common'; diff --git a/drizzle-orm/src/sqlite-common/unique-constraint.ts b/drizzle-orm/src/sqlite-core/unique-constraint.ts similarity index 100% rename from drizzle-orm/src/sqlite-common/unique-constraint.ts rename to drizzle-orm/src/sqlite-core/unique-constraint.ts diff --git a/drizzle-orm/src/sqlite-common/utils.ts b/drizzle-orm/src/sqlite-core/utils.ts similarity index 86% rename from drizzle-orm/src/sqlite-common/utils.ts rename to drizzle-orm/src/sqlite-core/utils.ts index ff86e2b97..1b5d82657 100644 --- a/drizzle-orm/src/sqlite-common/utils.ts +++ b/drizzle-orm/src/sqlite-core/utils.ts @@ -1,9 +1,9 @@ -import { Table } from 'drizzle-orm'; -import { Param, SQL, SQLResponse } from 'drizzle-orm/sql'; -import { SQLiteColumn } from '~/columns'; -import { SelectFieldsOrdered, SQLiteSelectFields } from '~/operations'; -import { SQLiteUpdateSet } from '~/query-builders'; -import { AnySQLiteTable, SQLiteTable } from '~/table'; +import { Param, SQL, SQLResponse } from '~/sql'; +import { SQLiteColumn } from '~/sqlite-core/columns'; +import { SelectFieldsOrdered, SQLiteSelectFields } from '~/sqlite-core/operations'; +import { SQLiteUpdateSet } from '~/sqlite-core/query-builders'; +import { AnySQLiteTable, SQLiteTable } from '~/sqlite-core/table'; +import { Table } from '~/table'; export function getTableColumns(table: TTable) { const columns = table[SQLiteTable.Symbol.Columns]; @@ -50,8 +50,6 @@ export function mapUpdateSet(table: AnySQLiteTable, values: Record = T extends U ? T : U; - export function orderSelectedFields(fields: SQLiteSelectFields, pathPrefix?: string[]): SelectFieldsOrdered { return Object.entries(fields).reduce((result, [name, field]) => { if (typeof name !== 'string') { diff --git a/drizzle-orm/src/utils.ts b/drizzle-orm/src/utils.ts index 98f861b68..24bd13806 100644 --- a/drizzle-orm/src/utils.ts +++ b/drizzle-orm/src/utils.ts @@ -145,3 +145,5 @@ export type Simplify< Options extends SimplifyOptions = {}, > = Flatten extends AnyType ? Flatten : AnyType; + +export type Assume = T extends U ? T : U; diff --git a/drizzle-orm/tsconfig.json b/drizzle-orm/tsconfig.json index 9483f4389..8b4c5ffe6 100644 --- a/drizzle-orm/tsconfig.json +++ b/drizzle-orm/tsconfig.json @@ -8,6 +8,5 @@ "~/*": ["src/*"] } }, - "include": ["src"], - "types": ["bun-types", "@cloudflare/workers-types"] + "include": ["src"] } diff --git a/drizzle-zod/README.md b/drizzle-zod/README.md index b3c1242db..6ee94fff8 100644 --- a/drizzle-zod/README.md +++ b/drizzle-zod/README.md @@ -20,7 +20,7 @@ # Usage ```ts -import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm-pg'; +import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { z } from 'zod'; import { createInsertSchema } from 'drizzle-zod'; diff --git a/drizzle-zod/package.json b/drizzle-zod/package.json index 0fd8effb0..ba770bb49 100644 --- a/drizzle-zod/package.json +++ b/drizzle-zod/package.json @@ -41,14 +41,9 @@ "author": "Drizzle Team", "license": "Apache-2.0", "peerDependencies": { - "drizzle-orm-pg": ">=0.15 <0.16", + "drizzle-orm": ">=0.17", "zod": ">=3 <4" }, - "peerDependenciesMeta": { - "drizzle-orm-pg": { - "optional": true - } - }, "devDependencies": { "ava": "^5.1.0", "drizzle-orm": "link:../drizzle-orm/dist", diff --git a/drizzle-zod/src/pg/index.ts b/drizzle-zod/src/pg/index.ts index 9b9260850..7422d0d9b 100644 --- a/drizzle-zod/src/pg/index.ts +++ b/drizzle-zod/src/pg/index.ts @@ -25,8 +25,8 @@ import { PgTimestamp, PgUUID, PgVarchar, -} from 'drizzle-orm-pg'; -import { getTableColumns } from 'drizzle-orm-pg/utils'; +} from 'drizzle-orm/pg-common'; +import { getTableColumns } from 'drizzle-orm/pg-common/utils'; import { Simplify } from 'drizzle-orm/utils'; import { z } from 'zod'; diff --git a/drizzle-zod/tests/pg.test.ts b/drizzle-zod/tests/pg.test.ts index af893cda5..1a85a9594 100644 --- a/drizzle-zod/tests/pg.test.ts +++ b/drizzle-zod/tests/pg.test.ts @@ -1,5 +1,5 @@ import test, { ExecutionContext } from 'ava'; -import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm-pg'; +import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-common'; import { z } from 'zod'; import { createInsertSchema } from '../src/pg'; diff --git a/examples/bun-sqlite/README.md b/examples/bun-sqlite/README.md index 3910c07f0..d5b3142a0 100644 --- a/examples/bun-sqlite/README.md +++ b/examples/bun-sqlite/README.md @@ -1,6 +1,6 @@ [Drizzle ORM](https://github.com/drizzle-team/drizzle-orm) example with [bun:sqlite](https://bun.sh) module. Blazingly fast ⚡️ ```shell -bun install mitata drizzle-orm drizzle-orm-sqlite +bun install mitata drizzle-orm bun run src/index.ts -``` \ No newline at end of file +``` diff --git a/examples/bun-sqlite/src/index.ts b/examples/bun-sqlite/src/index.ts index b8bbac53c..47f28ca43 100644 --- a/examples/bun-sqlite/src/index.ts +++ b/examples/bun-sqlite/src/index.ts @@ -1,13 +1,13 @@ import { Database } from 'bun:sqlite'; import { sql } from 'drizzle-orm'; -import { alias } from 'drizzle-orm-sqlite'; -import { drizzle } from 'drizzle-orm-sqlite/bun'; +import { drizzle } from 'drizzle-orm/bun-sqlite'; import { asc, eq } from 'drizzle-orm/expressions'; import { placeholder } from 'drizzle-orm/sql'; +import { alias } from 'drizzle-orm/sqlite-core'; import { bench, group, run } from 'mitata'; import { customerIds, customerSearches, employeeIds, orderIds, productSearches } from './meta'; -import { employees, customers, suppliers, products, orders, details } from './schema'; +import { customers, details, employees, orders, products, suppliers } from './schema'; const sqlite = new Database('northwind.db'); const db = drizzle(sqlite); @@ -83,7 +83,7 @@ group({ name: 'drizzle', summary: false }, () => { bench('SELECT * FROM employee WHERE id = ? LEFT JOIN reportee', () => { employeeIds.forEach((id) => { - // due to a known bug https://github.com/oven-sh/bun/issues/1646 + // due to a known bug https://github.com/oven-sh/bun/issues/1646 // d5.all({ employeeId: id }); }); }); @@ -104,7 +104,7 @@ group({ name: 'drizzle', summary: false }, () => { bench('SELECT * FROM order WHERE order_id = ? LEFT JOIN details + products', () => { orderIds.forEach((id) => { - // due to a known bug https://github.com/oven-sh/bun/issues/1646 + // due to a known bug https://github.com/oven-sh/bun/issues/1646 // d9.all({ orderId: id }); }); }); diff --git a/examples/bun-sqlite/src/schema.ts b/examples/bun-sqlite/src/schema.ts index 2cb3dca0c..269ea0e03 100644 --- a/examples/bun-sqlite/src/schema.ts +++ b/examples/bun-sqlite/src/schema.ts @@ -1,104 +1,102 @@ -import { - InferModel, text, foreignKey, integer, sqliteTable, numeric, -} from "drizzle-orm-sqlite"; +import { foreignKey, InferModel, integer, numeric, sqliteTable, text } from 'drizzle-orm/sqlite-core'; -export const customers = sqliteTable("customer", { - id: text("id").primaryKey(), - companyName: text("company_name").notNull(), - contactName: text("contact_name").notNull(), - contactTitle: text("contact_title").notNull(), - address: text("address").notNull(), - city: text("city").notNull(), - postalCode: text("postal_code"), - region: text("region"), - country: text("country").notNull(), - phone: text("phone").notNull(), - fax: text("fax"), +export const customers = sqliteTable('customer', { + id: text('id').primaryKey(), + companyName: text('company_name').notNull(), + contactName: text('contact_name').notNull(), + contactTitle: text('contact_title').notNull(), + address: text('address').notNull(), + city: text('city').notNull(), + postalCode: text('postal_code'), + region: text('region'), + country: text('country').notNull(), + phone: text('phone').notNull(), + fax: text('fax'), }); export type Customer = InferModel; -export const employees = sqliteTable("employee", { - id: integer("id").primaryKey(), - lastName: text("last_name").notNull(), - firstName: text("first_name"), - title: text("title").notNull(), - titleOfCourtesy: text("title_of_courtesy").notNull(), - birthDate: integer("birth_date", { mode: "timestamp" }).notNull(), - hireDate: integer("hire_date", { mode: "timestamp" }).notNull(), - address: text("address").notNull(), - city: text("city").notNull(), - postalCode: text("postal_code").notNull(), - country: text("country").notNull(), - homePhone: text("home_phone").notNull(), - extension: integer("extension").notNull(), - notes: text("notes").notNull(), - reportsTo: integer("reports_to"), - photoPath: text("photo_path"), +export const employees = sqliteTable('employee', { + id: integer('id').primaryKey(), + lastName: text('last_name').notNull(), + firstName: text('first_name'), + title: text('title').notNull(), + titleOfCourtesy: text('title_of_courtesy').notNull(), + birthDate: integer('birth_date', { mode: 'timestamp' }).notNull(), + hireDate: integer('hire_date', { mode: 'timestamp' }).notNull(), + address: text('address').notNull(), + city: text('city').notNull(), + postalCode: text('postal_code').notNull(), + country: text('country').notNull(), + homePhone: text('home_phone').notNull(), + extension: integer('extension').notNull(), + notes: text('notes').notNull(), + reportsTo: integer('reports_to'), + photoPath: text('photo_path'), }, (table) => ({ - reportsToFk: foreignKey(() => ({ - columns: [table.reportsTo], - foreignColumns: [table.id], - })), + reportsToFk: foreignKey(() => ({ + columns: [table.reportsTo], + foreignColumns: [table.id], + })), })); export type Employee = InferModel; -export const orders = sqliteTable("order", { - id: integer("id").primaryKey(), - orderDate: integer("order_date", { mode: "timestamp" }).notNull(), - requiredDate: integer("required_date", { mode: "timestamp" }).notNull(), - shippedDate: integer("shipped_date", { mode: "timestamp" }), - shipVia: integer("ship_via").notNull(), - freight: numeric("freight").notNull(), - shipName: text("ship_name").notNull(), - shipCity: text("ship_city").notNull(), - shipRegion: text("ship_region"), - shipPostalCode: text("ship_postal_code"), - shipCountry: text("ship_country").notNull(), - customerId: text("customer_id").notNull(), - employeeId: integer("employee_id").notNull(), +export const orders = sqliteTable('order', { + id: integer('id').primaryKey(), + orderDate: integer('order_date', { mode: 'timestamp' }).notNull(), + requiredDate: integer('required_date', { mode: 'timestamp' }).notNull(), + shippedDate: integer('shipped_date', { mode: 'timestamp' }), + shipVia: integer('ship_via').notNull(), + freight: numeric('freight').notNull(), + shipName: text('ship_name').notNull(), + shipCity: text('ship_city').notNull(), + shipRegion: text('ship_region'), + shipPostalCode: text('ship_postal_code'), + shipCountry: text('ship_country').notNull(), + customerId: text('customer_id').notNull(), + employeeId: integer('employee_id').notNull(), }); export type Order = InferModel; -export const suppliers = sqliteTable("supplier", { - id: integer("id").primaryKey({ autoIncrement: true }), - companyName: text("company_name").notNull(), - contactName: text("contact_name").notNull(), - contactTitle: text("contact_title").notNull(), - address: text("address").notNull(), - city: text("city").notNull(), - region: text("region"), - postalCode: text("postal_code").notNull(), - country: text("country").notNull(), - phone: text("phone").notNull(), +export const suppliers = sqliteTable('supplier', { + id: integer('id').primaryKey({ autoIncrement: true }), + companyName: text('company_name').notNull(), + contactName: text('contact_name').notNull(), + contactTitle: text('contact_title').notNull(), + address: text('address').notNull(), + city: text('city').notNull(), + region: text('region'), + postalCode: text('postal_code').notNull(), + country: text('country').notNull(), + phone: text('phone').notNull(), }); export type Supplier = InferModel; -export const products = sqliteTable("product", { - id: integer("id").primaryKey({ autoIncrement: true }), - name: text("name").notNull(), - quantityPerUnit: text("quantity_per_unit").notNull(), - unitPrice: numeric("unit_price").notNull(), - unitsInStock: integer("units_in_stock").notNull(), - unitsOnOrder: integer("units_on_order").notNull(), - reorderLevel: integer("reorder_level").notNull(), - discontinued: integer("discontinued").notNull(), +export const products = sqliteTable('product', { + id: integer('id').primaryKey({ autoIncrement: true }), + name: text('name').notNull(), + quantityPerUnit: text('quantity_per_unit').notNull(), + unitPrice: numeric('unit_price').notNull(), + unitsInStock: integer('units_in_stock').notNull(), + unitsOnOrder: integer('units_on_order').notNull(), + reorderLevel: integer('reorder_level').notNull(), + discontinued: integer('discontinued').notNull(), - supplierId: integer("supplier_id").notNull() - .references(() => suppliers.id, { onDelete: "cascade" }), + supplierId: integer('supplier_id').notNull() + .references(() => suppliers.id, { onDelete: 'cascade' }), }); export type Product = InferModel; -export const details = sqliteTable("order_detail", { - unitPrice: numeric("unit_price").notNull(), - quantity: integer("quantity").notNull(), - discount: numeric("discount").notNull(), - orderId: integer("order_id").notNull(), - productId: integer("product_id").notNull(), +export const details = sqliteTable('order_detail', { + unitPrice: numeric('unit_price').notNull(), + quantity: integer('quantity').notNull(), + discount: numeric('discount').notNull(), + orderId: integer('order_id').notNull(), + productId: integer('product_id').notNull(), }); export type Detail = InferModel; diff --git a/examples/cloudflare-d1/README.md b/examples/cloudflare-d1/README.md index c42431224..286c1745f 100644 --- a/examples/cloudflare-d1/README.md +++ b/examples/cloudflare-d1/README.md @@ -1,11 +1,12 @@ -Example project for [Drizzle ORM D1 SQLite package](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-sqlite) +Example project for [Drizzle ORM D1 SQLite package](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm/src/sqlite-core) Subscribe to our updates on [Twitter](https://twitter.com/DrizzleOrm)! ## Initial project setup + To setup project for your Cloudflare D1 - please refer to [official docs](https://developers.cloudflare.com/d1/) ```toml -## your wrangler.toml will loke somthing like this +## your wrangler.toml will look something like this name = "YOU PROJECT NAME" main = "src/index.ts" @@ -19,14 +20,16 @@ database_id = "YOUR DB ID" ``` To init local database and run server locally + ```bash wrangler d1 execute --local --file=./drizzle/20221126113135/migration.sql wrangler dev --local --persist ``` -Install Drizzle ORM and SQLite packages +Install Drizzle ORM + ```bash -npm install drizzle-orm drizzle-orm-sqlite +npm install drizzle-orm ``` To automatically generate migration .sql files, when src/schema.ts chages diff --git a/examples/cloudflare-d1/package.json b/examples/cloudflare-d1/package.json index a5b2dd1f2..11c5c8f43 100644 --- a/examples/cloudflare-d1/package.json +++ b/examples/cloudflare-d1/package.json @@ -19,7 +19,6 @@ }, "dependencies": { "drizzle-orm": "0.14.2", - "drizzle-orm-sqlite": "0.14.2", "itty-router": "^2.6.6", "itty-router-extras": "^0.4.2" } diff --git a/examples/cloudflare-d1/src/index.ts b/examples/cloudflare-d1/src/index.ts index a9b7790e2..5da633fd2 100644 --- a/examples/cloudflare-d1/src/index.ts +++ b/examples/cloudflare-d1/src/index.ts @@ -1,4 +1,4 @@ -import { drizzle, DrizzleD1Database } from 'drizzle-orm-sqlite/d1'; +import { drizzle, DrizzleD1Database } from 'drizzle-orm/d1'; import { eq } from 'drizzle-orm/expressions'; import { Request as IttyRequest, Route, Router } from 'itty-router'; import { json } from 'itty-router-extras'; diff --git a/examples/cloudflare-d1/src/schema.ts b/examples/cloudflare-d1/src/schema.ts index 043664c60..140f5a456 100644 --- a/examples/cloudflare-d1/src/schema.ts +++ b/examples/cloudflare-d1/src/schema.ts @@ -1,4 +1,4 @@ -import { integer, sqliteTable, text } from "drizzle-orm-sqlite"; +import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; export const users = sqliteTable('users', { id: integer('id').primaryKey(), @@ -8,6 +8,6 @@ export const users = sqliteTable('users', { export const statItemAggregation = sqliteTable('StatItemAggregation', { userId: integer('user_id').primaryKey(), - revenue: integer("revenue"), - connectTalkbackTime: integer("connect_talkback_time"), -}); \ No newline at end of file + revenue: integer('revenue'), + connectTalkbackTime: integer('connect_talkback_time'), +}); diff --git a/integration-tests/tests/better-sqlite.test.ts b/integration-tests/tests/better-sqlite.test.ts index d20740268..237c104e5 100644 --- a/integration-tests/tests/better-sqlite.test.ts +++ b/integration-tests/tests/better-sqlite.test.ts @@ -1,13 +1,11 @@ import anyTest, { TestFn } from 'ava'; import Database from 'better-sqlite3'; -import { DefaultLogger, sql } from 'drizzle-orm'; -import { alias, blob, InferModel, integer, primaryKey, sqliteTable, text } from 'drizzle-orm-sqlite'; -import { BetterSQLite3Database, drizzle } from 'drizzle-orm-sqlite/better-sqlite3'; -import { migrate } from 'drizzle-orm-sqlite/better-sqlite3/migrator'; -import { getTableCompositePrimaryKeys } from 'drizzle-orm-sqlite/utils'; +import { sql } from 'drizzle-orm'; +import { BetterSQLite3Database, drizzle } from 'drizzle-orm/better-sqlite3'; +import { migrate } from 'drizzle-orm/better-sqlite3/migrator'; import { asc, eq } from 'drizzle-orm/expressions'; import { name, placeholder } from 'drizzle-orm/sql'; -import { getTableName } from 'drizzle-orm/table'; +import { alias, blob, InferModel, integer, primaryKey, sqliteTable, text } from 'drizzle-orm/sqlite-core'; const usersTable = sqliteTable('users', { id: integer('id').primaryKey(), @@ -34,8 +32,7 @@ const pkExample = sqliteTable('pk_example', { name: text('name').notNull(), email: text('email').notNull(), }, (table) => ({ - compositePk: - primaryKey(table.id, table.name) + compositePk: primaryKey(table.id, table.name), })); interface Context { diff --git a/integration-tests/tests/bun/sqlite-nw.test.ts b/integration-tests/tests/bun/sqlite-nw.test.ts index 373a694e5..fd126184b 100644 --- a/integration-tests/tests/bun/sqlite-nw.test.ts +++ b/integration-tests/tests/bun/sqlite-nw.test.ts @@ -1,9 +1,8 @@ import { Database } from 'bun:sqlite'; import { DefaultLogger, sql } from 'drizzle-orm'; -import { integer, real, SQLiteDatabase, sqliteTable, text } from 'drizzle-orm-sqlite'; -import { SQLiteBunConnector } from 'drizzle-orm-sqlite/bun'; +import { BunSQLiteDatabase, drizzle } from 'drizzle-orm/bun-sqlite'; +import { integer, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; const order = sqliteTable('Order', { id: integer('Id'), @@ -23,8 +22,7 @@ const order = sqliteTable('Order', { }); interface Context { - db: SQLiteDatabase; - client: Database; + db: BunSQLiteDatabase; } const test = suite('sqlite-bun'); @@ -33,8 +31,8 @@ test.before((ctx) => { try { const dbPath = process.env['SQLITE_DB_PATH'] ?? ':memory:'; - ctx.client = new Database(dbPath); - ctx.db = new SQLiteBunConnector(ctx.client, { logger: new DefaultLogger() }).connect(); + const client = new Database(dbPath); + ctx.db = drizzle(client, { logger: new DefaultLogger() }); } catch (e) { console.error(e); } diff --git a/integration-tests/tests/bun/sqlite.test.ts b/integration-tests/tests/bun/sqlite.test.ts index 55e597fc6..0eedfa2f7 100644 --- a/integration-tests/tests/bun/sqlite.test.ts +++ b/integration-tests/tests/bun/sqlite.test.ts @@ -1,7 +1,7 @@ import { Database } from 'bun:sqlite'; import { DefaultLogger, sql } from 'drizzle-orm'; -import { blob, integer, SQLiteDatabase, sqliteTable, text } from 'drizzle-orm-sqlite'; -import { SQLiteBunConnector } from 'drizzle-orm-sqlite/bun'; +import { BunSQLiteDatabase, drizzle } from 'drizzle-orm/bun-sqlite'; +import { blob, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import { suite } from 'uvu'; import * as assert from 'uvu/assert'; @@ -14,8 +14,7 @@ const usersTable = sqliteTable('users', { }); interface Context { - db: SQLiteDatabase; - client: Database; + db: BunSQLiteDatabase; } const test = suite('sqlite-bun'); @@ -24,8 +23,8 @@ test.before((ctx) => { try { const dbPath = process.env['SQLITE_DB_PATH'] ?? ':memory:'; - ctx.client = new Database(dbPath); - ctx.db = new SQLiteBunConnector(ctx.client, { logger: new DefaultLogger() }).connect(); + const client = new Database(dbPath); + ctx.db = drizzle(client, { logger: new DefaultLogger() }); } catch (e) { console.error(e); } diff --git a/integration-tests/tests/mysql-schema.test.ts b/integration-tests/tests/mysql-schema.test.ts index 373e7c2c4..dfb627c72 100644 --- a/integration-tests/tests/mysql-schema.test.ts +++ b/integration-tests/tests/mysql-schema.test.ts @@ -1,31 +1,27 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; +import { asc, eq } from 'drizzle-orm/expressions'; import { + alias, boolean, date, datetime, - foreignKey, - int, json, MySqlDatabase, mysqlEnum, mysqlSchema, mysqlTable, + serial, + text, time, - uniqueIndex, - varchar, + timestamp, year, -} from 'drizzle-orm-mysql'; -import { alias, InferModel, serial, text, timestamp } from 'drizzle-orm-mysql'; -import { drizzle } from 'drizzle-orm-mysql/mysql2'; -import { migrate } from 'drizzle-orm-mysql/mysql2/migrator'; -import { getTableConfig } from 'drizzle-orm-mysql/utils'; -import { asc, eq, inArray } from 'drizzle-orm/expressions'; +} from 'drizzle-orm/mysql-core'; +import { drizzle } from 'drizzle-orm/mysql2'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import * as mysql from 'mysql2/promise'; -import { Client } from 'pg'; import { v4 as uuid } from 'uuid'; const mySchema = mysqlSchema('mySchema'); diff --git a/integration-tests/tests/mysql.custom.test.ts b/integration-tests/tests/mysql.custom.test.ts index 95b7188ae..2cdc758a0 100644 --- a/integration-tests/tests/mysql.custom.test.ts +++ b/integration-tests/tests/mysql.custom.test.ts @@ -1,31 +1,29 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; +import { asc, eq } from 'drizzle-orm/expressions'; import { - boolean, + alias, + customType, date, datetime, - int, - json, MySqlDatabase, mysqlEnum, mysqlTable, + serial, + text, time, uniqueIndex, - varchar, year, - customType -} from 'drizzle-orm-mysql'; -import { alias, InferModel, serial, text, timestamp } from 'drizzle-orm-mysql'; -import { drizzle } from 'drizzle-orm-mysql/mysql2'; -import { migrate } from 'drizzle-orm-mysql/mysql2/migrator'; -import { asc, eq } from 'drizzle-orm/expressions'; +} from 'drizzle-orm/mysql-core'; +import { drizzle } from 'drizzle-orm/mysql2'; +import { migrate } from 'drizzle-orm/mysql2/migrator'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import * as mysql from 'mysql2/promise'; import { v4 as uuid } from 'uuid'; -const customSerial = customType<{ data: number, notNull: true, default: true }>({ +const customSerial = customType<{ data: number; notNull: true; default: true }>({ dataType() { return 'serial'; }, @@ -41,12 +39,12 @@ const customBoolean = customType<{ data: boolean }>({ dataType() { return 'boolean'; }, - fromDriver(value) { - if (typeof value === 'boolean') { + fromDriver(value) { + if (typeof value === 'boolean') { return value; } return value === 1; - }, + }, }); const customJson = (name: string) => @@ -59,9 +57,8 @@ const customJson = (name: string) => }, })(name); - const customTimestamp = customType< - { data: Date; driverData: string; config: { fsp: number; } } + { data: Date; driverData: string; config: { fsp: number } } >({ dataType(config) { const precision = typeof config.fsp !== 'undefined' ? ` (${config.fsp})` : ''; diff --git a/integration-tests/tests/mysql.test.ts b/integration-tests/tests/mysql.test.ts index f03c6eac2..2a1093364 100644 --- a/integration-tests/tests/mysql.test.ts +++ b/integration-tests/tests/mysql.test.ts @@ -1,7 +1,9 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; +import { asc, eq } from 'drizzle-orm/expressions'; import { + alias, boolean, date, datetime, @@ -9,14 +11,15 @@ import { MySqlDatabase, mysqlEnum, mysqlTable, + serial, + text, time, + timestamp, uniqueIndex, year, -} from 'drizzle-orm-mysql'; -import { alias, serial, text, timestamp } from 'drizzle-orm-mysql'; -import { drizzle } from 'drizzle-orm-mysql/mysql2'; -import { migrate } from 'drizzle-orm-mysql/mysql2/migrator'; -import { asc, eq } from 'drizzle-orm/expressions'; +} from 'drizzle-orm/mysql-core'; +import { drizzle } from 'drizzle-orm/mysql2'; +import { migrate } from 'drizzle-orm/mysql2/migrator'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import * as mysql from 'mysql2/promise'; diff --git a/integration-tests/tests/pg-schema.test.ts b/integration-tests/tests/pg-schema.test.ts index da09b947b..ff13df117 100644 --- a/integration-tests/tests/pg-schema.test.ts +++ b/integration-tests/tests/pg-schema.test.ts @@ -1,9 +1,9 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; -import { alias, boolean, InferModel, jsonb, pgSchema, pgTable, serial, text, timestamp } from 'drizzle-orm-pg'; -import { drizzle, NodePgDatabase } from 'drizzle-orm-pg/node'; import { asc, eq } from 'drizzle-orm/expressions'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; +import { alias, boolean, InferModel, jsonb, pgSchema, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import { Client } from 'pg'; diff --git a/integration-tests/tests/pg.custom.test.ts b/integration-tests/tests/pg.custom.test.ts index c0ed6d82d..90c333fb4 100644 --- a/integration-tests/tests/pg.custom.test.ts +++ b/integration-tests/tests/pg.custom.test.ts @@ -1,33 +1,16 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; -import { - alias, - boolean, - customType, - foreignKey, - InferModel, - integer, - isPgSchema, - jsonb, - PgDatabase, - pgSchema, - pgTable, - serial, - text, - timestamp, - uniqueIndex, -} from 'drizzle-orm-pg'; -import { drizzle, NodePgDatabase } from 'drizzle-orm-pg/node'; -import { migrate } from 'drizzle-orm-pg/node/migrator'; -import { getTableConfig } from 'drizzle-orm-pg/utils'; import { asc, eq } from 'drizzle-orm/expressions'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; +import { migrate } from 'drizzle-orm/node-pg/migrator'; +import { alias, customType, InferModel, pgTable, serial, text } from 'drizzle-orm/pg-core'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import { Client } from 'pg'; import { v4 as uuid } from 'uuid'; -const customSerial = customType<{ data: number, notNull: true, default: true }>({ +const customSerial = customType<{ data: number; notNull: true; default: true }>({ dataType() { return 'serial'; }, @@ -55,7 +38,6 @@ const customJsonb = (name: string) => }, })(name); - const customTimestamp = customType< { data: Date; driverData: string; config: { withTimezone: boolean; precision?: number } } >({ diff --git a/integration-tests/tests/pg.test.ts b/integration-tests/tests/pg.test.ts index 0977a5d85..dd0bd6e00 100644 --- a/integration-tests/tests/pg.test.ts +++ b/integration-tests/tests/pg.test.ts @@ -1,10 +1,10 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; -import { alias, boolean, InferModel, jsonb, pgTable, serial, text, timestamp } from 'drizzle-orm-pg'; -import { drizzle, NodePgDatabase } from 'drizzle-orm-pg/node'; -import { migrate } from 'drizzle-orm-pg/node/migrator'; import { asc, eq } from 'drizzle-orm/expressions'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; +import { migrate } from 'drizzle-orm/node-pg/migrator'; +import { alias, boolean, InferModel, jsonb, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import { Client } from 'pg'; diff --git a/integration-tests/tests/postgres.js.test.ts b/integration-tests/tests/postgres.js.test.ts index 2335258a2..5000c0b7a 100644 --- a/integration-tests/tests/postgres.js.test.ts +++ b/integration-tests/tests/postgres.js.test.ts @@ -1,10 +1,10 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; -import { alias, boolean, InferModel, jsonb, pgTable, serial, text, timestamp } from 'drizzle-orm-pg'; -import { drizzle, PostgresJsDatabase } from 'drizzle-orm-pg/postgres.js'; -import { migrate } from 'drizzle-orm-pg/postgres.js/migrator'; import { asc, eq } from 'drizzle-orm/expressions'; +import { alias, boolean, InferModel, jsonb, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; +import { drizzle, PostgresJsDatabase } from 'drizzle-orm/postgres.js'; +import { migrate } from 'drizzle-orm/postgres.js/migrator'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; import postgres, { Sql } from 'postgres'; diff --git a/integration-tests/tests/sql.js.test.ts b/integration-tests/tests/sql.js.test.ts index 0e411fad2..74b7d66b4 100644 --- a/integration-tests/tests/sql.js.test.ts +++ b/integration-tests/tests/sql.js.test.ts @@ -1,10 +1,10 @@ import anyTest, { TestFn } from 'ava'; import { sql } from 'drizzle-orm'; -import { alias, blob, InferModel, integer, primaryKey, sqliteTable, text } from 'drizzle-orm-sqlite'; -import { drizzle, SQLJsDatabase } from 'drizzle-orm-sqlite/sql.js'; -import { migrate } from 'drizzle-orm-sqlite/sql.js/migrator'; import { asc, eq } from 'drizzle-orm/expressions'; import { name, placeholder } from 'drizzle-orm/sql'; +import { drizzle, SQLJsDatabase } from 'drizzle-orm/sql.js'; +import { migrate } from 'drizzle-orm/sql.js/migrator'; +import { alias, blob, InferModel, integer, primaryKey, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import initSqlJs, { Database } from 'sql.js'; const usersTable = sqliteTable('users', { diff --git a/package.json b/package.json index 5c27f6ef0..54d43a5d0 100755 --- a/package.json +++ b/package.json @@ -1,10 +1,7 @@ { "private": true, "scripts": { - "build:core": "turbo run build --filter drizzle-orm", - "build:pg": "turbo run build --filter drizzle-orm-pg", - "build:mysql": "turbo run build --filter drizzle-orm-mysql", - "build:sqlite": "turbo run build --filter drizzle-orm-sqlite", + "build:orm": "turbo run build --filter drizzle-orm", "build": "turbo run build test:types --color", "pack": "turbo run pack --color", "test": "turbo run test --color" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 015f5a85c..378e5ddef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,9 +29,33 @@ importers: drizzle-orm: specifiers: + '@cloudflare/workers-types': ^3.18.0 + '@neondatabase/serverless': ^0.1.13 + '@types/better-sqlite3': ^7.6.2 '@types/node': ^18.11.9 + '@types/pg': ^8.6.5 + '@types/sql.js': ^1.4.4 + better-sqlite3: ^7.6.2 + bun-types: ^0.5.0 + mysql2: ^2.3.3 + pg: ^8.8.0 + postgres: ^3.3.3 + sql.js: ^1.8.0 + sqlite3: ^5.1.2 devDependencies: + '@cloudflare/workers-types': 3.18.0 + '@neondatabase/serverless': 0.1.13 + '@types/better-sqlite3': 7.6.3 '@types/node': 18.11.18 + '@types/pg': 8.6.6 + '@types/sql.js': 1.4.4 + better-sqlite3: 7.6.2 + bun-types: 0.5.0 + mysql2: 2.3.3 + pg: 8.8.0 + postgres: 3.3.3 + sql.js: 1.8.0 + sqlite3: 5.1.4 drizzle-orm-mysql: specifiers: @@ -1200,6 +1224,10 @@ packages: resolution: {integrity: sha512-/1IPC/PPWvV39I7uulBcWHL0Xpi1BqvwF34R/2gRwt0/l5MJB1gt15GLwLP33d59EnkOdRYibImuCg0l/9BRng==} dev: true + /bun-types/0.5.0: + resolution: {integrity: sha512-W74XkTKdOP2HV1PbzL7k6+8TZlcJyj1IuD7y9wX2SiHIaVjlqVwM9fXgsCvTlQQqkkkyZxSPSDFF10J6qml2eA==} + dev: true + /busboy/1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index dcbc1fe3e..dc1c084bc 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,9 +1,6 @@ prefer-workspace-packages: true packages: - drizzle-orm - - drizzle-orm-pg - - drizzle-orm-mysql - - drizzle-orm-sqlite - drizzle-zod - integration-tests - examples/cloudflare-d1 From 4e99516eda7d897f15f323e376811cdd74144268 Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Wed, 25 Jan 2023 14:14:06 +0100 Subject: [PATCH 3/8] Update pnpm-lock.yaml --- pnpm-lock.yaml | 87 +++----------------------------------------------- 1 file changed, 4 insertions(+), 83 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 378e5ddef..e8d21e229 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,63 +57,15 @@ importers: sql.js: 1.8.0 sqlite3: 5.1.4 - drizzle-orm-mysql: - specifiers: - '@types/node': ^18.11.12 - drizzle-orm: link:../drizzle-orm/dist - mysql2: ^2.3.3 - devDependencies: - '@types/node': 18.11.18 - drizzle-orm: link:../drizzle-orm/dist - mysql2: 2.3.3 - - drizzle-orm-pg: - specifiers: - '@neondatabase/serverless': ^0.1.13 - '@types/pg': ^8.6.5 - drizzle-orm: link:../drizzle-orm/dist - pg: ^8.8.0 - postgres: ^3.3.3 - devDependencies: - '@neondatabase/serverless': 0.1.13 - '@types/pg': 8.6.6 - drizzle-orm: link:../drizzle-orm/dist - pg: 8.8.0 - postgres: 3.3.3 - - drizzle-orm-sqlite: - specifiers: - '@cloudflare/workers-types': ^3.18.0 - '@types/better-sqlite3': ^7.6.2 - '@types/sql.js': ^1.4.4 - better-sqlite3: ^7.6.2 - drizzle-orm: link:../drizzle-orm/dist - sql.js: ^1.8.0 - sqlite3: ^5.1.2 - devDependencies: - '@cloudflare/workers-types': 3.18.0 - '@types/better-sqlite3': 7.6.3 - '@types/sql.js': 1.4.4 - better-sqlite3: 7.6.2 - drizzle-orm: link:../drizzle-orm/dist - sql.js: 1.8.0 - sqlite3: 5.1.4 - drizzle-zod: specifiers: ava: ^5.1.0 drizzle-orm: link:../drizzle-orm/dist - drizzle-orm-mysql: link:../drizzle-orm-mysql/dist - drizzle-orm-pg: link:../drizzle-orm-pg/dist - drizzle-orm-sqlite: link:../drizzle-orm-sqlite/dist tsx: ^3.12.2 zod: ^3.20.2 devDependencies: ava: 5.1.1 drizzle-orm: link:../drizzle-orm/dist - drizzle-orm-mysql: link:../drizzle-orm-mysql/dist - drizzle-orm-pg: link:../drizzle-orm-pg/dist - drizzle-orm-sqlite: link:../drizzle-orm-sqlite/dist tsx: 3.12.2 zod: 3.20.2 @@ -124,14 +76,12 @@ importers: better-sqlite3: ^8.0.0 drizzle-kit: ^0.12.18 drizzle-orm: 0.14.2 - drizzle-orm-sqlite: 0.14.2 itty-router: ^2.6.6 itty-router-extras: ^0.4.2 typescript: ^4.9.3 wrangler: ^2.4.2 dependencies: - drizzle-orm: 0.14.2_drizzle-orm-sqlite@0.14.2 - drizzle-orm-sqlite: 0.14.2_zlc2hznpyo77b3lwadvfeyduza + drizzle-orm: 0.14.2 itty-router: 2.6.6 itty-router-extras: 0.4.2 devDependencies: @@ -154,9 +104,6 @@ importers: better-sqlite3: ^7.6.2 dockerode: ^3.3.4 drizzle-orm: workspace:../drizzle-orm/dist - drizzle-orm-mysql: workspace:../drizzle-orm-mysql/dist - drizzle-orm-pg: workspace:../drizzle-orm-pg/dist - drizzle-orm-sqlite: workspace:../drizzle-orm-sqlite/dist get-port: ^6.1.2 mysql2: ^2.3.3 pg: ^8.8.0 @@ -170,9 +117,6 @@ importers: better-sqlite3: 7.6.2 dockerode: 3.3.4 drizzle-orm: link:../drizzle-orm/dist - drizzle-orm-mysql: link:../drizzle-orm-mysql/dist - drizzle-orm-pg: link:../drizzle-orm-pg/dist - drizzle-orm-sqlite: link:../drizzle-orm-sqlite/dist get-port: 6.1.2 mysql2: 2.3.3 pg: 8.8.0 @@ -450,6 +394,7 @@ packages: /@cloudflare/workers-types/3.18.0: resolution: {integrity: sha512-ehKOJVLMeR+tZkYhWEaLYQxl0TaIZu/kE86HF3/RidR8Xv5LuQxpbh+XXAoKVqsaphWLhIgBhgnlN5HGdheXSQ==} + dev: true /@esbuild-kit/cjs-loader/2.4.1: resolution: {integrity: sha512-lhc/XLith28QdW0HpHZvZKkorWgmCNT7sVelMHDj3HFdTfdqkwEKvT+aXVQtNAmCC39VJhunDkWhONWB7335mg==} @@ -1140,6 +1085,7 @@ packages: dependencies: bindings: 1.5.0 prebuild-install: 7.1.1 + dev: true /binary-extensions/2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} @@ -1656,30 +1602,7 @@ packages: - supports-color dev: true - /drizzle-orm-sqlite/0.14.2_zlc2hznpyo77b3lwadvfeyduza: - resolution: {integrity: sha512-q5lB0A2rHLNEkBK5ROj/y9hB1e7cCB7aPQ8borFdl4oBwDkWtEpy90FCa/nWv/dUx5SQ0gaoT1hEL4G30FWQnA==} - peerDependencies: - '@cloudflare/workers-types': '>=3 <4' - '@types/better-sqlite3': '>=7 <9' - better-sqlite3: '>=7 <9' - drizzle-orm: '>=0.14 <0.15' - sqlite3: '>=5 <6' - peerDependenciesMeta: - '@cloudflare/workers-types': - optional: true - '@types/better-sqlite3': - optional: true - better-sqlite3: - optional: true - sqlite3: - optional: true - dependencies: - '@cloudflare/workers-types': 3.18.0 - better-sqlite3: 8.0.1 - drizzle-orm: 0.14.2_drizzle-orm-sqlite@0.14.2 - dev: false - - /drizzle-orm/0.14.2_drizzle-orm-sqlite@0.14.2: + /drizzle-orm/0.14.2: resolution: {integrity: sha512-5eUH81oXQ1GCpsEDPlX3LqX5RzDuO3uWp50yEKMb5GYyWkA0t5gBbMxpIdjYoxeP3xv4g+IkhlTuxXkK/70/5g==} peerDependencies: drizzle-orm-mysql: '>=0.14 <0.15' @@ -1692,8 +1615,6 @@ packages: optional: true drizzle-orm-sqlite: optional: true - dependencies: - drizzle-orm-sqlite: 0.14.2_zlc2hznpyo77b3lwadvfeyduza dev: false /eastasianwidth/0.2.0: From 3b51c024fe4db79dbad1d99301563070770e6dfa Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Wed, 25 Jan 2023 14:24:46 +0100 Subject: [PATCH 4/8] Fix import paths --- drizzle-zod/src/pg/index.ts | 4 ++-- drizzle-zod/tests/pg.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drizzle-zod/src/pg/index.ts b/drizzle-zod/src/pg/index.ts index 7422d0d9b..14a392f4d 100644 --- a/drizzle-zod/src/pg/index.ts +++ b/drizzle-zod/src/pg/index.ts @@ -25,8 +25,8 @@ import { PgTimestamp, PgUUID, PgVarchar, -} from 'drizzle-orm/pg-common'; -import { getTableColumns } from 'drizzle-orm/pg-common/utils'; +} from 'drizzle-orm/pg-core'; +import { getTableColumns } from 'drizzle-orm/pg-core/utils'; import { Simplify } from 'drizzle-orm/utils'; import { z } from 'zod'; diff --git a/drizzle-zod/tests/pg.test.ts b/drizzle-zod/tests/pg.test.ts index 1a85a9594..0d1205680 100644 --- a/drizzle-zod/tests/pg.test.ts +++ b/drizzle-zod/tests/pg.test.ts @@ -1,5 +1,5 @@ import test, { ExecutionContext } from 'ava'; -import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-common'; +import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { z } from 'zod'; import { createInsertSchema } from '../src/pg'; From 7d6e6662ff5b2976a2546a07cde17ed2da85c716 Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Thu, 26 Jan 2023 13:52:37 +0100 Subject: [PATCH 5/8] Rename neon to neon-serverless, fix release pipeline --- .github/workflows/release-latest.yaml | 73 ++++++++++++------- .../src/{neon => neon-serverless}/driver.ts | 0 .../src/{neon => neon-serverless}/index.ts | 0 .../src/{neon => neon-serverless}/migrator.ts | 0 .../src/{neon => neon-serverless}/session.ts | 0 drizzle-zod/README.md | 2 +- integration-tests/tests/pg-schema.test.ts | 2 +- integration-tests/tests/pg.custom.test.ts | 4 +- integration-tests/tests/pg.test.ts | 4 +- 9 files changed, 53 insertions(+), 32 deletions(-) rename drizzle-orm/src/{neon => neon-serverless}/driver.ts (100%) rename drizzle-orm/src/{neon => neon-serverless}/index.ts (100%) rename drizzle-orm/src/{neon => neon-serverless}/migrator.ts (100%) rename drizzle-orm/src/{neon => neon-serverless}/session.ts (100%) diff --git a/.github/workflows/release-latest.yaml b/.github/workflows/release-latest.yaml index b90002870..1c311f880 100644 --- a/.github/workflows/release-latest.yaml +++ b/.github/workflows/release-latest.yaml @@ -4,7 +4,9 @@ on: workflow_dispatch jobs: release: + permissions: write-all strategy: + fail-fast: false matrix: package: - drizzle-orm @@ -23,7 +25,10 @@ jobs: version: latest run_install: true - - name: Publish + - name: Check preconditions + id: checks + shell: bash + working-directory: ${{ matrix.package }} run: | latest="$(npm view --json ${{ matrix.package }} dist-tags.latest | jq -r)" version="$(jq -r .version package.json)" @@ -32,33 +37,49 @@ jobs: echo "Latest: $latest" echo "Current: $version" - is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')" - if [[ "$is_version_published" == "true" ]]; then - echo "Version $version already published, adding tag $tag" - npm dist-tag add ${{ matrix.package }}@$version latest - else - echo echo "Publishing ${{ matrix.package }}@$version" - (cd .. && npm run pack -- --filter ${{ matrix.package }}) - npm run publish + changelogPath=$(node -e "console.log(require('path').resolve('..', 'changelogs', '${{ matrix.package }}', '$version.md'))") + if [[ ! -f "$changelogPath" ]]; then + echo "::error::Changelog for version $version not found: $changelogPath" + exit 1 fi - # Post release message to Discord - curl -X POST -H "Content-Type: application/json" -d "{\"embeds\": [{\"title\": \"New \`${{ matrix.package }}\` release! 🎉\", \"url\": \"https://www.npmjs.com/package/${{ matrix.package }}\", \"color\": \"12907856\", \"fields\": [{\"name\": \"Tag\", \"value\": \"\`$tag\`\"}]}]}" ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }} - - # Put version to outputs - echo "::set-output name=version::$version" - echo "::set-output name=has_new_release::true" + { + echo "version=$version" + echo "has_new_release=true" + echo "changelog_path=$changelogPath" + } >> $GITHUB_OUTPUT else echo "Already up to date: $version" + echo "\`$version\` is already latest on NPM" >> $GITHUB_STEP_SUMMARY fi + + - name: Publish + if: steps.checks.outputs.has_new_release == 'true' working-directory: ${{ matrix.package }} shell: bash env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + run: | + version="${{ steps.checks.outputs.version }}" + is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')" - - name: Create GitHub release + if [[ "$is_version_published" == "true" ]]; then + echo "Version $version already published, adding tag $tag" + npm dist-tag add ${{ matrix.package }}@$version latest + else + echo echo "Publishing ${{ matrix.package }}@$version" + (cd .. && npm run pack -- --filter ${{ matrix.package }}) + npm run publish + fi + + echo "npm: \`+ ${{ matrix.package }}@$version\`" >> $GITHUB_STEP_SUMMARY + + # Post release message to Discord + curl -X POST -H "Content-Type: application/json" -d "{\"embeds\": [{\"title\": \"New \`${{ matrix.package }}\` release! 🎉\", \"url\": \"https://www.npmjs.com/package/${{ matrix.package }}\", \"color\": \"12907856\", \"fields\": [{\"name\": \"Tag\", \"value\": \"\`$tag\`\"}]}]}" ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }} + + - name: Create GitHub release for ORM package uses: actions/github-script@v6 - if: ${{ steps.release.outputs.has_new_release == 'true' }} + if: matrix.package == 'drizzle-orm' && steps.checks.outputs.has_new_release == 'true' with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -66,24 +87,24 @@ jobs: const fs = require("fs"); const path = require("path"); - const changelog = fs.readFileSync(path.join(__dirname, "changelogs", "${{ matrix.package }}", "${{ steps.release.outputs.version }}.md"), "utf8"); - const version = "${{ steps.release.outputs.version }}"; - const tag = "latest"; + const version = "${{ steps.checks.outputs.version }}"; + const changelog = fs.readFileSync("${{ steps.checks.outputs.changelog_path }}", "utf8"); + const release = await github.rest.repos.createRelease({ owner: context.repo.owner, repo: context.repo.repo, - tag_name: tag, - name: `${{ matrix.package }} v${version}`, + tag_name: `${version}`, + name: `${version}`, body: changelog, - draft: true, }); + await github.rest.repos.uploadReleaseAsset({ owner: context.repo.owner, repo: context.repo.repo, release_id: release.data.id, - name: `${{ matrix.package }}-${version}.tgz`, - data: fs.readFileSync(path.join(__dirname, "${{ matrix.package }}", "package.tgz")), + name: `${{ matrix.package }}-${version}-dist.tgz`, + data: fs.readFileSync(path.resolve("${{ matrix.package }}", "package.tgz")), }); } catch (e) { - core.setFailed(error.message); + core.setFailed(e.message); } diff --git a/drizzle-orm/src/neon/driver.ts b/drizzle-orm/src/neon-serverless/driver.ts similarity index 100% rename from drizzle-orm/src/neon/driver.ts rename to drizzle-orm/src/neon-serverless/driver.ts diff --git a/drizzle-orm/src/neon/index.ts b/drizzle-orm/src/neon-serverless/index.ts similarity index 100% rename from drizzle-orm/src/neon/index.ts rename to drizzle-orm/src/neon-serverless/index.ts diff --git a/drizzle-orm/src/neon/migrator.ts b/drizzle-orm/src/neon-serverless/migrator.ts similarity index 100% rename from drizzle-orm/src/neon/migrator.ts rename to drizzle-orm/src/neon-serverless/migrator.ts diff --git a/drizzle-orm/src/neon/session.ts b/drizzle-orm/src/neon-serverless/session.ts similarity index 100% rename from drizzle-orm/src/neon/session.ts rename to drizzle-orm/src/neon-serverless/session.ts diff --git a/drizzle-zod/README.md b/drizzle-zod/README.md index 6ee94fff8..615cda3ee 100644 --- a/drizzle-zod/README.md +++ b/drizzle-zod/README.md @@ -22,7 +22,7 @@ ```ts import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { z } from 'zod'; -import { createInsertSchema } from 'drizzle-zod'; +import { createInsertSchema } from 'drizzle-zod/pg'; const users = pgTable('users', { id: serial('id').primaryKey(), diff --git a/integration-tests/tests/pg-schema.test.ts b/integration-tests/tests/pg-schema.test.ts index ff13df117..69bd48d77 100644 --- a/integration-tests/tests/pg-schema.test.ts +++ b/integration-tests/tests/pg-schema.test.ts @@ -2,7 +2,7 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; import { asc, eq } from 'drizzle-orm/expressions'; -import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-postgres'; import { alias, boolean, InferModel, jsonb, pgSchema, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; diff --git a/integration-tests/tests/pg.custom.test.ts b/integration-tests/tests/pg.custom.test.ts index 90c333fb4..3edf0d81c 100644 --- a/integration-tests/tests/pg.custom.test.ts +++ b/integration-tests/tests/pg.custom.test.ts @@ -2,8 +2,8 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; import { asc, eq } from 'drizzle-orm/expressions'; -import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; -import { migrate } from 'drizzle-orm/node-pg/migrator'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-postgres'; +import { migrate } from 'drizzle-orm/node-postgres/migrator'; import { alias, customType, InferModel, pgTable, serial, text } from 'drizzle-orm/pg-core'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; diff --git a/integration-tests/tests/pg.test.ts b/integration-tests/tests/pg.test.ts index dd0bd6e00..e970371c6 100644 --- a/integration-tests/tests/pg.test.ts +++ b/integration-tests/tests/pg.test.ts @@ -2,8 +2,8 @@ import anyTest, { TestFn } from 'ava'; import Docker from 'dockerode'; import { sql } from 'drizzle-orm'; import { asc, eq } from 'drizzle-orm/expressions'; -import { drizzle, NodePgDatabase } from 'drizzle-orm/node-pg'; -import { migrate } from 'drizzle-orm/node-pg/migrator'; +import { drizzle, NodePgDatabase } from 'drizzle-orm/node-postgres'; +import { migrate } from 'drizzle-orm/node-postgres/migrator'; import { alias, boolean, InferModel, jsonb, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; import { name, placeholder } from 'drizzle-orm/sql'; import getPort from 'get-port'; From 76e4d7c7405e80d77d788c994734c3a2bfffdb19 Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Thu, 26 Jan 2023 14:49:19 +0100 Subject: [PATCH 6/8] Rename apiVersion to compatibilityVersion --- drizzle-orm/src/utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drizzle-orm/src/utils.ts b/drizzle-orm/src/utils.ts index 24bd13806..fd62696e3 100644 --- a/drizzle-orm/src/utils.ts +++ b/drizzle-orm/src/utils.ts @@ -2,8 +2,13 @@ import { Column } from './column'; import { SelectFieldsOrdered } from './operations'; import { DriverValueDecoder, noopDecoder, SQL } from './sql'; -export const apiVersion: number = 1; -export const npmVersion: string = '0.15.0'; +/** + * @deprecated + * Use `compatibilityVersion` instead. + */ +export const apiVersion = 2; +export const compatibilityVersion = 2; +export const npmVersion = '0.15.0'; export function mapResultRow( columns: SelectFieldsOrdered, From 81e00177d3be3ef0be2c6e2f5509a786e29d585a Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Thu, 26 Jan 2023 14:50:25 +0100 Subject: [PATCH 7/8] Deprecate npmVersion --- drizzle-orm/src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drizzle-orm/src/utils.ts b/drizzle-orm/src/utils.ts index fd62696e3..3825b355f 100644 --- a/drizzle-orm/src/utils.ts +++ b/drizzle-orm/src/utils.ts @@ -8,6 +8,10 @@ import { DriverValueDecoder, noopDecoder, SQL } from './sql'; */ export const apiVersion = 2; export const compatibilityVersion = 2; +/** + * @deprecated + * Use version from `package.json` instead. + */ export const npmVersion = '0.15.0'; export function mapResultRow( From a4e41dda0baeff6909bc29918ddfa43a77411c73 Mon Sep 17 00:00:00 2001 From: Dan Kochetov Date: Thu, 26 Jan 2023 15:33:46 +0100 Subject: [PATCH 8/8] Move versions to drizzle-orm/version --- drizzle-orm/src/utils.ts | 7 +++---- drizzle-orm/src/version.ts | 2 ++ integration-tests/package.json | 3 ++- integration-tests/tests/version.test.ts | 11 +++++++++++ pnpm-lock.yaml | 3 ++- 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 drizzle-orm/src/version.ts create mode 100644 integration-tests/tests/version.test.ts diff --git a/drizzle-orm/src/utils.ts b/drizzle-orm/src/utils.ts index 3825b355f..988d9ea62 100644 --- a/drizzle-orm/src/utils.ts +++ b/drizzle-orm/src/utils.ts @@ -4,15 +4,14 @@ import { DriverValueDecoder, noopDecoder, SQL } from './sql'; /** * @deprecated - * Use `compatibilityVersion` instead. + * Use `compatibilityVersion` from `drizzle-orm/version` instead. */ export const apiVersion = 2; -export const compatibilityVersion = 2; /** * @deprecated - * Use version from `package.json` instead. + * Use `npmVersion` from `drizzle-orm/version` instead. */ -export const npmVersion = '0.15.0'; +export const npmVersion = '0.17.0'; export function mapResultRow( columns: SelectFieldsOrdered, diff --git a/drizzle-orm/src/version.ts b/drizzle-orm/src/version.ts new file mode 100644 index 000000000..4f341c35d --- /dev/null +++ b/drizzle-orm/src/version.ts @@ -0,0 +1,2 @@ +export const compatibilityVersion = 2; +export const npmVersion: string = require('../package.json').version; diff --git a/integration-tests/package.json b/integration-tests/package.json index b228dbcef..b5499224a 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -43,6 +43,7 @@ "sql.js": "^1.8.0", "sqlite3": "^5.1.4", "uuid": "^9.0.0", - "uvu": "^0.5.6" + "uvu": "^0.5.6", + "zod": "^3.20.2" } } diff --git a/integration-tests/tests/version.test.ts b/integration-tests/tests/version.test.ts new file mode 100644 index 000000000..78d95c5c8 --- /dev/null +++ b/integration-tests/tests/version.test.ts @@ -0,0 +1,11 @@ +import test from 'ava'; +import * as version from 'drizzle-orm/version'; +import { z } from 'zod'; + +test('shape', (t) => { + const shape = z.object({ + compatibilityVersion: z.number(), + npmVersion: z.string(), + }); + t.notThrows(() => shape.parse(version)); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e8d21e229..39438a9a3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,6 +113,7 @@ importers: tsx: ^3.12.2 uuid: ^9.0.0 uvu: ^0.5.6 + zod: ^3.20.2 dependencies: better-sqlite3: 7.6.2 dockerode: 3.3.4 @@ -125,6 +126,7 @@ importers: sqlite3: 5.1.4 uuid: 9.0.0 uvu: 0.5.6 + zod: 3.20.2 devDependencies: '@types/better-sqlite3': 7.6.3 '@types/dockerode': 3.3.14 @@ -4126,4 +4128,3 @@ packages: /zod/3.20.2: resolution: {integrity: sha512-1MzNQdAvO+54H+EaK5YpyEy0T+Ejo/7YLHS93G3RnYWh5gaotGHwGeN/ZO687qEDU2y4CdStQYXVHIgrUl5UVQ==} - dev: true