Releases: drizzle-team/drizzle-kit-mirror
v0.20.15
- Moving server instantiations from Local Drizzle Studio to drizzle-kit. Local Studio will now require an upgrade to the latest version of drizzle-kit
0.20.14
- 🐛 When upgrading from
<0.20.0
to0.20.0+
, if you have composite primary keys and are using thegenerate
command only for SQLite database, you may encounter amalformed
error from drizzle-kit for all snapshots. This issue has been fixed in this version
0.20.13
- New SQL Query Runner inside Drizzle Studio(https://local.drizzle.studio)
0.20.12
-
Made
schemaTo
optional during the serialize step, preventing unnecessary drop+create foreign key statements from appearing. -
Fixed an issue: when using a barrel file, drizzle-kit was exporting duplicated tables, leading to an error with multiple indexes having the same name. It should now remove duplicates and function as expected
0.20.11
- 🐛 [BUG]: how to recover from snapshot.json data is malformed #1554
0.20.10
- 🐛 [BUG]: drizzle-kit generates incorrect foreign key references to a table from a different schema when using pgSchema #636
- 🐛 Introspect error #277
0.20.9
- Local Drizzle Studio proper support for Safari with mkcert
- Remove wrangler from prod deps
0.20.8
Bug Fixes
- Fixed
introspect
andpush
for PlanetScale. A newly added feature to PlanetScale was not functioning properly with the 'drizzle-kit introspect' and 'push' commands, failing to retrieve foreign keys from a database. This issue should now be resolved
New Drivers
🎉 Expo SQLite Driver is available
For starting with Expo SQLite Driver, you need to install expo-sqlite
and drizzle-orm
packages.
npm install drizzle-orm expo-sqlite@next
Then, you can use it like this:
import { drizzle } from "drizzle-orm/expo-sqlite";
import { openDatabaseSync } from "expo-sqlite/next";
const expoDb = openDatabaseSync("db.db");
const db = drizzle(expoDb);
await db.select().from(...)...
// or
db.select().from(...).then(...);
// or
db.select().from(...).all();
If you want to use Drizzle Migrations, you need to update babel and metro configuration files.
- Install
babel-plugin-inline-import
package.
npm install babel-plugin-inline-import
- Update
babel.config.js
andmetro.config.js
files.
babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
+ plugins: [["inline-import", { "extensions": [".sql"] }]]
};
};
metro.config.js
const { getDefaultConfig } = require('expo/metro-config');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
+config.resolver.sourceExts.push('sql');
module.exports = config;
- Create
drizzle.config.ts
file in your project root folder.
import type { Config } from 'drizzle-kit';
export default {
schema: './db/schema.ts',
out: './drizzle',
driver: 'expo',
} satisfies Config;
After creating schema file and drizzle.config.ts file, you can generate migrations like this:
npx drizzle-kit generate:sqlite
Then you need to import migrations.js
file in your App.tsx
file from ./drizzle
folder and use hook useMigrations
or migrate
function.
import { drizzle } from "drizzle-orm/expo-sqlite";
import { openDatabaseSync } from "expo-sqlite/next";
import { useMigrations } from 'drizzle-orm/expo-sqlite/migrator';
import migrations from './drizzle/migrations';
const expoDb = openDatabaseSync("db.db");
const db = drizzle(expoDb);
export default function App() {
const { success, error } = useMigrations(db, migrations);
if (error) {
return (
<View>
<Text>Migration error: {error.message}</Text>
</View>
);
}
if (!success) {
return (
<View>
<Text>Migration is in progress...</Text>
</View>
);
}
return ...your application component;
}
0.20.7
Bug fixes
- BUG drizzle-kit introspect:mysql from Planetscale db returns wrong primary key #216
- BUG: v0.20.2 push:mysql error: there can be only one auto column and it must be defined as a key #234
- Fixed dropping all primary keys and creating them 1 more time
Improvements
- Check names for indexes and notify if you have specified the same index names within the schema.
- Verify that auto-increment can only be created for primary keys in MySQL
0.20.0
Drizzle ORM version
0.29.0
will require a minimum Drizzle Kit version of0.20.0
, and vice versa. Therefore, when upgrading to a newer version of Drizzle ORM, you will also need to upgrade Drizzle Kit. This may result in some breaking changes throughout the versions, especially if you need to upgrade Drizzle Kit and your Drizzle ORM version is older than<0.28.0
New Features
New way to define drizzle.config using defineConfig
function
import { defineConfig } from 'drizzle-kit'
export default defineConfig({
schema: "./schema.ts",
out: "./drizzle",
driver: "..",
dbCredentials: {
// connection
},
verbose: true,
strict: true,
})
Possibility to access Cloudflare D1 with Drizzle Studio using wrangler.toml file
You can now use Drizzle Studio with your D1 database. Please note that it may be slow at times because Drizzle Studio utilizes Wrangler CLI calls to perform data selection, updates, deletions, and insertions. The speed of these operations depends on the performance of Wrangler CLI calls.
To use Drizzle Studio with the D1 database, you need to provide the file path to your wrangler.toml
file and specify the dbName
you are using in Cloudflare D1
import { defineConfig } from 'drizzle-kit'
export default defineConfig({
schema: "./schema.ts",
out: "./drizzle",
driver: "d1",
dbCredentials: {
wranglerConfigPath: 'wrangler.toml',
dbName: 'd1-test'
},
verbose: true,
strict: true,
})
And then run drizzle-kit studio
Note: make sure you have wrangler cli installed globally or inside your project and you invoked
wrangler login
before running studio
Drizzle Studio is migrating to https://local.drizzle.studio/
Previously, Drizzle Studio used 127.0.0.1:4983
as the default host and port for the web page. Currently, Drizzle Studio will always be hosted on https://local.drizzle.studio/
, connecting to the backend at 127.0.0.1:4983
. You can modify the host and port for the backend server by using the --host
and --port
options in drizzle-kit studio
.
local.drizzle.studio
provides the ability to ship updates to the Drizzle Studio web UI immediately, eliminating the need for constant drizzle-kit
upgrades
bigint unsigned
support
This option is now available in the introspect, push, and generate commands.
primaryKeys
and foreignKeys
now can have custom names
This option is now available in the introspect, push, and generate commands.
Environment variables are now fetched automatically
As mentioned many times, you can finally skip fetching environment variables to use with the drizzle.config
file. Drizzle Kit will handle this process automatically.
Drizzle Studio Updates
- Refresh button for the view inside a table.
- Possibility to choose schemas for Postgres. For MySQL and SQLite,
public
will be the default, and the only choice.
Improvements
- remove
libsql_wasm_func_table
from sqlite introspect and push - Handle
primaryKey
columns order for composite constraints
Bug Fixes
- Fix the case, when having
turso
orlibsql
driver user was seeing an error with nobetter-sqlite3
dependency - Add
tableFilters
to cli options in all push commands - Fix dropping unique indexes syntax for push and generate command