sqlite insert results in error: "SQLite error: no such table: main.__old_push_items"

2 of my 3 table insert work fine, but my auctions table inserts do not work for some reason. When I try to insert data into my sqlite db on Turso I get the following error:
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_items
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_items
Versions
{
"drizzle-kit": "^0.20.4",
"drizzle-orm": "^0.29.0"
}
{
"drizzle-kit": "^0.20.4",
"drizzle-orm": "^0.29.0"
}
Insert code uses Zod to validate, which it passes succesfully
const newscanmeta = await db
.insert(scanmeta)
.values({
realm: entry.realm,
faction: entry.faction as 'Alliance' | 'Horde' | 'Neutral',
scanner: entry.char,
timestamp: new Date(entry.ts * 1000).toISOString(),
})
.onConflictDoUpdate({
target: [scanmeta.timestamp, scanmeta.scanner],
set: {
scanner: entry.char,
timestamp: new Date(entry.ts * 1000).toISOString(),
},
})
.returning({ id: scanmeta.id });

const scanID = newscanmeta[0]?.id;

const newAuction = insertAuctionsSchema.safeParse({
scanId: scanID,
itemId: item,
timestamp: new Date(scan.ts * 1000).toISOString(),
seller,
timeLeft: a.TimeLeft,
itemCount: a.ItemCount,
minBid: a.MinBid,
buyout: a.Buyout,
curBid: a.CurBid,
});
if (!newAuction.success) {
console.error(fromZodError(newAuction.error));
continue;
}

await db.insert(auctions).values(newAuction.data);
const newscanmeta = await db
.insert(scanmeta)
.values({
realm: entry.realm,
faction: entry.faction as 'Alliance' | 'Horde' | 'Neutral',
scanner: entry.char,
timestamp: new Date(entry.ts * 1000).toISOString(),
})
.onConflictDoUpdate({
target: [scanmeta.timestamp, scanmeta.scanner],
set: {
scanner: entry.char,
timestamp: new Date(entry.ts * 1000).toISOString(),
},
})
.returning({ id: scanmeta.id });

const scanID = newscanmeta[0]?.id;

const newAuction = insertAuctionsSchema.safeParse({
scanId: scanID,
itemId: item,
timestamp: new Date(scan.ts * 1000).toISOString(),
seller,
timeLeft: a.TimeLeft,
itemCount: a.ItemCount,
minBid: a.MinBid,
buyout: a.Buyout,
curBid: a.CurBid,
});
if (!newAuction.success) {
console.error(fromZodError(newAuction.error));
continue;
}

await db.insert(auctions).values(newAuction.data);
I also tried raw sql insert but it gives the same error
await db.run(sql`
INSERT INTO ${auctions} (scanId, itemId, ts, seller, timeLeft, itemCount, minBid, buyout, curBid)
VALUES (${newAuction.data.scanId}, ${newAuction.data.itemId}, ${newAuction.data.timestamp}, ${newAuction.data.seller}, ${newAuction.data.timeLeft}, ${newAuction.data.itemCount}, ${newAuction.data.minBid}, ${newAuction.data.buyout}, ${newAuction.data.curBid})
`);
await db.run(sql`
INSERT INTO ${auctions} (scanId, itemId, ts, seller, timeLeft, itemCount, minBid, buyout, curBid)
VALUES (${newAuction.data.scanId}, ${newAuction.data.itemId}, ${newAuction.data.timestamp}, ${newAuction.data.seller}, ${newAuction.data.timeLeft}, ${newAuction.data.itemCount}, ${newAuction.data.minBid}, ${newAuction.data.buyout}, ${newAuction.data.curBid})
`);
5 Replies
Meexa
MeexaOP13mo ago
Pastebin
import { sql } from 'drizzle-orm';import { text, integer, sqliteTab...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Meexa
MeexaOP13mo ago
Also happens with a local sqlite db
Angelelz
Angelelz13mo ago
You have to push or migrate your changes when you create a new table on your schema
Meexa
MeexaOP13mo ago
I have pushed all changes I continue to get this error, but one way to solve it is by deleting all the tables and pushing again. Not great, but its the only solution I've found so far.
daz.dev
daz.dev12mo ago
Also encountering this after pushing changes:
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_user
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_user
Want results from more Discord servers?
Add your server