SimpleNotes/api/resources/db/migration/V4__Create_chapters_table.sql

13 lines
329 B
SQL

CREATE TABLE `Chapters`
(
`id` int PRIMARY KEY AUTO_INCREMENT,
`number` int NOT NULL,
`content` text NOT NULL,
`note_id` int NOT NULL
);
ALTER TABLE `Chapters`
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE `Notes`
DROP COLUMN `content`;