`no such table: main.__old_push_projects` after db push

Added the following to a table named service:
(table) => ({
name_project_idx: index("name_project_idx").on(table.name, table.projectId),
name_project_unq: unique("name_project_unq").on(
table.name,
table.projectId,
),
}),
(table) => ({
name_project_idx: index("name_project_idx").on(table.name, table.projectId),
name_project_unq: unique("name_project_unq").on(
table.name,
table.projectId,
),
}),
and ran pnpm drizzle-kit push:sqlite it warned:
 Warning  Found data-loss statements:
· You're about to delete __old_push_projects table with 4 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
[✓] Changes applied
 Warning  Found data-loss statements:
· You're about to delete __old_push_projects table with 4 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
[✓] Changes applied
__old_push_projects is never mentioned in my codebase. I have a table named projects, and thats the closest thing. now my server errors with:
"no such table: main.__old_push_projects"
What is this table supposed to be and how can I get it back?
9 Replies
Angelelz
Angelelz11mo ago
When does it show that error?
Derock
DerockOP11mo ago
const [data] = await ctx.db
.insert(service)
.values({
name: input.name,
projectId: ctx.project.id,
redeploySecret: randomBytes(env.REDEPLOY_SECRET_BYTES).toString(
"hex",
),
source: ServiceSource.Docker,

dockerImage: "traefik/whoami",
})
.returning({
id: service.id,
})
.execute()
const [data] = await ctx.db
.insert(service)
.values({
name: input.name,
projectId: ctx.project.id,
redeploySecret: randomBytes(env.REDEPLOY_SECRET_BYTES).toString(
"hex",
),
source: ServiceSource.Docker,

dockerImage: "traefik/whoami",
})
.returning({
id: service.id,
})
.execute()
stack trace
Derock
DerockOP11mo ago
No description
Derock
DerockOP11mo ago
seems like this is duplicate of: https://discord.com/channels/1043890932593987624/1158505696166428772/1158505696166428772 i cant even find in the drizzle-orm source code any references to __old_push or __old and searching for __ NOT __drizzle comes up with nothing useful (using github search) so im very confused as to where the old_push gets added in searching ` AND push` comes up with nothing good either
Angelelz
Angelelz11mo ago
I believe this is drizzle-kit But the error shows up when you query the database?
NevTheReal
NevTheReal11mo ago
I got the same issue here, when I try to add a new user to the database
Angelelz
Angelelz11mo ago
@Andrew Sherman
Derock
DerockOP11mo ago
i deleted the old database and created a brand new one (I'm using better-sqlite3) the only difference is that the old database also has a table called __old_push_sessions while the new one has no __old_push_ tables looking closer at the stack trace, i think the error is coming from somewhere else in my code:
const [project] = await ctx.db
.select({
id: projects.id,
friendlyName: projects.friendlyName,
internalName: projects.internalName,
createdAt: projects.createdAt,
})
.from(projects)
.where(
or(
eq(projects.id, input.projectId), // << this line is what my stack trace is telling me
eq(projects.internalName, input.projectId),
),
)
.limit(1);
const [project] = await ctx.db
.select({
id: projects.id,
friendlyName: projects.friendlyName,
internalName: projects.internalName,
createdAt: projects.createdAt,
})
.from(projects)
.where(
or(
eq(projects.id, input.projectId), // << this line is what my stack trace is telling me
eq(projects.internalName, input.projectId),
),
)
.limit(1);
actually ignore this, my stack trace is being very weird -- code completely unrelated to the issue for some reason is part of the trace.
Eimis
Eimis11mo ago
try to create migration file migrate.ts with something like this:
import { migrate } from 'drizzle-orm/libsql/migrator';

const db = const orgClient = createClient({ url: env.LIBSQL_URL });
const migrate = async () => {
await migrate(db, { migrationsFolder: YOUR_MIGRATION_FOLDER });
}

void migrate();
import { migrate } from 'drizzle-orm/libsql/migrator';

const db = const orgClient = createClient({ url: env.LIBSQL_URL });
const migrate = async () => {
await migrate(db, { migrationsFolder: YOUR_MIGRATION_FOLDER });
}

void migrate();
and change migrate script to: yarn tsx ./migrate.ts I had same error with turso using drizzle-kit push:sqlite but had to start with fresh db
Want results from more Discord servers?
Add your server