drizzle-team / drizzle-team/drizzle-orm

[BUG]: Turso Introspection is empty

Open
#2,483 1 comment 0 reactions 0 assignees View on GitHub
bug bug/cant-reproduce driver/libsql drizzle/kit priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.31.2

### What version of `drizzle-kit` are you using?

0.22.6

### Describe the Bug

I created a Turso database `drizzle-test` with a simple table `untitled_table_1` with two columns.

```ts
export const temp = sqliteTable('untitled_table_1', {
id: text('id').primaryKey(),
name: text('name').notNull(),
})
```

```sh
> npx drizzle-kit push
drizzle-kit: v0.22.6
drizzle-orm: v0.31.2

No config path provided, using default path
Reading config file '.../drizzle.config.ts'
[✓] Pulling schema from database...
Warning You are about to execute current statements:

CREATE TABLE `untitled_table_1` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL
);

[✓] Changes applied
```

I connected to the new database and table and manually seeded two rows of data just to make sure (tested both with and without data)

Turso web ui view:

![image](https://github.com/drizzle-team/drizzle-orm/assets/1010488/3761c8c9-9e7f-4b82-8796-be932339f5f7)

TablePlus view:

![image](https://github.com/drizzle-team/drizzle-orm/assets/1010488/bcfc98c7-c06e-4fc2-9197-d22c1de5f4d3)

`drizzle-kit introspect` output:

```sh
> ❯ npx drizzle-kit introspect
drizzle-kit: v0.22.6
drizzle-orm: v0.31.2

No config path provided, using default path
Reading config file '.../drizzle.config.ts'
Pulling from ['public'] list of schemas

[✓] 0 tables fetched
[✓] 0 columns fetched
[✓] 0 indexes fetched
[✓] 0 foreign keys fetched

[✓] Your SQL migration file ➜ drizzle/0000_true_the_call.sql 🚀
[✓] You schema file is ready ➜ drizzle/schema.ts 🚀
[✓] You relations file is ready ➜ drizzle/relations.ts 🚀
```

Since the introspection isn't working correctly, subsequent runs of `drizzle-kit push` will fail because it will attempt to create the table again.

```sh
npx drizzle-kit push
drizzle-kit: v0.22.6
drizzle-orm: v0.31.2

No config path provided, using default path
Reading config file '.../drizzle.config.ts'
[✓] Pulling schema from database...
Warning You are about to execute current statements:

CREATE TABLE `untitled_table_1` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL
);

LibsqlError: SQL_INPUT_ERROR: SQL input error: table `untitled_table_1` already exists (at offset 13)
at mapHranaError (.../node_modules/@libsql/client/lib-esm/hrana.js:262:16)
at HttpClient.execute (.../node_modules/@libsql/client/lib-esm/http.js:80:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.run (.../drizzle-kit/bin.cjs:119857:15)
at async sqlitePush (.../node_modules/drizzle-kit/bin.cjs:122665:13)
at async _Command. (.../node_modules/drizzle-kit/bin.cjs:129712:7) {
code: 'SQL_INPUT_ERROR',
rawCode: undefined,
[cause]: [ResponseError: SQL input error: table `untitled_table_1` already exists (at offset 13)] {
code: 'SQL_INPUT_ERROR',
proto: {
message: 'SQL input error: table `untitled_table_1` already exists (at offset 13)',
code: 'SQL_INPUT_ERROR'
}
}
```

I'm using @libsql/client v0.6.2 if that is relevant.

### Expected behavior

_No response_

### Environment & setup

_No response_

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.