Cannot read properties of undefined (reading 'columns')

/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:11810
result[key].columns[value[0]].primaryKey = true;
^

TypeError: Cannot read properties of undefined (reading 'columns')
at fromDatabase (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:11810:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async mysqlPushIntrospect (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:37573:19)
at async Command.<anonymous> (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:52680:31)
/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:11810
result[key].columns[value[0]].primaryKey = true;
^

TypeError: Cannot read properties of undefined (reading 'columns')
at fromDatabase (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:11810:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async mysqlPushIntrospect (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:37573:19)
at async Command.<anonymous> (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/drizzle-kit@0.19.6/node_modules/drizzle-kit/index.cjs:52680:31)
T
thdxr303d ago
looks like the key is __drizleMigrations
AS
Andrii Sherman303d ago
fixing this one is fixed in 0.19.7
T
thdxr303d ago
ty
X
0xpeezy303d ago
i am getting this on 0.19.7
AS
Andrii Sherman303d ago
ohcomeon assume you are using push with tableFilters? just found this case, will release now in 0.19.8
X
0xpeezy303d ago
yea exactly
AS
Andrii Sherman303d ago
5 mins drizzle-kit@0.19.8
X
0xpeezy303d ago
insane
S
sps260d ago
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:52617:61)
at logSuggestionsAndReturn2 (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:52842:39)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.<anonymous> (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:53456:11)
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:52617:61)
at logSuggestionsAndReturn2 (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:52842:39)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.<anonymous> (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:53456:11)
Getting this in 0.19.13 with sqlite:push *push:sqlite
AS
Andrii Sherman260d ago
If you can share what did you change in your schema - will help me a lot
S
sps260d ago
1. Added these two tables:
export const session = sqliteTable("user_session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
activeExpires: blob("active_expires", {
mode: "bigint"
}).notNull(),
idleExpires: blob("idle_expires", {
mode: "bigint"
}).notNull()
});

export const key = sqliteTable("user_key", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
hashedPassword: text("hashed_password")
});
export const session = sqliteTable("user_session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
activeExpires: blob("active_expires", {
mode: "bigint"
}).notNull(),
idleExpires: blob("idle_expires", {
mode: "bigint"
}).notNull()
});

