
# 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;

#-----------------------------------------------------------------------------
#-- node
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `node`;


CREATE TABLE `node`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`is_public` INTEGER default 1 NOT NULL,
	`node_class` VARCHAR(255)  NOT NULL,
	`url_provider` INTEGER,
	`open_target_provider` INTEGER,
	`perms_type` TINYINT default 1,
	`credentials` TEXT,
	`tree_left` INTEGER  NOT NULL,
	`tree_right` INTEGER  NOT NULL,
	`tree_parent` INTEGER,
	`tree_id` INTEGER default 1 NOT NULL,
	`is_visible_in_menu` INTEGER default 1 NOT NULL,
	`current_layout` VARCHAR(255),
	`current_layout_type` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	PRIMARY KEY (`id`),
	KEY `node_I_1`(`tree_left`),
	KEY `node_I_2`(`tree_right`),
	KEY `node_I_3`(`tree_parent`),
	KEY `node_I_4`(`tree_id`)
)Engine=InnoDB;

#-----------------------------------------------------------------------------
#-- node_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `node_i18n`;


CREATE TABLE `node_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`url_type` INTEGER  NOT NULL,
	`url_identifier` VARCHAR(255),
	`title` VARCHAR(255)  NOT NULL,
	`sub_title` VARCHAR(255),
	`browser_title_type` INTEGER  NOT NULL,
	`browser_title_content` VARCHAR(255),
	`seo_keywords_type` INTEGER  NOT NULL,
	`seo_keywords_content` VARCHAR(255),
	`seo_description_type` INTEGER  NOT NULL,
	`seo_description_content` VARCHAR(255),
	`menu_title_type` INTEGER  NOT NULL,
	`menu_title_content` VARCHAR(255),
	PRIMARY KEY (`id`,`culture`),
	KEY `node_i18n_I_1`(`culture`),
	CONSTRAINT `node_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `node` (`id`)
		ON DELETE CASCADE
)Engine=InnoDB;

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