Cannot read properties of undefined (reading 'columns')

/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/node_modules/drizzle-kit/index.cjs:37573:19)
at async Command.<anonymous> (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52680:31)
/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/node_modules/drizzle-kit/index.cjs:37573:19)
at async Command.<anonymous> (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52680:31)
19 Replies
thdxr
thdxrOP2y ago
looks like the key is __drizleMigrations
Andrii Sherman
fixing this one is fixed in 0.19.7
thdxr
thdxrOP2y ago
ty
0xpeezy
0xpeezy2y ago
i am getting this on 0.19.7
Andrii Sherman
ohcomeon assume you are using push with tableFilters? just found this case, will release now in 0.19.8
0xpeezy
0xpeezy2y ago
yea exactly
0xpeezy
0xpeezy2y ago
insane
SPS | Shootmail
SPS | Shootmail17mo ago
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52617:61)
at logSuggestionsAndReturn2 (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/node_modules/drizzle-kit/index.cjs:52617:61)
at logSuggestionsAndReturn2 (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/drizzle-kit/index.cjs:53456:11)
Getting this in 0.19.13 with sqlite:push *push:sqlite
Andrii Sherman
Andrii Sherman17mo ago
If you can share what did you change in your schema - will help me a lot
SPS | Shootmail
SPS | Shootmail17mo 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
Andrii Sherman
Andrii Sherman17mo ago
got it, will test this specific case
SPS | Shootmail
SPS | Shootmail16mo ago
Sure Hey @Andrew Sherman were you able to check this?
Andrii Sherman
Andrii Sherman16mo ago
Not yet, I'll ping you right after I get a chance to look into it
SPS | Shootmail
SPS | Shootmail16mo ago
Thanks
d4mr
d4mr14mo ago
hi, has this been fixed? I still get this error
daz.dev
daz.dev13mo 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.
DaFr33k
DaFr33k11mo 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
DaFr33k
DaFr33k11mo 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