github drizzle-team/drizzle-kit-mirror v0.19.0
0.19.0

latest releases: v0.23.1, v0.23.0, v0.22.8...
15 months ago

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 🎉

  1. New parameter driver allows you to choose the driver with which you want to execute introspect and push statements to the database

Usage

{
  driver: "mysql2", // 'pg' | 'mysql2' | 'better-sqlite' | 'libsql' | 'turso'
  dbCredentials: {
    // Driver specific connection values
  },
}
  1. New parameters verbose and strict have been added for the drizzle-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
}
  1. New parameter introspect.casing has been introduced to allow you to choose a strategy for the drizzle-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

  1. Move check:mysql back to available commands
  2. Add proper error messages and checks for cli+config collisions
  3. Fix drizzle-kit drop command with 0 entries in journal error
  4. Add error if database was not specified for mysql connection
  5. Add tableFilters support to introspect:pg, introspect:mysql, introspect:sqlite. Closing #70
  6. Fix PostgreSQL: generated ALTER TABLE incorrectly adds schema on rename
  7. Fix Error while pushing changes
  8. Fix Typescript and ESM not working together
  9. Fix Cannot find module "drizzle-orm/version"
  10. Fix PG Migrations using Schemas
  11. Fix Cannot use import statement outside a module when using a TypeScript config file
  12. Add support for Feature request: option to match generated column name case to db column name
  13. Fix Generate:mysql command produces a migration file name with a directory separator
  14. Fix Postgres Enums not double quoted when used

Don't miss a new drizzle-kit-mirror release

NewReleases is sending notifications on new releases.