···11+DROP INDEX `repost_scheduleGuid_idx`;--> statement-breakpoint
22+CREATE INDEX `repost_scheduleGuid_idx` ON `reposts` (`schedule_guid`,`post_uuid`);
···6767 // used for left joining and matching with posts field
6868 index("repost_postid_idx").on(table.uuid),
6969 // used for checking if a schedule still has actions left
7070- index("repost_scheduleGuid_idx").on(table.scheduleGuid),
7070+ index("repost_scheduleGuid_idx").on(table.scheduleGuid, table.uuid),
7171 // preventing similar actions from pushing to the table
7272 unique("repost_noduplicates_idx").on(table.uuid, table.scheduledDate),
7373]);
+4-2
src/utils/db/data.ts
···11import {
22- and, eq, inArray, isNotNull,
22+ and, eq, inArray,
33 lte, ne, notInArray, sql
44} from "drizzle-orm";
55import { BatchItem } from "drizzle-orm/batch";
···7979 // do a search to find if there are any reposts with the same scheduleguid.
8080 // if there are none, this schedule should get removed from the repostInfo array
8181 const stillHasSchedule = await db.select().from(reposts)
8282- .where(and(isNotNull(reposts.scheduleGuid), eq(reposts.scheduleGuid, deleted.scheduleGuid!)))
8282+ .where(and(
8383+ eq(reposts.scheduleGuid, deleted.scheduleGuid!),
8484+ eq(reposts.uuid, deleted.id)))
8385 .limit(1).all();
84868587 // if this is empty, then we need to update the repost info.