CREATE TABLE `template_link` (
`template_id` int unsigned NOT NULL,
`category_id` int unsigned NOT NULL,
UNIQUE KEY `template_id` (`template_id`,`category_id`)
)
CREATE TABLE `template_category` (
`category_id` int unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`category_id`)
)
CREATE TABLE `template` (
`template_id` int unsigned NOT NULL AUTO_INCREMENT,
`user_id` int unsigned NOT NULL,
`flow_id` int unsigned NOT NULL,
`status` int unsigned DEFAULT NULL,
`name` varchar(255) NOT NULL,
`preview_url` varchar(255) DEFAULT NULL,
`structure` longtext,
`last_structure` longtext,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`template_id`)
)