Skip to content

Releases: drizzle-team/drizzle-kit-mirror

0.20.17

20 Apr 19:22
edfae9e
Compare
Choose a tag to compare
  • Fixed $default values to work with new local drizzle studio. You will be forced to upgrade drizzle-kit

v0.20.16

19 Apr 18:51
edfae9e
Compare
Choose a tag to compare
  • Fixed 0.20.15 bugs and force to upgrade from studio UI

v0.20.15

19 Apr 13:22
edfae9e
Compare
Choose a tag to compare
  • 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

01 Feb 11:43
edfae9e
Compare
Choose a tag to compare
  • 🐛 When upgrading from <0.20.0 to 0.20.0+, if you have composite primary keys and are using the generate command only for SQLite database, you may encounter a malformed error from drizzle-kit for all snapshots. This issue has been fixed in this version

0.20.13

16 Jan 12:13
edfae9e
Compare
Choose a tag to compare

0.20.12

12 Jan 20:38
edfae9e
Compare
Choose a tag to compare
  • 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

12 Jan 12:01
edfae9e
Compare
Choose a tag to compare
  • 🐛 [BUG]: how to recover from snapshot.json data is malformed #1554

0.20.10

05 Jan 09:48
edfae9e
Compare
Choose a tag to compare
  • 🐛 [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

27 Dec 11:46
edfae9e
Compare
Choose a tag to compare
  • Local Drizzle Studio proper support for Safari with mkcert
  • Remove wrangler from prod deps

0.20.8

25 Dec 10:27
edfae9e
Compare
Choose a tag to compare

Bug Fixes

  • Fixed introspect and push 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.

  1. Install babel-plugin-inline-import package.
npm install babel-plugin-inline-import
  1. Update babel.config.js and metro.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;
  1. 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;
}