
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;

-- ---------------------------------------------------------------------
-- slide_item
-- ---------------------------------------------------------------------

DROP TABLE IF EXISTS `slide_item`;

CREATE TABLE `slide_item`
(
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255),
    `content` TEXT,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB;

-- ---------------------------------------------------------------------
-- slide_rel
-- ---------------------------------------------------------------------

DROP TABLE IF EXISTS `slide_rel`;

CREATE TABLE `slide_rel`
(
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `position` INTEGER DEFAULT 1 NOT NULL,
    `slide_id` INTEGER NOT NULL,
    `ref` VARCHAR(255) NOT NULL,
    `ref_id` INTEGER NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `FI_de_rel_slide_id` (`slide_id`),
    CONSTRAINT `slide_rel_slide_id`
        FOREIGN KEY (`slide_id`)
        REFERENCES `slide_item` (`id`)
        ON DELETE CASCADE
) ENGINE=InnoDB;

# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
