drizzle-team / drizzle-team/drizzle-orm

The __drizzle_migrations table looks not right on Durable Objects

Open
#4,928 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

I use drizzle on Cloudflare Durable Objects.

Here is `migrations.js` file:

```javascript
import journal from './meta/_journal.json';
import m0000 from './0000_init_tables.sql';
import m0001 from './0001_add_username_plugin.sql';
import m0002 from './0002_add_configs_and_keys.sql';
import m0003 from './0003_alter_time_columns.sql';

export default {
journal,
migrations: {
m0000,
m0001,
m0002,
m0003
}
}

```

Here is the `migrate` code on durable objects:

```typescript

import { drizzle } from 'drizzle-orm/durable-sqlite';
import { migrate } from "drizzle-orm/durable-sqlite/migrator";
import migrations from "./drizzle/migrations/migrations";

export class EdgeAuthWorkspaceDurableObject extends DurableObject {
db: WorkspaceDatabase;

constructor(ctx: DurableObjectState, env: CloudflareBindings) {
super(ctx, env);
// init db
this.db = drizzle(ctx.storage, { schema: schema, logger: true });
// do migrations
this.migrate();
}

private migrate() {
this.ctx.blockConcurrencyWhile(async () => {
await migrate(this.db, migrations);
console.log('migrations completed');
})
}
}
```

Now, check the table `__drizzle_migrations`:

Image

The `id` column is `NULL`, the `hash` column is `''`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.