-- Create syntax for TABLE 'square_grid_items'
CREATE TABLE `square_grid_items` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `backend_user_id` int(10) unsigned DEFAULT NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` datetime DEFAULT NULL,
    `square_image_id` int(11) unsigned DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `FK_auth` (`backend_user_id`),
    KEY `FK_square_grid_image` (`square_image_id`),
    CONSTRAINT `FK_auth` FOREIGN KEY (`backend_user_id`) REFERENCES `backend_users` (`id`) ON DELETE SET NULL,
    CONSTRAINT `FK_square_grid_image` FOREIGN KEY (`square_image_id`) REFERENCES `media_items` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



-- Create syntax for TABLE 'square_grid_item_languages'
CREATE TABLE `square_grid_item_languages` (
    `translation_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `square_grid_item_id` int(10) unsigned NOT NULL,
    `language_id` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
    `title` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
    `subtitle` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
    `cta` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
    PRIMARY KEY (`translation_id`),
    UNIQUE KEY `INDEX` (`square_grid_item_id`,`language_id`),
    CONSTRAINT `FK_square_grid_item_lang` FOREIGN KEY (`square_grid_item_id`) REFERENCES `square_grid_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



-- Create syntax for TABLE 'campaign_content_boxes'
CREATE TABLE `blocks` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `backend_user_id` int(10) unsigned DEFAULT NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `FK_auth` (`backend_user_id`),
    CONSTRAINT `FK_auth` FOREIGN KEY (`backend_user_id`) REFERENCES `backend_users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Create syntax for TABLE 'campaign_content_boxes_lang'
CREATE TABLE `block_languages` (
    `translation_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `block_id` int(10) unsigned NOT NULL,
    `language_id` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
    `title` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
    PRIMARY KEY (`translation_id`),
    UNIQUE KEY `INDEX` (`block_id`,`language_id`),
    CONSTRAINT `FK_blocks_lang` FOREIGN KEY (`block_id`) REFERENCES `blocks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


CREATE TABLE `block_entry` (
    `block_id` int(10) unsigned NOT NULL,
    `entry_id` int(10) unsigned NOT NULL,
    `position` int(10) DEFAULT NULL,
    PRIMARY KEY (`block_id`,`entry_id`),
    KEY `FK_block` (`block_id`),
    KEY `FK_entry` (`entry_id`),
    CONSTRAINT `FK_block` FOREIGN KEY (`block_id`) REFERENCES `blocks` (`id`) ON DELETE CASCADE,
    CONSTRAINT `FK_entry` FOREIGN KEY (`entry_id`) REFERENCES `entries` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
