No such table: main.__old_push_[TABLENAME]
Hello,
I tried to setup Lucia Auth with DrizzleORM and Torso LibSQL. The database reads/writes work via drizzleORM but when i want to create a user via Lucia Auth i get the error from the title. Does anyone have an idea?
38 Replies
Did you solve this?
not yet
do you have an idea? @stan
Not at all, I'm not in production, so I just changed the db and now it's working
The problem started after I made a migration
i didnt even make an migration
just rebuilt
the db
there where no entries so i didnt care#
I did the same and is now working
changed from neon.tech to turso.tech because i want tot migrate to cf d1 when its ready
yeah i changed the credentials and the adapters and so on but its not working for lucia-auth. its only working in drizzle itself
But I fear it may happen in production and to say that it would be bad is an understatement haha
yes
i think its weird that it only throws this error when using a lucia-auth function. when i use drizzle to query and so on it works. but in lucia even i use the same client its not working correctly
For me I wasn't using Lucia auth, I made my own auth with jwt and passportjs and it was working fine
i think i go back to neon.tech and then migrate to d1 when its ready
idk
its weird
The problem came when I was trying to run this code const newStore = await db.insert(stores).values(store).returning();
And it makes no sense for me
hm
true
Because I ran this one and it worked seamlessly: const newUser = await db.insert(users).values(user).returning();
I think the problem was specifically related to the stores table and the migration a made to it
My full error looks like this: LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.old_push_users
at mapHranaError (/home/stan/project-rusilla-nstc/node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib-cjs/hrana.js:287:16)
at HttpClient.execute (/home/stan/project-rusilla-nstc/node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib-cjs/http.js:84:48)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PreparedQuery.all (/home/stan/project-rusilla-nstc/nodemodules/.pnpm/[email protected]@[email protected][email protected]/node_modules/src/libsql/session.ts:223:16)
at async /home/stan/project-rusilla-nstc/src/routes/storeRoutes.ts:38:22 {
code: 'SQLITE_UNKNOWN',
[cause]: [ResponseError: SQLite error: no such table: main.old_push_users] {
code: 'SQLITE_UNKNOWN',
proto: {
message: 'SQLite error: no such table: main.__old_push_users',
code: 'SQLITE_UNKNOWN'
}
}
}
You can see it says old_push_users doesn't exist because it's related to the push migration I did
what the fuck
i
what the fuck
i dont get it
okay
so i deleted the databases in turso
created them new
deleted the migration dir in my project
and generated and pushed fresh
now its working
i dont get it
I did exactly the same
But it does not make any sense for me
exactly
that a bit fucked up
i cant just delete everything when there is a problem
oH prOducTioN is NoT wOrKiNg? JuSt dEleTe It
It was trying to use the main.__old_push_users table, that I guess is the name of the users table from before the push
its some migration table
when u edit a schema of a table
it renames the old to this weird name
creates the new
and moves the data to the new and deletes the old
afaik
But why was it looking for it?
exatly
i didnt define the name as this
like where did it get the name from
And worst, did it loose it?
Outside of the migration process
XD! cReAtE A nEw oNe
who cares about data
There's no github issue about it, later I'm going to create one, I suggest you do the same so that they may fix it
just dont use it
alright
send it then
Just run in to this same issue with Elysia and Lucia Auth. Hit it twice, only resolution is to delete the tables, which is not practical. Did you open a GitHub issue I can track/contribute to @stan?
I pushed changes instead of migrated so there were some problems
@Louis / @stan
Did either of you make an GitHub issue for this?
I'm running into the same problem (https://discord.com/channels/1043890932593987624/1186793412549148753) and if you haven't made an issue yet, I'll go ahead and make one.
No didnt made one
I ran into the same thing. Looking at the schema, the issue for me was that the foreign keys on the user tables were creating an issue because the FK's were connected to the old table (main.__old). Removing the foreign keys fixed the issue where I could use Drizzle. :/ Hope this helps.
Hello everyone! Could you please let me know if this issue is exclusive to authentication providers (like Lucia, Next) or if it can also happen with a standard workflow using SQLite? Additionally, could you provide a detailed description of your workflow to help reproduce this issue?
@Mykhailo I'm sorry to say I can't clear that part up but am constantly running into this same issue using Turso, Drizzle, Lucia auth as well.
My workflow is as follows:
- write my schema files
- generate a migration file
- push it to turso.
The first time everything works just fine but when running a new migration I get that same error and the __old_push_ table is not deleted.
My schemas are quite foreign-key heavy which I suppose is causing this problem.
Hello, @Domski! We will investigate your issue tomorrow, but could you please share your schema code?
Hi @Mykhailo, having the same issue (seems unrelated to my Clerk auth), here's my
schema.ts
if it can help.
To ""solve"" the problem, currently I have to comment my schema, push, reverse the change and push again (not a viable solution for production, but seems the only to workaround that works for the time being)Hello, @Massimo! You should update all your columns with default value
CURRENT_TIMESTAMP
to this
So, the problem is with default value and current_timestamp constant. It should be wrapped with parentheses. Otherwise, push command will detect changes every time and it will result in this issue.@Mykhailo unfortunately the issue seems to persist even with this change (same behaviour as before)
Could you clarify your workflow please?