Noob question about DROP TABLE ordering

Hello! I'm about to drop my first table with Drizzle, and I noticed the SQL file looks like this:
DROP TABLE "merlin_schools";--> statement-breakpoint
ALTER TABLE "merlin_auth_user" DROP CONSTRAINT "merlin_auth_user_school_merlin_schools_id_fk";
--> statement-breakpoint
ALTER TABLE "merlin_groups" DROP CONSTRAINT "merlin_groups_school_id_merlin_schools_id_fk";
--> statement-breakpoint
ALTER TABLE "merlin_auth_user" DROP COLUMN IF EXISTS "school";--> statement-breakpoint
ALTER TABLE "merlin_groups" DROP COLUMN IF EXISTS "school_id";
DROP TABLE "merlin_schools";--> statement-breakpoint
ALTER TABLE "merlin_auth_user" DROP CONSTRAINT "merlin_auth_user_school_merlin_schools_id_fk";
--> statement-breakpoint
ALTER TABLE "merlin_groups" DROP CONSTRAINT "merlin_groups_school_id_merlin_schools_id_fk";
--> statement-breakpoint
ALTER TABLE "merlin_auth_user" DROP COLUMN IF EXISTS "school";--> statement-breakpoint
ALTER TABLE "merlin_groups" DROP COLUMN IF EXISTS "school_id";
won't dropping the table first cause issues with the FK contraints?
3 Replies
benjick
benjick2mo ago
Yeah, got this error:
error: cannot drop table merlin_schools because other objects depend on it
DYELbrah
DYELbrah2mo ago
@benjick you figure this out? we can't drop a table either because of this. I'm pretty sure drizzle-kit should've deleted all references to the table first THEN dropped the table...
benjick
benjick2mo ago
Yeah I just moved the DROP statement to the end of the file manually