drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
290 stars 17 forks source link

[bug]: `drizzle-kit push` is not detecting changes correctly (Turso) #397

Closed JoshStwrt closed 4 months ago

JoshStwrt commented 4 months ago

I'm using Turso in local development and attempting to use drizzle-kit push but it's not correctly detecting schema changes. For example, it won't simply detect a new column being added to a table. It does seem to detect changes to indexes and constraints. See an example below:

Current Schema (already pushed to the database)

export let example = sqliteTable('example', {
    id: text('id').primaryKey()
})

Proposed Schema Change (without unique constraint)

export let example = sqliteTable('example', {
    id: text('id').primaryKey(),
    extraField: text('extra_field')
})

Running drizzle-kit push on the above returns:

Reading config file '/***<projectpath>***/drizzle.config.ts'

[i] No changes detected

But, running drizzle-kit push on a change such as the following:

Proposed Schema Change (with unique constraint)

export let example = sqliteTable('example', {
    id: text('id').primaryKey(),
    extraFieldAndUnique: text('extra_field').unique()
})

Prompts the following, noting the creation of a new unique index but not the new column:

Warning You are about to execute current statements:

CREATE UNIQUE INDEX `example_extra_field_unique` ON `example` (`extra_field`);

  No, abort
❯ Yes, I want to execute all statements

drizzle.config.ts

export default defineConfig({
    dialect: 'sqlite',
    driver: 'turso',
    dbCredentials: {
        url: 'http://localhost:8080'
    },

    schema: './src/lib/server/database/schema/*.ts',
    strict: true,
    verbose: true
})

Versions

"drizzle-kit": "0.21.1",
"drizzle-orm": "0.30.10"
arxkdev commented 4 months ago

Same problem happening to me as well, in the Discord they informed me they are aware and it is being fixed.

codewithcheese commented 4 months ago

Me too. Except with drizzle-kit generate. Tracking this.

VaggelisKa commented 4 months ago

Same for me. Good to know that it's being fixed!

varundeva commented 4 months ago

The same issue is facing. drizzle-kit generate is not showing these changes. I run drizzle-kit drop and again run the generate command. but after running the migrate command it is showing table already exists and skips.. altered change is not tracking.

AndriiSherman commented 4 months ago

fixed locally, will include in one if next releases

AndriiSherman commented 4 months ago

should be fixed in drizzle-kit@0.21.2. Feel free to reopen if it is not fixed for you!

VaggelisKa commented 4 months ago

It's working for me @AndriiSherman :)