Drizzle Kit 0.19.0
Breaking changes
drizzle.config.*
file now have a different structure for defining database connection and driver to use. For more about all changes check New Features
section
Previously
export default {
schema: "./schema.ts",
out: "./drizzle",
connectionString: '',
} satisfies Config;
Now
import { Config } from "drizzle-kit";
export default {
schema: "./schema.ts",
out: "./drizzle",
driver: "mysql2",
dbCredentials: {
connectionString: ''
},
} satisfies Config;
New Features
ESM support for drizzle-kit 🎉
Drizzle Kit can now be used in both ESM and CommonJS environments.
Config file changes 🎉
- New parameter
driver
allows you to choose the driver with which you want to executeintrospect
andpush
statements to the database
Usage
{
driver: "mysql2", // 'pg' | 'mysql2' | 'better-sqlite' | 'libsql' | 'turso'
dbCredentials: {
// Driver specific connection values
},
}
- New parameters
verbose
andstrict
have been added for thedrizzle-kit push
commands.
verbose
is responsible for printing all statements that the push
command will execute.
strict
will always ask for your approval before pushing a schema, even if those statements do not pose a risk of data loss
Usage
{
verbose: true,
strict: true
}
- New parameter
introspect.casing
has been introduced to allow you to choose a strategy for thedrizzle-kit introspect
command when creating JS object keys from database column names
Usage
{
introspect: {
casing: 'preserve' // 'camel' | 'preserve'. Default: 'camel'
}
}
New command drizzle-kit introspect:sqlite
🎉
You can create a database schema from an existing SQLite database by running drizzle-kit introspect:sqlite
. This command will generate a schema.ts
file and the initial migration for your database.
Config file for introspect
export default {
out: "./drizzle",
driver: "turso",
dbCredentials: {
url: '',
authToken: ''
},
introspect: {
casing: 'camel', // optional
}
} satisfies Config;
New command drizzle-kit push:sqlite
🎉
You can now prototype your schema even faster, without the need of creating migration files each time you need to check the new database structure for a new feature in your app. You can simply run drizzle-kit push:sqlite
and your schema will be synced with a database.
You can even run those on a Turso Database directly
Config file for introspect
export default {
schema: "./schema.ts",
driver: "turso",
dbCredentials: {
url: '',
authToken: ''
},
verbose: true,
strict: true,
} satisfies Config;
To obtain more information about the SQLite push command, you can refer to a blog post that features the Turso + Drizzle push flow.
Bug fixes
- Move
check:mysql
back to available commands - Add proper error messages and checks for cli+config collisions
- Fix
drizzle-kit drop
command with 0 entries in journal error - Add error if database was not specified for mysql connection
- Add
tableFilters
support tointrospect:pg
,introspect:mysql
,introspect:sqlite
. Closing #70 - Fix PostgreSQL: generated ALTER TABLE incorrectly adds schema on rename
- Fix Error while pushing changes
- Fix Typescript and ESM not working together
- Fix Cannot find module "drizzle-orm/version"
- Fix PG Migrations using Schemas
- Fix Cannot use import statement outside a module when using a TypeScript config file
- Add support for Feature request: option to match generated column name case to db column name
- Fix Generate:mysql command produces a migration file name with a directory separator
- Fix Postgres Enums not double quoted when used