From 463c16beac0ae5667f80b7281ab0fca610ae7619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 26 Jan 2016 22:44:43 +0100 Subject: [PATCH] FEATURE: add custom field resource and possible values to schema --- database/schema.sql | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/database/schema.sql b/database/schema.sql index 6b87396d..46ad3ef6 100644 --- a/database/schema.sql +++ b/database/schema.sql @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- Út 26. leden 2016, 21:53:01 CET +-- Út 26. leden 2016, 22:44:34 CET -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -233,6 +233,16 @@ ENGINE = InnoDB COMMENT = 'List of all custom field types.'; +-- ----------------------------------------------------- +-- Table `custom_field_resource` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `custom_field_resource` ( + `id` INT NOT NULL AUTO_INCREMENT, + `name` VARCHAR(64) NOT NULL COMMENT 'Name of resource for custom fields. Saved as translation string.', + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + -- ----------------------------------------------------- -- Table `custom_fields` -- ----------------------------------------------------- @@ -240,19 +250,27 @@ CREATE TABLE IF NOT EXISTS `custom_fields` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(128) NOT NULL, `type_id` INT NOT NULL COMMENT 'Foreign key to custom_field_types table', + `resource_id` INT NOT NULL, `description` MEDIUMTEXT NULL DEFAULT NULL COMMENT 'Description used for detailed information about meaning of given custom field', `default_value` TEXT NULL DEFAULT NULL, + `possible_values` TEXT NULL DEFAULT NULL COMMENT 'Possible values separated with pipeline', `regexp` MEDIUMTEXT NULL DEFAULT NULL, `min_length` INT(11) NULL DEFAULT NULL, `max_length` INT(11) NULL DEFAULT NULL, `required` TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), INDEX `fk_custom_fields_custom_field_types1_idx` (`type_id` ASC), + INDEX `fk_custom_fields_custom_field_resource1_idx` (`resource_id` ASC), CONSTRAINT `fk_custom_fields_custom_field_types1` FOREIGN KEY (`type_id`) REFERENCES `custom_field_types` (`id`) ON DELETE CASCADE - ON UPDATE CASCADE) + ON UPDATE CASCADE, + CONSTRAINT `fk_custom_fields_custom_field_resource1` + FOREIGN KEY (`resource_id`) + REFERENCES `custom_field_resource` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION) ENGINE = InnoDB COMMENT = 'List of all custom fields which may be used for extending some part of content on webpage'; @@ -280,29 +298,6 @@ CREATE TABLE IF NOT EXISTS `user_has_custom_field` ( ENGINE = InnoDB; --- ----------------------------------------------------- --- Table `module_has_custom_field` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `module_has_custom_field` ( - `module_handler` VARCHAR(255) NOT NULL, - `custom_field_id` INT NOT NULL, - PRIMARY KEY (`module_handler`, `custom_field_id`), - INDEX `fk_module_has_custom_field_custom_field1_idx` (`custom_field_id` ASC), - INDEX `fk_module_has_custom_field_module1_idx` (`module_handler` ASC), - CONSTRAINT `fk_module_has_custom_field_module1` - FOREIGN KEY (`module_handler`) - REFERENCES `modules` (`handler`) - ON DELETE CASCADE - ON UPDATE CASCADE, - CONSTRAINT `fk_module_has_custom_field_custom_field1` - FOREIGN KEY (`custom_field_id`) - REFERENCES `custom_fields` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -COMMENT = 'Table used for assigning different custom fields to different modules. This table does not hold information about any configuration nor values of custom fields. Value is stored in content_has_custom_fields table.'; - - -- ----------------------------------------------------- -- Table `action_log_types` -- -----------------------------------------------------