Column of relation already exists

I have a couple of tables
export const schoolReferences = pgTable(
'school_references',
{
id: serial('id').primaryKey(),
sanityId: text('sanity_id').notNull().unique(),
name: text('name'),
},
(table) => [uniqueIndex('sanity_id_idx').on(table.sanityId)],
)

export const players = pgTable('players', {
id: serial('id').primaryKey(),
firstName: text('first_name').notNull(),
lastName: text('last_name').notNull(),
currentSchoolId: integer('current_school_id').references(() => schoolReferences.id),
})

export const transferPortalEntries = pgTable('transfer_portal_entries', {
id: serial('id').primaryKey(),
playerId: integer('player_id')
.references(() => players.id)
.notNull(),
previousSchoolId: integer('previous_school_id')
.references(() => schoolReferences.id)
.notNull(),
commitmentSchoolId: integer('commitment_school_id').references(() => schoolReferences.id),
})
export const schoolReferences = pgTable(
'school_references',
{
id: serial('id').primaryKey(),
sanityId: text('sanity_id').notNull().unique(),
name: text('name'),
},
(table) => [uniqueIndex('sanity_id_idx').on(table.sanityId)],
)

export const players = pgTable('players', {
id: serial('id').primaryKey(),
firstName: text('first_name').notNull(),
lastName: text('last_name').notNull(),
currentSchoolId: integer('current_school_id').references(() => schoolReferences.id),
})

export const transferPortalEntries = pgTable('transfer_portal_entries', {
id: serial('id').primaryKey(),
playerId: integer('player_id')
.references(() => players.id)
.notNull(),
previousSchoolId: integer('previous_school_id')
.references(() => schoolReferences.id)
.notNull(),
commitmentSchoolId: integer('commitment_school_id').references(() => schoolReferences.id),
})
I went to add a new column name to the school_references table & remove a column from transfer_portal_entries and ran drizzle-kit generate followed by drizzle-kit migrate. However, when I run the migrate command I get applying migrations...PostgresError: column "name" of relation "school_references" already exists. I previously added name via the Supabase dashboard to test something and then removed it but it was back after running generate and migrate the other day (which I want). I'm not sure why it's complaining now.
2 Replies
Spark
Spark•2w ago
I am running into something similar due to the IF NOT EXISTS being removed I think https://github.com/drizzle-team/drizzle-orm/releases/tag/drizzle-kit%400.30.0
GitHub
Release [email protected] · drizzle-team/drizzle-orm
Starting from this update, the PostgreSQL dialect will align with the behavior of all other dialects. It will no longer include IF NOT EXISTS, $DO, or similar statements, which could cause incorrec...
jsingleton37
jsingleton37OP•7d ago
I just upgraded from 0.36.4 to 0.38.1 of drizzle-orm and 0.28.1 to 0.30.0 of drizzle-kit and now I can't even do drizzle-kit generate 😭 I get
Error: [supabase/migrations/meta/0017_snapshot.json, supabase/migrations/meta/0018_snapshot.json] are pointing to a parent snapshot: supabase/migrations/meta/0017_snapshot.json/snapshot.json which is a collision.
Error: [supabase/migrations/meta/0017_snapshot.json, supabase/migrations/meta/0018_snapshot.json] are pointing to a parent snapshot: supabase/migrations/meta/0017_snapshot.json/snapshot.json which is a collision.
Want results from more Discord servers?
Add your server