export const key = sqliteTable("user_key", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
hashedPassword: text("hashed_password")
});
2. Removed a table named auth_key 3. In the users table earlier only the id was primaryKey, now I have changed it to a composite key of id, organizationId
export const users = sqliteTable("users", {
id: text("id").unique().notNull(),
email: text('email').notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).default(sql`(strftime('%s', 'now'))`),
status: text('status', {enum: ["ACTIVE", "INACTIVE"]}).default("INACTIVE"),
organizationId: text("organization_id")
}, (users) => ({
emailIdx: index("user_email_idx").on(users.email),
emailOrgPrimaryKey: primaryKey(users.email, users.organizationId)
}));
export const users = sqliteTable("users", {
id: text("id").unique().notNull(),
email: text('email').notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).default(sql`(strftime('%s', 'now'))`),
status: text('status', {enum: ["ACTIVE", "INACTIVE"]}).default("INACTIVE"),
organizationId: text("organization_id")
}, (users) => ({
emailIdx: index("user_email_idx").on(users.email),
emailOrgPrimaryKey: primaryKey(users.email, users.organizationId)
}));
I was trying push:sqlite against remote turso db database. Then I tried with a fresh local turso db and it worked. But didn't work with the remote db that already had tables and data
AS
Andrii Sherman260d ago
got it, will test this specific case
S
sps258d ago
Sure Hey @Andrew Sherman were you able to check this?
AS
Andrii Sherman258d ago
Not yet, I'll ping you right after I get a chance to look into it
S
sps254d ago
Thanks
D
d4mr191d ago
hi, has this been fixed? I still get this error
D
daz.dev147d ago
I have just run in to this error too: v0.20.7 pushing to Turso. Let me know what additional info will help. Actually, I figured this out. The issue what that I wasn't pointing to my src/db/schema.ts file correctly, hence not finding columns.
D
DaFr33k103d ago
I'm getting the same issue with the same stack trace using turso dev for local development. Version 0.28.5. @Andrew Sherman if it helps, attached is my debug of the table causing the issue. My change was adding a self referencing column to a table that isn't related to organization_auth. See 2nd image on migration:
No description
No description
D
DaFr33k103d ago
Quick discovery. It seems like some of the __old_push tables hang around if the push:sqlite command fails. Once that happens, the undefined 'columns' error pops up. After manually dropping the table with the sqlite command line client, the push runs and spits back my actual error (foreign key constraint problem on my end), but after that error, another __old_push table hangs around again. This time, that table had columns, so I actually got a prompt to drop it when running the push again. What made this complicated is those temp tables (I assume due to naming convention) are hidden in drizzle studio. Maybe this helps some of you get unstuck to see the actual error thrown by the driver. It seems like there needs to be an error catch in drizzle-kit that cleans up the temp tables used if the underlying driver throws. To clarify, I didn't check the __old_push_organization_auth table for columns before dropping. I'm just assuming it didn't since the new temp table had columns and I was prompted to drop it during the push
Want results from more Discord servers?
Add your server
More Posts
neon coldstarts in vercel edgehey!! if my neondb is in `idle` state, and i try to query something -- it will error out. `- error How to create GIN/GIST index on text[] column?According to some issues this is not implemented or buggy - https://github.com/drizzle-team/drizzle-Module '"drizzle-orm/mysql-core"' has no exported member 'unique'.ts(2305)Getting this error when trying to import `unique` ```typescript import { text, unique, // erroriIs there a way to set the index operator type for postgres?I'm migrating our project to drizzle, and I want to add the indexes to the table. Previously we wereHow to update multiple rows with one query?Take this array as an example: ```ts const data = [ {id: 1, col1: "col1 data where id = 1"} {id:Use Drizzle in NestJS appHi everyone ! I am new to both drizzle and NestJS and was wondering if there was any recipe out ther[Solved] Transforming const to the configured target environment ("es5") is not supported yetSo I had a old project, and I copied the `DATABASE_URL` and on created a basic drizzle project and `Placeholders in inserting: db.insert().values(placeholder('example'))Hey, how do I add placeholders inside the values of an insert prepare statement? I get an typeerror Can I add a Unique constraint to a column?I couldn't find an option for that in the docs. I'm assuming Drizzle doesn't support that. So, coul"Cannot parse date or time" using AWS Data API, aurora postgresI'm trying drizzle-orm (with sst) and aurora pg thru aws data api, when trying to insert a Date valuFiltering against a relationI have a orgs table that have a many to many relation with a users table. while querying with the fGet type for select query?Hey guys, is there a way to infer the "select" type for a given table? for example: ```ts async getorderBy related table columnGiven a relational query such as ``` const matchResult = await db.query.matches.findMany({ Soft Delete StrategyI'm a person of eloquent taste; one who prefers the soft delete. With the current feature set of driColumns that not allowed to updatedHi guys, I'm looking for a proper way to declare SQL schema and its `InferModel` types when there'rExecute sql with '?' as parameterHello everyone. Please, how do I execute a sql that uses as a parameter the character '?' ? For examForeign Key Reference to auth Schema Not Generated in CodeI'm having an issue with my Drizzle-ORM code where the foreign key reference to the 'auth' schema isHow can I add a Prefix Index?I migrated from Prisma, and I have a column with `varchar(2000)` which I indexed with `@@index([coluconnect to local postgresDoes anyone knows how to connect to a local pg with neon? I tried: ``` import { neon, neonConfig } defaultNow(), onUpdateNow() not available on the datetime data typeI'm able to build this into my database, but I'm not able to express it through drizzle. What gives?