MyKindlebox/mykindlebox/server/db/migrations/0003_add_breed_date.sql

18 lines
888 B
SQL

PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_litters` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`sire_id` integer,
`dam_id` integer,
`breed_date` text,
`kindle_date` text,
`kit_count` integer,
`notes` text,
`created_at` text DEFAULT (current_timestamp) NOT NULL,
FOREIGN KEY (`sire_id`) REFERENCES `rabbits`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`dam_id`) REFERENCES `rabbits`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_litters`("id", "sire_id", "dam_id", "kindle_date", "kit_count", "notes", "created_at") SELECT "id", "sire_id", "dam_id", "kindle_date", "kit_count", "notes", "created_at" FROM `litters`;--> statement-breakpoint
DROP TABLE `litters`;--> statement-breakpoint
ALTER TABLE `__new_litters` RENAME TO `litters`;--> statement-breakpoint
PRAGMA foreign_keys=ON;