diff --git a/experiments/schema-annot/PrestaShop.sql b/experiments/schema-annot/PrestaShop.sql deleted file mode 100644 index 8e43aaa4..00000000 --- a/experiments/schema-annot/PrestaShop.sql +++ /dev/null @@ -1,2857 +0,0 @@ -SET - SESSION sql_mode=''; -SET - NAMES 'utf8mb4'; - -CREATE TABLE `PREFIX_accessory` ( - `id_product_1` int(10) unsigned NOT NULL, - `id_product_2` int(10) unsigned NOT NULL, - KEY `accessory_product` (`id_product_1`, `id_product_2`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Address info associated with a user */ -CREATE TABLE `PREFIX_address` ( - `id_address` int(10) unsigned NOT NULL auto_increment, - `id_country` int(10) unsigned NOT NULL, - `id_state` int(10) unsigned DEFAULT NULL, - `id_customer` int(10) unsigned NOT NULL DEFAULT '0', - `id_manufacturer` int(10) unsigned NOT NULL DEFAULT '0', - `id_supplier` int(10) unsigned NOT NULL DEFAULT '0', - `id_warehouse` int(10) unsigned NOT NULL DEFAULT '0', - `alias` varchar(32) NOT NULL, - `company` varchar(255) DEFAULT NULL, - `lastname` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `address1` varchar(128) NOT NULL, - `address2` varchar(128) DEFAULT NULL, - `postcode` varchar(12) DEFAULT NULL, - `city` varchar(64) NOT NULL, - `other` text, - `phone` varchar(32) DEFAULT NULL, - `phone_mobile` varchar(32) DEFAULT NULL, - `vat_number` varchar(32) DEFAULT NULL, - `dni` varchar(16) DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '1', - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_address`), - KEY `address_customer` (`id_customer`), - KEY `id_country` (`id_country`), - KEY `id_state` (`id_state`), - KEY `id_manufacturer` (`id_manufacturer`), - KEY `id_supplier` (`id_supplier`), - KEY `id_warehouse` (`id_warehouse`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Used for search, if a search string is present inside the table, search the alias as well */ -CREATE TABLE `PREFIX_alias` ( - `id_alias` int(10) unsigned NOT NULL auto_increment, - `alias` varchar(191) NOT NULL, - `search` varchar(255) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id_alias`), - UNIQUE KEY `alias` (`alias`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Contains all virtual products (attachements, like images, files, ...) */ -CREATE TABLE `PREFIX_attachment` ( - `id_attachment` int(10) unsigned NOT NULL auto_increment, - `file` varchar(40) NOT NULL, - `file_name` varchar(128) NOT NULL, - `file_size` bigint(10) unsigned NOT NULL DEFAULT '0', - `mime` varchar(128) NOT NULL, - PRIMARY KEY (`id_attachment`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Name / Description linked to an attachment, localised */ -CREATE TABLE `PREFIX_attachment_lang` ( - `id_attachment` int(10) unsigned NOT NULL auto_increment, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(32) DEFAULT NULL, - `description` TEXT, - PRIMARY KEY (`id_attachment`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Relationship between a product and an attachment */ -CREATE TABLE `PREFIX_product_attachment` ( - `id_product` int(10) unsigned NOT NULL, - `id_attachment` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_product`, `id_attachment`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Describe the impact on weight / price of an attribute */ -CREATE TABLE `PREFIX_attribute_impact` ( - `id_attribute_impact` int(10) unsigned NOT NULL auto_increment, - `id_product` int(11) unsigned NOT NULL, - `id_attribute` int(11) unsigned NOT NULL, - `weight` DECIMAL(20, 6) NOT NULL, - `price` DECIMAL(20, 6) NOT NULL, - PRIMARY KEY (`id_attribute_impact`), - UNIQUE KEY `id_product` (`id_product`, `id_attribute`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Describe the carrier informations */ -CREATE TABLE `PREFIX_carrier` ( - `id_carrier` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_reference` int(10) unsigned NOT NULL, - `id_tax_rules_group` int(10) unsigned DEFAULT '0', - `name` varchar(64) NOT NULL, - `url` varchar(255) DEFAULT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - `shipping_handling` tinyint(1) unsigned NOT NULL DEFAULT '1', - `range_behavior` tinyint(1) unsigned NOT NULL DEFAULT '0', - `is_module` tinyint(1) unsigned NOT NULL DEFAULT '0', - `is_free` tinyint(1) unsigned NOT NULL DEFAULT '0', - `shipping_external` tinyint(1) unsigned NOT NULL DEFAULT '0', - `need_range` tinyint(1) unsigned NOT NULL DEFAULT '0', - `external_module_name` varchar(64) DEFAULT NULL, - `shipping_method` int(2) NOT NULL DEFAULT '0', - `position` int(10) unsigned NOT NULL DEFAULT '0', - `max_width` int(10) DEFAULT '0', - `max_height` int(10) DEFAULT '0', - `max_depth` int(10) DEFAULT '0', - `max_weight` DECIMAL(20, 6) DEFAULT '0', - `grade` int(10) DEFAULT '0', - PRIMARY KEY (`id_carrier`), - KEY `deleted` (`deleted`, `active`), - KEY `id_tax_rules_group` (`id_tax_rules_group`), - KEY `reference` ( - `id_reference`, `deleted`, `active` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localization carrier infos */ -CREATE TABLE `PREFIX_carrier_lang` ( - `id_carrier` int(10) unsigned NOT NULL, - `id_shop` int(11) unsigned NOT NULL DEFAULT '1', - `id_lang` int(10) unsigned NOT NULL, - `delay` varchar(512) DEFAULT NULL, - PRIMARY KEY ( - `id_lang`, `id_shop`, `id_carrier` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a zone and a carrier */ -CREATE TABLE `PREFIX_carrier_zone` ( - `id_carrier` int(10) unsigned NOT NULL, - `id_zone` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_carrier`, `id_zone`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Describe the metadata associated with the carts */ -CREATE TABLE `PREFIX_cart` ( - `id_cart` int(10) unsigned NOT NULL auto_increment, - `id_shop_group` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_carrier` int(10) unsigned NOT NULL, - `delivery_option` TEXT NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `id_address_delivery` int(10) unsigned NOT NULL, - `id_address_invoice` int(10) unsigned NOT NULL, - `id_currency` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned NOT NULL, - `id_guest` int(10) unsigned NOT NULL, - `secure_key` varchar(32) NOT NULL DEFAULT '-1', - `recyclable` tinyint(1) unsigned NOT NULL DEFAULT '1', - `gift` tinyint(1) unsigned NOT NULL DEFAULT '0', - `gift_message` text, - `mobile_theme` tinyint(1) NOT NULL DEFAULT '0', - `allow_seperated_package` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `checkout_session_data` MEDIUMTEXT NULL, - PRIMARY KEY (`id_cart`), - KEY `cart_customer` (`id_customer`), - KEY `id_address_delivery` (`id_address_delivery`), - KEY `id_address_invoice` (`id_address_invoice`), - KEY `id_carrier` (`id_carrier`), - KEY `id_lang` (`id_lang`), - KEY `id_currency` (`id_currency`), - KEY `id_guest` (`id_guest`), - KEY `id_shop_group` (`id_shop_group`), - KEY `id_shop_2` (`id_shop`, `date_upd`), - KEY `id_shop` (`id_shop`, `date_add`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Contains all the promo code rules */ -CREATE TABLE `PREFIX_cart_rule` ( - `id_cart_rule` int(10) unsigned NOT NULL auto_increment, - `id_customer` int unsigned NOT NULL DEFAULT '0', - `date_from` datetime NOT NULL, - `date_to` datetime NOT NULL, - `description` text, - `quantity` int(10) unsigned NOT NULL DEFAULT '0', - `quantity_per_user` int(10) unsigned NOT NULL DEFAULT '0', - `priority` int(10) unsigned NOT NULL DEFAULT 1, - `partial_use` tinyint(1) unsigned NOT NULL DEFAULT '0', - `code` varchar(254) NOT NULL, - `minimum_amount` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `minimum_amount_tax` tinyint(1) NOT NULL DEFAULT '0', - `minimum_amount_currency` int unsigned NOT NULL DEFAULT '0', - `minimum_amount_shipping` tinyint(1) NOT NULL DEFAULT '0', - `country_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0', - `carrier_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0', - `group_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0', - `cart_rule_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0', - `product_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0', - `shop_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0', - `free_shipping` tinyint(1) NOT NULL DEFAULT '0', - `reduction_percent` decimal(5, 2) NOT NULL DEFAULT '0.00', - `reduction_amount` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `reduction_tax` tinyint(1) unsigned NOT NULL DEFAULT '0', - `reduction_currency` int(10) unsigned NOT NULL DEFAULT '0', - `reduction_product` int(10) NOT NULL DEFAULT '0', - `reduction_exclude_special` tinyint(1) unsigned NOT NULL DEFAULT '0', - `gift_product` int(10) unsigned NOT NULL DEFAULT '0', - `gift_product_attribute` int(10) unsigned NOT NULL DEFAULT '0', - `highlight` tinyint(1) unsigned NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_cart_rule`), - KEY `id_customer` ( - `id_customer`, `active`, `date_to` - ), - KEY `group_restriction` ( - `group_restriction`, `active`, `date_to` - ), - KEY `id_customer_2` ( - `id_customer`, `active`, `highlight`, - `date_to` - ), - KEY `group_restriction_2` ( - `group_restriction`, `active`, `highlight`, - `date_to` - ), - KEY `date_from` (`date_from`), - KEY `date_to` (`date_to`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized name assocatied with a promo code */ -CREATE TABLE `PREFIX_cart_rule_lang` ( - `id_cart_rule` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(254) NOT NULL, - PRIMARY KEY (`id_cart_rule`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Country associated with a promo code */ -CREATE TABLE `PREFIX_cart_rule_country` ( - `id_cart_rule` int(10) unsigned NOT NULL, - `id_country` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_cart_rule`, `id_country`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* User group associated with a promo code */ -CREATE TABLE `PREFIX_cart_rule_group` ( - `id_cart_rule` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_cart_rule`, `id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Carrier associated with a promo code */ -CREATE TABLE `PREFIX_cart_rule_carrier` ( - `id_cart_rule` int(10) unsigned NOT NULL, - `id_carrier` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_cart_rule`, `id_carrier`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Allowed combination of promo code */ -CREATE TABLE `PREFIX_cart_rule_combination` ( - `id_cart_rule_1` int(10) unsigned NOT NULL, - `id_cart_rule_2` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_cart_rule_1`, `id_cart_rule_2` - ), - KEY `id_cart_rule_1` (`id_cart_rule_1`), - KEY `id_cart_rule_2` (`id_cart_rule_2`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* @TODO : check checkProductRestrictionsFromCart() to understand the code */ -CREATE TABLE `PREFIX_cart_rule_product_rule_group` ( - `id_product_rule_group` int(10) unsigned NOT NULL auto_increment, - `id_cart_rule` int(10) unsigned NOT NULL, - `quantity` int(10) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`id_product_rule_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* @TODO : check checkProductRestrictionsFromCart() to understand the code */ -CREATE TABLE `PREFIX_cart_rule_product_rule` ( - `id_product_rule` int(10) unsigned NOT NULL auto_increment, - `id_product_rule_group` int(10) unsigned NOT NULL, - `type` ENUM( - 'products', 'categories', 'attributes', - 'manufacturers', 'suppliers' - ) NOT NULL, - PRIMARY KEY (`id_product_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* @TODO : check checkProductRestrictionsFromCart() to understand the code */ -CREATE TABLE `PREFIX_cart_rule_product_rule_value` ( - `id_product_rule` int(10) unsigned NOT NULL, - `id_item` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_product_rule`, `id_item`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a cart and a promo code */ -CREATE TABLE `PREFIX_cart_cart_rule` ( - `id_cart` int(10) unsigned NOT NULL, - `id_cart_rule` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_cart`, `id_cart_rule`), - KEY (`id_cart_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a shop and a promo code */ -CREATE TABLE `PREFIX_cart_rule_shop` ( - `id_cart_rule` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_cart_rule`, `id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of products inside a cart */ -CREATE TABLE `PREFIX_cart_product` ( - `id_cart` int(10) unsigned NOT NULL, - `id_product` int(10) unsigned NOT NULL, - `id_address_delivery` int(10) unsigned NOT NULL DEFAULT '0', - `id_shop` int(10) unsigned NOT NULL DEFAULT '1', - `id_product_attribute` int(10) unsigned NOT NULL DEFAULT '0', - `id_customization` int(10) unsigned NOT NULL DEFAULT '0', - `quantity` int(10) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - PRIMARY KEY ( - `id_cart`, `id_product`, `id_product_attribute`, - `id_customization`, `id_address_delivery` - ), - KEY `id_product_attribute` (`id_product_attribute`), - KEY `id_cart_order` ( - `id_cart`, `date_add`, `id_product`, - `id_product_attribute` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of product categories */ -CREATE TABLE `PREFIX_category` ( - `id_category` int(10) unsigned NOT NULL auto_increment, - `id_parent` int(10) unsigned NOT NULL, - `id_shop_default` int(10) unsigned NOT NULL DEFAULT 1, - `level_depth` tinyint(3) unsigned NOT NULL DEFAULT '0', - `nleft` int(10) unsigned NOT NULL DEFAULT '0', - `nright` int(10) unsigned NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - `is_root_category` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_category`), - KEY `category_parent` (`id_parent`), - KEY `nleftrightactive` (`nleft`, `nright`, `active`), - KEY `level_depth` (`level_depth`), - KEY `nright` (`nright`), - KEY `activenleft` (`active`, `nleft`), - KEY `activenright` (`active`, `nright`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a product category and a group of customer */ -CREATE TABLE `PREFIX_category_group` ( - `id_category` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_category`, `id_group`), - KEY `id_category` (`id_category`), - KEY `id_group` (`id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized product category infos */ -CREATE TABLE `PREFIX_category_lang` ( - `id_category` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(128) NOT NULL, - `description` text, - `link_rewrite` varchar(128) NOT NULL, - `meta_title` varchar(255) DEFAULT NULL, - `meta_keywords` varchar(255) DEFAULT NULL, - `meta_description` varchar(512) DEFAULT NULL, - PRIMARY KEY ( - `id_category`, `id_shop`, `id_lang` - ), - KEY `category_name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a product category and a product */ -CREATE TABLE `PREFIX_category_product` ( - `id_category` int(10) unsigned NOT NULL, - `id_product` int(10) unsigned NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_category`, `id_product`), - INDEX (`id_product`), - INDEX (`id_category`, `position`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Information on content block position and category */ -CREATE TABLE `PREFIX_cms` ( - `id_cms` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_cms_category` int(10) unsigned NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `indexation` tinyint(1) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id_cms`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized CMS infos */ -CREATE TABLE `PREFIX_cms_lang` ( - `id_cms` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL DEFAULT '1', - `meta_title` varchar(255) NOT NULL, - `head_seo_title` varchar(255) DEFAULT NULL, - `meta_description` varchar(512) DEFAULT NULL, - `meta_keywords` varchar(255) DEFAULT NULL, - `content` longtext, - `link_rewrite` varchar(128) NOT NULL, - PRIMARY KEY (`id_cms`, `id_shop`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* CMS category informations */ -CREATE TABLE `PREFIX_cms_category` ( - `id_cms_category` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_parent` int(10) unsigned NOT NULL, - `level_depth` tinyint(3) unsigned NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_cms_category`), - KEY `category_parent` (`id_parent`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized CMS category info */ -CREATE TABLE `PREFIX_cms_category_lang` ( - `id_cms_category` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL DEFAULT '1', - `name` varchar(128) NOT NULL, - `description` text, - `link_rewrite` varchar(128) NOT NULL, - `meta_title` varchar(255) DEFAULT NULL, - `meta_keywords` varchar(255) DEFAULT NULL, - `meta_description` varchar(512) DEFAULT NULL, - PRIMARY KEY ( - `id_cms_category`, `id_shop`, `id_lang` - ), - KEY `category_name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a CMS category and a shop */ -CREATE TABLE `PREFIX_cms_category_shop` ( - `id_cms_category` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_cms_category`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Store the configuration, depending on the shop & the group. See configuration.xml to have the list of -existing variables */ -CREATE TABLE `PREFIX_configuration` ( - `id_configuration` int(10) unsigned NOT NULL auto_increment, - `id_shop_group` INT(11) UNSIGNED DEFAULT NULL, - `id_shop` INT(11) UNSIGNED DEFAULT NULL, - `name` varchar(254) NOT NULL, - `value` text, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_configuration`), - KEY `name` (`name`), - KEY `id_shop` (`id_shop`), - KEY `id_shop_group` (`id_shop_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized configuration info */ -CREATE TABLE `PREFIX_configuration_lang` ( - `id_configuration` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `value` text, - `date_upd` datetime DEFAULT NULL, - PRIMARY KEY (`id_configuration`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Store the KPI configuration variables (dashboard) */ -CREATE TABLE `PREFIX_configuration_kpi` ( - `id_configuration_kpi` int(10) unsigned NOT NULL auto_increment, - `id_shop_group` INT(11) UNSIGNED DEFAULT NULL, - `id_shop` INT(11) UNSIGNED DEFAULT NULL, - `name` varchar(64) NOT NULL, - `value` text, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_configuration_kpi`), - KEY `name` (`name`), - KEY `id_shop` (`id_shop`), - KEY `id_shop_group` (`id_shop_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized KPI configuration label */ -CREATE TABLE `PREFIX_configuration_kpi_lang` ( - `id_configuration_kpi` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `value` text, - `date_upd` datetime DEFAULT NULL, - PRIMARY KEY ( - `id_configuration_kpi`, `id_lang` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* User connections log. See PS_STATSDATA_PAGESVIEWS variable */ -CREATE TABLE `PREFIX_connections` ( - `id_connections` int(10) unsigned NOT NULL auto_increment, - `id_shop_group` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_guest` int(10) unsigned NOT NULL, - `id_page` int(10) unsigned NOT NULL, - `ip_address` BIGINT NULL DEFAULT NULL, - `date_add` datetime NOT NULL, - `http_referer` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id_connections`), - KEY `id_guest` (`id_guest`), - KEY `date_add` (`date_add`), - KEY `id_page` (`id_page`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* User connection pages log. See PS_STATSDATA_CUSTOMER_PAGESVIEWS variable */ -CREATE TABLE `PREFIX_connections_page` ( - `id_connections` int(10) unsigned NOT NULL, - `id_page` int(10) unsigned NOT NULL, - `time_start` datetime NOT NULL, - `time_end` datetime DEFAULT NULL, - PRIMARY KEY ( - `id_connections`, `id_page`, `time_start` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* User connection source log. */ -CREATE TABLE `PREFIX_connections_source` ( - `id_connections_source` int(10) unsigned NOT NULL auto_increment, - `id_connections` int(10) unsigned NOT NULL, - `http_referer` varchar(255) DEFAULT NULL, - `request_uri` varchar(255) DEFAULT NULL, - `keywords` varchar(255) DEFAULT NULL, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_connections_source`), - KEY `connections` (`id_connections`), - KEY `orderby` (`date_add`), - KEY `http_referer` (`http_referer`), - KEY `request_uri` (`request_uri`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Store technical contact informations */ -CREATE TABLE `PREFIX_contact` ( - `id_contact` int(10) unsigned NOT NULL auto_increment, - `PII_email` varchar(255) NOT NULL, - `customer_service` tinyint(1) NOT NULL DEFAULT '0', - `position` tinyint(2) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_contact`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized technical contact infos */ -CREATE TABLE `PREFIX_contact_lang` ( - `id_contact` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - `description` text, - PRIMARY KEY (`id_contact`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Country specific data */ -CREATE TABLE `PREFIX_country` ( - `id_country` int(10) unsigned NOT NULL auto_increment, - `id_zone` int(10) unsigned NOT NULL, - `id_currency` int(10) unsigned NOT NULL DEFAULT '0', - `iso_code` varchar(3) NOT NULL, - `call_prefix` int(10) NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `contains_states` tinyint(1) NOT NULL DEFAULT '0', - `need_identification_number` tinyint(1) NOT NULL DEFAULT '0', - `need_zip_code` tinyint(1) NOT NULL DEFAULT '1', - `zip_code_format` varchar(12) NOT NULL DEFAULT '', - `display_tax_label` BOOLEAN NOT NULL, - PRIMARY KEY (`id_country`), - KEY `country_iso_code` (`iso_code`), - KEY `country_` (`id_zone`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized country information */ -CREATE TABLE `PREFIX_country_lang` ( - `id_country` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(64) NOT NULL, - PRIMARY KEY (`id_country`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Currency specification */ -CREATE TABLE `PREFIX_currency` ( - `id_currency` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, /* Deprecated since 1.7.5.0. Use PREFIX_currency_lang.name instead. */ - `iso_code` varchar(3) NOT NULL DEFAULT '0', - `numeric_iso_code` varchar(3), - `precision` int(2) NOT NULL DEFAULT 6, - `conversion_rate` decimal(13,6) NOT NULL, - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '1', - `unofficial` tinyint(1) unsigned NOT NULL DEFAULT '0', - `modified` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_currency`), - KEY `currency_iso_code` (`iso_code`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized currency information */ -CREATE TABLE `PREFIX_currency_lang` ( - `id_currency` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - `symbol` varchar(255) NOT NULL, - `pattern` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id_currency`,`id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customer info */ -CREATE TABLE `PREFIX_customer` ( - `id_customer` int(10) unsigned NOT NULL auto_increment, - `id_shop_group` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_gender` int(10) unsigned NOT NULL, - `id_default_group` int(10) unsigned NOT NULL DEFAULT '1', - `id_lang` int(10) unsigned NULL, - `id_risk` int(10) unsigned NOT NULL DEFAULT '1', - `company` varchar(255), - `siret` varchar(14), - `ape` varchar(5), - `firstname` varchar(255) NOT NULL, - `lastname` varchar(255) NOT NULL, - `PII_email` varchar(255) NOT NULL, - `passwd` varchar(255) NOT NULL, - `last_passwd_gen` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `birthday` date DEFAULT NULL, - `newsletter` tinyint(1) unsigned NOT NULL DEFAULT '0', - `ip_registration_newsletter` varchar(15) DEFAULT NULL, - `newsletter_date_add` datetime DEFAULT NULL, - `optin` tinyint(1) unsigned NOT NULL DEFAULT '0', - `website` varchar(128), - `outstanding_allow_amount` DECIMAL(20, 6) NOT NULL DEFAULT '0.00', - `show_public_prices` tinyint(1) unsigned NOT NULL DEFAULT '0', - `max_payment_days` int(10) unsigned NOT NULL DEFAULT '60', - `secure_key` varchar(32) NOT NULL DEFAULT '-1', - `note` text, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `is_guest` tinyint(1) NOT NULL DEFAULT '0', - `deleted` tinyint(1) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `reset_password_token` varchar(40) DEFAULT NULL, - `reset_password_validity` datetime DEFAULT NULL, - PRIMARY KEY (`id_customer`), - KEY `customer_email` (`email`), - KEY `customer_login` (`email`, `passwd`), - KEY `id_customer_passwd` (`id_customer`, `passwd`), - KEY `id_gender` (`id_gender`), - KEY `id_shop_group` (`id_shop_group`), - KEY `id_shop` (`id_shop`, `date_add`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customer group association */ -CREATE TABLE `PREFIX_customer_group` ( - `id_customer` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_customer`, `id_group`), - INDEX customer_login(id_group), - KEY `id_customer` (`id_customer`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customer support private messaging */ -CREATE TABLE `PREFIX_customer_message` ( - `id_customer_message` int(10) unsigned NOT NULL auto_increment, - `id_customer_thread` int(11) DEFAULT NULL, - `id_employee` int(10) unsigned DEFAULT NULL, - `message` MEDIUMTEXT NOT NULL, - `file_name` varchar(18) DEFAULT NULL, - `ip_address` varchar(16) DEFAULT NULL, - `user_agent` varchar(128) DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `private` TINYINT NOT NULL DEFAULT '0', - `read` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_customer_message`), - KEY `id_customer_thread` (`id_customer_thread`), - KEY `id_employee` (`id_employee`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* store the header of already fetched emails from imap support messaging */ -CREATE TABLE `PREFIX_customer_message_sync_imap` ( - `md5_header` varbinary(32) NOT NULL, - KEY `md5_header_index` ( - `md5_header`(4) - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customer support private messaging */ -CREATE TABLE `PREFIX_customer_thread` ( - `id_customer_thread` int(11) unsigned NOT NULL auto_increment, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_lang` int(10) unsigned NOT NULL, - `id_contact` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned DEFAULT NULL, - `id_order` int(10) unsigned DEFAULT NULL, - `id_product` int(10) unsigned DEFAULT NULL, - `status` enum( - 'open', 'closed', 'pending1', 'pending2' - ) NOT NULL DEFAULT 'open', - `email` varchar(255) NOT NULL, - `token` varchar(12) DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_customer_thread`), - KEY `id_shop` (`id_shop`), - KEY `id_lang` (`id_lang`), - KEY `id_contact` (`id_contact`), - KEY `id_customer` (`id_customer`), - KEY `id_order` (`id_order`), - KEY `id_product` (`id_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customization associated with a purchase (engraving...) */ -CREATE TABLE `PREFIX_customization` ( - `id_customization` int(10) unsigned NOT NULL auto_increment, - `id_product_attribute` int(10) unsigned NOT NULL DEFAULT '0', - `id_address_delivery` int(10) UNSIGNED NOT NULL DEFAULT '0', - `id_cart` int(10) unsigned NOT NULL, - `id_product` int(10) NOT NULL, - `quantity` int(10) NOT NULL, - `quantity_refunded` INT NOT NULL DEFAULT '0', - `quantity_returned` INT NOT NULL DEFAULT '0', - `in_cart` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY ( - `id_customization`, `id_cart`, `id_product`, - `id_address_delivery` - ), - KEY `id_product_attribute` (`id_product_attribute`), - KEY `id_cart_product` ( - `id_cart`, `id_product`, `id_product_attribute` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customization possibility for a product */ -CREATE TABLE `PREFIX_customization_field` ( - `id_customization_field` int(10) unsigned NOT NULL auto_increment, - `id_product` int(10) unsigned NOT NULL, - `type` tinyint(1) NOT NULL, - `required` tinyint(1) NOT NULL, - `is_module` TINYINT(1) NOT NULL DEFAULT '0', - `is_deleted` TINYINT(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_customization_field`), - KEY `id_product` (`id_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized customization fields */ -CREATE TABLE `PREFIX_customization_field_lang` ( - `id_customization_field` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `id_shop` int(10) UNSIGNED NOT NULL DEFAULT '1', - `name` varchar(255) NOT NULL, - PRIMARY KEY ( - `id_customization_field`, `id_lang`, - `id_shop` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Customization content associated with a purchase (e.g. : text to engrave) */ -CREATE TABLE `PREFIX_customized_data` ( - `id_customization` int(10) unsigned NOT NULL, - `type` tinyint(1) NOT NULL, - `index` int(3) NOT NULL, - `value` varchar(255) NOT NULL, - `id_module` int(10) NOT NULL DEFAULT '0', - `price` decimal(20, 6) NOT NULL DEFAULT '0', - `weight` decimal(20, 6) NOT NULL DEFAULT '0', - PRIMARY KEY ( - `id_customization`, `type`, `index` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Date range info (used in PS_STATSDATA_PAGESVIEWS mode) */ -CREATE TABLE `PREFIX_date_range` ( - `id_date_range` int(10) unsigned NOT NULL auto_increment, - `time_start` datetime NOT NULL, - `time_end` datetime NOT NULL, - PRIMARY KEY (`id_date_range`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Delivery info associated with a carrier and a shop */ -CREATE TABLE `PREFIX_delivery` ( - `id_delivery` int(10) unsigned NOT NULL auto_increment, - `id_shop` INT UNSIGNED NULL DEFAULT NULL, - `id_shop_group` INT UNSIGNED NULL DEFAULT NULL, - `id_carrier` int(10) unsigned NOT NULL, - `id_range_price` int(10) unsigned DEFAULT NULL, - `id_range_weight` int(10) unsigned DEFAULT NULL, - `id_zone` int(10) unsigned NOT NULL, - `price` decimal(20, 6) NOT NULL, - PRIMARY KEY (`id_delivery`), - KEY `id_zone` (`id_zone`), - KEY `id_carrier` (`id_carrier`, `id_zone`), - KEY `id_range_price` (`id_range_price`), - KEY `id_range_weight` (`id_range_weight`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Admin users */ -CREATE TABLE `PREFIX_employee` ( - `id_employee` int(10) unsigned NOT NULL auto_increment, - `id_profile` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL DEFAULT '0', - `lastname` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `PII_email` varchar(255) NOT NULL, - `passwd` varchar(255) NOT NULL, - `last_passwd_gen` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `stats_date_from` date DEFAULT NULL, - `stats_date_to` date DEFAULT NULL, - `stats_compare_from` date DEFAULT NULL, - `stats_compare_to` date DEFAULT NULL, - `stats_compare_option` int(1) unsigned NOT NULL DEFAULT 1, - `preselect_date_range` varchar(32) DEFAULT NULL, - `bo_color` varchar(32) DEFAULT NULL, - `bo_theme` varchar(32) DEFAULT NULL, - `bo_css` varchar(64) DEFAULT NULL, - `default_tab` int(10) unsigned NOT NULL DEFAULT '0', - `bo_width` int(10) unsigned NOT NULL DEFAULT '0', - `bo_menu` tinyint(1) NOT NULL DEFAULT '1', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `optin` tinyint(1) unsigned DEFAULT NULL, - `id_last_order` int(10) unsigned NOT NULL DEFAULT '0', - `id_last_customer_message` int(10) unsigned NOT NULL DEFAULT '0', - `id_last_customer` int(10) unsigned NOT NULL DEFAULT '0', - `last_connection_date` date DEFAULT NULL, - `reset_password_token` varchar(40) DEFAULT NULL, - `reset_password_validity` datetime DEFAULT NULL, - PRIMARY KEY (`id_employee`), - KEY `employee_login` (`email`, `passwd`), - KEY `id_employee_passwd` (`id_employee`, `passwd`), - KEY `id_profile` (`id_profile`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Admin users shop */ -CREATE TABLE `PREFIX_employee_shop` ( - `id_employee` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_employee`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Position of each feature */ -CREATE TABLE `PREFIX_feature` ( - `id_feature` int(10) unsigned NOT NULL auto_increment, - `position` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_feature`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized feature info */ -CREATE TABLE `PREFIX_feature_lang` ( - `id_feature` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(128) DEFAULT NULL, - PRIMARY KEY (`id_feature`, `id_lang`), - KEY (`id_lang`, `name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a feature and a product */ -CREATE TABLE `PREFIX_feature_product` ( - `id_feature` int(10) unsigned NOT NULL, - `id_product` int(10) unsigned NOT NULL, - `id_feature_value` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_feature`, `id_product`, `id_feature_value` - ), - KEY `id_feature_value` (`id_feature_value`), - KEY `id_product` (`id_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Various choice associated with a feature */ -CREATE TABLE `PREFIX_feature_value` ( - `id_feature_value` int(10) unsigned NOT NULL auto_increment, - `id_feature` int(10) unsigned NOT NULL, - `custom` tinyint(3) unsigned DEFAULT NULL, - PRIMARY KEY (`id_feature_value`), - KEY `feature` (`id_feature`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized feature choice */ -CREATE TABLE `PREFIX_feature_value_lang` ( - `id_feature_value` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `value` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id_feature_value`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* User titles (e.g. : Mr, Mrs...) */ -CREATE TABLE IF NOT EXISTS `PREFIX_gender` ( - `id_gender` int(11) NOT NULL AUTO_INCREMENT, - `type` tinyint(1) NOT NULL, - PRIMARY KEY (`id_gender`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized user title */ -CREATE TABLE IF NOT EXISTS `PREFIX_gender_lang` ( - `id_gender` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(20) NOT NULL, - PRIMARY KEY (`id_gender`, `id_lang`), - KEY `id_gender` (`id_gender`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Group special price rules */ -CREATE TABLE `PREFIX_group` ( - `id_group` int(10) unsigned NOT NULL auto_increment, - `reduction` decimal(5, 2) NOT NULL DEFAULT '0.00', - `price_display_method` TINYINT NOT NULL DEFAULT '0', - `show_prices` tinyint(1) unsigned NOT NULL DEFAULT '1', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized group info */ -CREATE TABLE `PREFIX_group_lang` ( - `id_group` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(32) NOT NULL, - PRIMARY KEY (`id_group`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Category specific reduction */ -CREATE TABLE `PREFIX_group_reduction` ( - `id_group_reduction` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_group` INT(10) UNSIGNED NOT NULL, - `id_category` INT(10) UNSIGNED NOT NULL, - `reduction` DECIMAL(5, 4) NOT NULL, - PRIMARY KEY (`id_group_reduction`), - UNIQUE KEY(`id_group`, `id_category`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Cache which store product price after reduction */ -CREATE TABLE `PREFIX_product_group_reduction_cache` ( - `id_product` INT UNSIGNED NOT NULL, - `id_group` INT UNSIGNED NOT NULL, - `reduction` DECIMAL(5, 4) NOT NULL, - PRIMARY KEY (`id_product`, `id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Specify a carrier for a given product */ -CREATE TABLE `PREFIX_product_carrier` ( - `id_product` int(10) unsigned NOT NULL, - `id_carrier_reference` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_product`, `id_carrier_reference`, - `id_shop` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Stats from guest user */ -CREATE TABLE `PREFIX_guest` ( - `id_guest` int(10) unsigned NOT NULL auto_increment, - `id_operating_system` int(10) unsigned DEFAULT NULL, - `id_web_browser` int(10) unsigned DEFAULT NULL, - `id_customer` int(10) unsigned DEFAULT NULL, - `javascript` tinyint(1) DEFAULT '0', - `screen_resolution_x` smallint(5) unsigned DEFAULT NULL, - `screen_resolution_y` smallint(5) unsigned DEFAULT NULL, - `screen_color` tinyint(3) unsigned DEFAULT NULL, - `sun_java` tinyint(1) DEFAULT NULL, - `adobe_flash` tinyint(1) DEFAULT NULL, - `adobe_director` tinyint(1) DEFAULT NULL, - `apple_quicktime` tinyint(1) DEFAULT NULL, - `real_player` tinyint(1) DEFAULT NULL, - `windows_media` tinyint(1) DEFAULT NULL, - `accept_language` varchar(8) DEFAULT NULL, - `mobile_theme` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_guest`), - KEY `id_customer` (`id_customer`), - KEY `id_operating_system` (`id_operating_system`), - KEY `id_web_browser` (`id_web_browser`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Store hook description */ -CREATE TABLE `PREFIX_hook` ( - `id_hook` int(10) unsigned NOT NULL auto_increment, - `name` varchar(191) NOT NULL, - `title` varchar(255) NOT NULL, - `description` text, - `position` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id_hook`), - UNIQUE KEY `hook_name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Hook alias name */ -CREATE TABLE `PREFIX_hook_alias` ( - `id_hook_alias` int(10) unsigned NOT NULL auto_increment, - `alias` varchar(191) NOT NULL, - `name` varchar(191) NOT NULL, - PRIMARY KEY (`id_hook_alias`), - UNIQUE KEY `alias` (`alias`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Define registered hook module */ -CREATE TABLE `PREFIX_hook_module` ( - `id_module` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_hook` int(10) unsigned NOT NULL, - `position` tinyint(2) unsigned NOT NULL, - PRIMARY KEY ( - `id_module`, `id_hook`, `id_shop` - ), - KEY `id_hook` (`id_hook`), - KEY `id_module` (`id_module`), - KEY `position` (`id_shop`, `position`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of page type where the hook is not loaded */ -CREATE TABLE `PREFIX_hook_module_exceptions` ( - `id_hook_module_exceptions` int(10) unsigned NOT NULL auto_increment, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_module` int(10) unsigned NOT NULL, - `id_hook` int(10) unsigned NOT NULL, - `file_name` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id_hook_module_exceptions`), - KEY `id_module` (`id_module`), - KEY `id_hook` (`id_hook`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Product image info */ -CREATE TABLE `PREFIX_image` ( - `id_image` int(10) unsigned NOT NULL auto_increment, - `id_product` int(10) unsigned NOT NULL, - `position` smallint(2) unsigned NOT NULL DEFAULT '0', - `cover` tinyint(1) unsigned NULL DEFAULT NULL, - PRIMARY KEY (`id_image`), - KEY `image_product` (`id_product`), - UNIQUE KEY `id_product_cover` (`id_product`, `cover`), - UNIQUE KEY `idx_product_image` ( - `id_image`, `id_product`, `cover` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized product image */ -CREATE TABLE `PREFIX_image_lang` ( - `id_image` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `legend` varchar(128) DEFAULT NULL, - PRIMARY KEY (`id_image`, `id_lang`), - KEY `id_image` (`id_image`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Image type description */ -CREATE TABLE `PREFIX_image_type` ( - `id_image_type` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `width` int(10) unsigned NOT NULL, - `height` int(10) unsigned NOT NULL, - `products` tinyint(1) NOT NULL DEFAULT '1', - `categories` tinyint(1) NOT NULL DEFAULT '1', - `manufacturers` tinyint(1) NOT NULL DEFAULT '1', - `suppliers` tinyint(1) NOT NULL DEFAULT '1', - `stores` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id_image_type`), - KEY `image_type_name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Manufacturer info */ -CREATE TABLE `PREFIX_manufacturer` ( - `id_manufacturer` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_manufacturer`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* localized manufacturer info */ -CREATE TABLE `PREFIX_manufacturer_lang` ( - `id_manufacturer` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `description` text, - `short_description` text, - `meta_title` varchar(255) DEFAULT NULL, - `meta_keywords` varchar(255) DEFAULT NULL, - `meta_description` varchar(512) DEFAULT NULL, - PRIMARY KEY (`id_manufacturer`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Private messaging */ -CREATE TABLE `PREFIX_message` ( - `id_message` int(10) unsigned NOT NULL auto_increment, - `id_cart` int(10) unsigned DEFAULT NULL, - `id_customer` int(10) unsigned NOT NULL, - `id_employee` int(10) unsigned DEFAULT NULL, - `id_order` int(10) unsigned NOT NULL, - `message` text NOT NULL, - `private` tinyint(1) unsigned NOT NULL DEFAULT '1', - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_message`), - KEY `message_order` (`id_order`), - KEY `id_cart` (`id_cart`), - KEY `id_customer` (`id_customer`), - KEY `id_employee` (`id_employee`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Private messaging read flag */ -CREATE TABLE `PREFIX_message_readed` ( - `id_message` int(10) unsigned NOT NULL, - `id_employee` int(10) unsigned NOT NULL, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_message`, `id_employee`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of route type that can be localized */ -CREATE TABLE `PREFIX_meta` ( - `id_meta` int(10) unsigned NOT NULL auto_increment, - `page` varchar(64) NOT NULL, - `configurable` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1', - PRIMARY KEY (`id_meta`), - UNIQUE KEY `page` (`page`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized routes */ -CREATE TABLE `PREFIX_meta_lang` ( - `id_meta` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_lang` int(10) unsigned NOT NULL, - `title` varchar(128) DEFAULT NULL, - `description` varchar(255) DEFAULT NULL, - `keywords` varchar(255) DEFAULT NULL, - `url_rewrite` varchar(254) NOT NULL, - PRIMARY KEY (`id_meta`, `id_shop`, `id_lang`), - KEY `id_shop` (`id_shop`), - KEY `id_lang` (`id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Installed module list */ -CREATE TABLE `PREFIX_module` ( - `id_module` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `version` VARCHAR(8) NOT NULL, - PRIMARY KEY (`id_module`), - UNIQUE KEY `name_UNIQUE` (`name`), - KEY `name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Module / class authorization_role */ -CREATE TABLE `PREFIX_authorization_role` ( - `id_authorization_role` int(10) unsigned NOT NULL auto_increment, - `slug` VARCHAR(191) NOT NULL, - PRIMARY KEY (`id_authorization_role`), - UNIQUE KEY (`slug`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a profile and a tab authorization_role (can be 'CREATE', 'READ', 'UPDATE' or 'DELETE') */ -CREATE TABLE `PREFIX_access` ( - `id_profile` int(10) unsigned NOT NULL, - `id_authorization_role` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_profile`, `id_authorization_role` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Association between a profile and a module authorization_role (can be 'CREATE', 'READ', 'UPDATE' or 'DELETE') */ -CREATE TABLE `PREFIX_module_access` ( - `id_profile` int(10) unsigned NOT NULL, - `id_authorization_role` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_profile`, `id_authorization_role` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* countries allowed for each module (e.g. : countries supported for a payment module) */ -CREATE TABLE `PREFIX_module_country` ( - `id_module` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_country` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_module`, `id_shop`, `id_country` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* currencies allowed for each module */ -CREATE TABLE `PREFIX_module_currency` ( - `id_module` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_currency` int(11) NOT NULL, - PRIMARY KEY ( - `id_module`, `id_shop`, `id_currency` - ), - KEY `id_module` (`id_module`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* groups allowed for each module */ -CREATE TABLE `PREFIX_module_group` ( - `id_module` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_group` int(11) unsigned NOT NULL, - PRIMARY KEY ( - `id_module`, `id_shop`, `id_group` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* carriers allowed for each module */ -CREATE TABLE `PREFIX_module_carrier` ( - `id_module` INT(10) unsigned NOT NULL, - `id_shop` INT(11) unsigned NOT NULL DEFAULT '1', - `id_reference` INT(11) NOT NULL, - PRIMARY KEY ( - `id_module`, `id_shop`, `id_reference` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of OS (used in guest stats) */ -CREATE TABLE `PREFIX_operating_system` ( - `id_operating_system` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) DEFAULT NULL, - PRIMARY KEY (`id_operating_system`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of orders */ -CREATE TABLE `PREFIX_orders` ( - `id_order` int(10) unsigned NOT NULL auto_increment, - `reference` VARCHAR(9), - `id_shop_group` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_carrier` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned NOT NULL, - `id_cart` int(10) unsigned NOT NULL, - `id_currency` int(10) unsigned NOT NULL, - `id_address_delivery` int(10) unsigned NOT NULL, - `id_address_invoice` int(10) unsigned NOT NULL, - `current_state` int(10) unsigned NOT NULL, - `secure_key` varchar(32) NOT NULL DEFAULT '-1', - `payment` varchar(255) NOT NULL, - `conversion_rate` decimal(13, 6) NOT NULL DEFAULT 1, - `module` varchar(255) DEFAULT NULL, - `recyclable` tinyint(1) unsigned NOT NULL DEFAULT '0', - `gift` tinyint(1) unsigned NOT NULL DEFAULT '0', - `gift_message` text, - `mobile_theme` tinyint(1) NOT NULL DEFAULT '0', - `shipping_number` varchar(64) DEFAULT NULL, - `total_discounts` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_discounts_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_discounts_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_paid` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_paid_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_paid_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_paid_real` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_products` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_products_wt` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_shipping` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_shipping_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_shipping_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `carrier_tax_rate` DECIMAL(10, 3) NOT NULL DEFAULT '0.00', - `total_wrapping` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_wrapping_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_wrapping_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `round_mode` tinyint(1) NOT NULL DEFAULT '2', - `round_type` tinyint(1) NOT NULL DEFAULT '1', - `invoice_number` int(10) unsigned NOT NULL DEFAULT '0', - `delivery_number` int(10) unsigned NOT NULL DEFAULT '0', - `invoice_date` datetime NOT NULL, - `delivery_date` datetime NOT NULL, - `valid` int(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_order`), - KEY `reference` (`reference`), - KEY `id_customer` (`id_customer`), - KEY `id_cart` (`id_cart`), - KEY `invoice_number` (`invoice_number`), - KEY `id_carrier` (`id_carrier`), - KEY `id_lang` (`id_lang`), - KEY `id_currency` (`id_currency`), - KEY `id_address_delivery` (`id_address_delivery`), - KEY `id_address_invoice` (`id_address_invoice`), - KEY `id_shop_group` (`id_shop_group`), - KEY (`current_state`), - KEY `id_shop` (`id_shop`), - INDEX `date_add`(`date_add`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Order tax detail */ -CREATE TABLE `PREFIX_order_detail_tax` ( - `id_order_detail` int(11) NOT NULL, - `id_tax` int(11) NOT NULL, - `unit_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', - `total_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', - KEY (`id_order_detail`), - KEY `id_tax` (`id_tax`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* list of invoice */ -CREATE TABLE `PREFIX_order_invoice` ( - `id_order_invoice` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_order` int(11) NOT NULL, - `number` int(11) NOT NULL, - `delivery_number` int(11) NOT NULL, - `delivery_date` datetime, - `total_discount_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_discount_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_paid_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_paid_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_products` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_products_wt` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_shipping_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_shipping_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `shipping_tax_computation_method` int(10) unsigned NOT NULL, - `total_wrapping_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `total_wrapping_tax_incl` decimal(20, 6) NOT NULL DEFAULT '0.00', - `shop_address` text DEFAULT NULL, - `note` text, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_order_invoice`), - KEY `id_order` (`id_order`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* global invoice tax */ -CREATE TABLE IF NOT EXISTS `PREFIX_order_invoice_tax` ( - `id_order_invoice` int(11) NOT NULL, - `type` varchar(15) NOT NULL, - `id_tax` int(11) NOT NULL, - `amount` decimal(10, 6) NOT NULL DEFAULT '0.000000', - KEY `id_tax` (`id_tax`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* order detail (every product inside an order) */ -CREATE TABLE `PREFIX_order_detail` ( - `id_order_detail` int(10) unsigned NOT NULL auto_increment, - `id_order` int(10) unsigned NOT NULL, - `id_order_invoice` int(11) DEFAULT NULL, - `id_warehouse` int(10) unsigned DEFAULT '0', - `id_shop` int(11) unsigned NOT NULL, - `product_id` int(10) unsigned NOT NULL, - `product_attribute_id` int(10) unsigned DEFAULT NULL, - `id_customization` int(10) unsigned DEFAULT 0, - `product_name` varchar(255) NOT NULL, - `product_quantity` int(10) unsigned NOT NULL DEFAULT '0', - `product_quantity_in_stock` int(10) NOT NULL DEFAULT '0', - `product_quantity_refunded` int(10) unsigned NOT NULL DEFAULT '0', - `product_quantity_return` int(10) unsigned NOT NULL DEFAULT '0', - `product_quantity_reinjected` int(10) unsigned NOT NULL DEFAULT '0', - `product_price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `reduction_percent` DECIMAL(5, 2) NOT NULL DEFAULT '0.00', - `reduction_amount` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `reduction_amount_tax_incl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `reduction_amount_tax_excl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `group_reduction` DECIMAL(5, 2) NOT NULL DEFAULT '0.00', - `product_quantity_discount` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `product_ean13` varchar(13) DEFAULT NULL, - `product_isbn` varchar(32) DEFAULT NULL, - `product_upc` varchar(12) DEFAULT NULL, - `product_mpn` varchar(40) DEFAULT NULL, - `product_reference` varchar(64) DEFAULT NULL, - `product_supplier_reference` varchar(64) DEFAULT NULL, - `product_weight` DECIMAL(20, 6) NOT NULL, - `id_tax_rules_group` INT(11) UNSIGNED DEFAULT '0', - `tax_computation_method` tinyint(1) unsigned NOT NULL DEFAULT '0', - `tax_name` varchar(16) NOT NULL, - `tax_rate` DECIMAL(10, 3) NOT NULL DEFAULT '0.000', - `ecotax` decimal(17, 6) NOT NULL DEFAULT '0.000000', - `ecotax_tax_rate` DECIMAL(5, 3) NOT NULL DEFAULT '0.000', - `discount_quantity_applied` TINYINT(1) NOT NULL DEFAULT '0', - `download_hash` varchar(255) DEFAULT NULL, - `download_nb` int(10) unsigned DEFAULT '0', - `download_deadline` datetime DEFAULT NULL, - `total_price_tax_incl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `total_price_tax_excl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `unit_price_tax_incl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `unit_price_tax_excl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `total_shipping_price_tax_incl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `total_shipping_price_tax_excl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `purchase_supplier_price` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `original_product_price` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `original_wholesale_price` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `total_refunded_tax_excl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `total_refunded_tax_incl` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - PRIMARY KEY (`id_order_detail`), - KEY `order_detail_order` (`id_order`), - KEY `product_id` ( - `product_id`, `product_attribute_id` - ), - KEY `product_attribute_id` (`product_attribute_id`), - KEY `id_tax_rules_group` (`id_tax_rules_group`), - KEY `id_order_id_order_detail` (`id_order`, `id_order_detail`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Promo code used in the order */ -CREATE TABLE `PREFIX_order_cart_rule` ( - `id_order_cart_rule` int(10) unsigned NOT NULL auto_increment, - `id_order` int(10) unsigned NOT NULL, - `id_cart_rule` int(10) unsigned NOT NULL, - `id_order_invoice` int(10) unsigned DEFAULT '0', - `name` varchar(254) NOT NULL, - `value` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `value_tax_excl` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `free_shipping` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_order_cart_rule`), - KEY `id_order` (`id_order`), - KEY `id_cart_rule` (`id_cart_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* order transactional information */ -CREATE TABLE `PREFIX_order_history` ( - `id_order_history` int(10) unsigned NOT NULL auto_increment, - `id_employee` int(10) unsigned NOT NULL, - `id_order` int(10) unsigned NOT NULL, - `id_order_state` int(10) unsigned NOT NULL, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_order_history`), - KEY `order_history_order` (`id_order`), - KEY `id_employee` (`id_employee`), - KEY `id_order_state` (`id_order_state`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Type of predefined message that can be inserted to an order */ -CREATE TABLE `PREFIX_order_message` ( - `id_order_message` int(10) unsigned NOT NULL auto_increment, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_order_message`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized predefined order message */ -CREATE TABLE `PREFIX_order_message_lang` ( - `id_order_message` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(128) NOT NULL, - `message` text NOT NULL, - PRIMARY KEY (`id_order_message`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Return state associated with an order */ -CREATE TABLE `PREFIX_order_return` ( - `id_order_return` int(10) unsigned NOT NULL auto_increment, - `id_customer` int(10) unsigned NOT NULL, - `id_order` int(10) unsigned NOT NULL, - `state` tinyint(1) unsigned NOT NULL DEFAULT '1', - `question` text NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_order_return`), - KEY `order_return_customer` (`id_customer`), - KEY `id_order` (`id_order`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Return detail for each product inside an order */ -CREATE TABLE `PREFIX_order_return_detail` ( - `id_order_return` int(10) unsigned NOT NULL, - `id_order_detail` int(10) unsigned NOT NULL, - `id_customization` int(10) unsigned NOT NULL DEFAULT '0', - `product_quantity` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY ( - `id_order_return`, `id_order_detail`, - `id_customization` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of possible return states color */ -CREATE TABLE `PREFIX_order_return_state` ( - `id_order_return_state` int(10) unsigned NOT NULL auto_increment, - `color` varchar(32) DEFAULT NULL, - PRIMARY KEY (`id_order_return_state`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized return states name */ -CREATE TABLE `PREFIX_order_return_state_lang` ( - `id_order_return_state` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(64) NOT NULL, - PRIMARY KEY ( - `id_order_return_state`, `id_lang` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Order slip info */ -CREATE TABLE `PREFIX_order_slip` ( - `id_order_slip` int(10) unsigned NOT NULL auto_increment, - `conversion_rate` decimal(13, 6) NOT NULL DEFAULT 1, - `id_customer` int(10) unsigned NOT NULL, - `id_order` int(10) unsigned NOT NULL, - `total_products_tax_excl` DECIMAL(20, 6) NULL, - `total_products_tax_incl` DECIMAL(20, 6) NULL, - `total_shipping_tax_excl` DECIMAL(20, 6) NULL, - `total_shipping_tax_incl` DECIMAL(20, 6) NULL, - `shipping_cost` tinyint(3) unsigned NOT NULL DEFAULT '0', - `amount` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `shipping_cost_amount` DECIMAL(20, 6) NOT NULL DEFAULT '0.000000', - `partial` TINYINT(1) NOT NULL, - `order_slip_type` TINYINT(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_order_slip`), - KEY `order_slip_customer` (`id_customer`), - KEY `id_order` (`id_order`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Detail of the order slip (every product) */ -CREATE TABLE `PREFIX_order_slip_detail` ( - `id_order_slip` int(10) unsigned NOT NULL, - `id_order_detail` int(10) unsigned NOT NULL, - `product_quantity` int(10) unsigned NOT NULL DEFAULT '0', - `unit_price_tax_excl` DECIMAL(20, 6) NULL, - `unit_price_tax_incl` DECIMAL(20, 6) NULL, - `total_price_tax_excl` DECIMAL(20, 6) NULL, - `total_price_tax_incl` DECIMAL(20, 6), - `amount_tax_excl` DECIMAL(20, 6) DEFAULT NULL, - `amount_tax_incl` DECIMAL(20, 6) DEFAULT NULL, - PRIMARY KEY ( - `id_order_slip`, `id_order_detail` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of available order states */ -CREATE TABLE `PREFIX_order_state` ( - `id_order_state` int(10) UNSIGNED NOT NULL auto_increment, - `invoice` tinyint(1) UNSIGNED DEFAULT '0', - `send_email` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', - `module_name` VARCHAR(255) NULL DEFAULT NULL, - `color` varchar(32) DEFAULT NULL, - `unremovable` tinyint(1) UNSIGNED NOT NULL, - `hidden` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', - `logable` tinyint(1) NOT NULL DEFAULT '0', - `delivery` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', - `shipped` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', - `paid` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', - `pdf_invoice` tinyint(1) UNSIGNED NOT NULL default '0', - `pdf_delivery` tinyint(1) UNSIGNED NOT NULL default '0', - `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (`id_order_state`), - KEY `module_name` (`module_name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized order state */ -CREATE TABLE `PREFIX_order_state_lang` ( - `id_order_state` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(64) NOT NULL, - `template` varchar(64) NOT NULL, - PRIMARY KEY (`id_order_state`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Define which products / quantities define a pack. A product could be a pack */ -CREATE TABLE `PREFIX_pack` ( - `id_product_pack` int(10) unsigned NOT NULL, - `id_product_item` int(10) unsigned NOT NULL, - `id_product_attribute_item` int(10) unsigned NOT NULL, - `quantity` int(10) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY ( - `id_product_pack`, `id_product_item`, - `id_product_attribute_item` - ), - KEY `product_item` ( - `id_product_item`, `id_product_attribute_item` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* page stats (PS_STATSDATA_CUSTOMER_PAGESVIEWS) */ -CREATE TABLE `PREFIX_page` ( - `id_page` int(10) unsigned NOT NULL auto_increment, - `id_page_type` int(10) unsigned NOT NULL, - `id_object` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id_page`), - KEY `id_page_type` (`id_page_type`), - KEY `id_object` (`id_object`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of page type (stats) */ -CREATE TABLE `PREFIX_page_type` ( - `id_page_type` int(10) unsigned NOT NULL auto_increment, - `name` varchar(255) NOT NULL, - PRIMARY KEY (`id_page_type`), - KEY `name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Page viewed (stats) */ -CREATE TABLE `PREFIX_page_viewed` ( - `id_page` int(10) unsigned NOT NULL, - `id_shop_group` INT UNSIGNED NOT NULL DEFAULT '1', - `id_shop` INT UNSIGNED NOT NULL DEFAULT '1', - `id_date_range` int(10) unsigned NOT NULL, - `counter` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_page`, `id_date_range`, `id_shop` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Payment info (see payment_invoice) */ -CREATE TABLE `PREFIX_order_payment` ( - `id_order_payment` INT NOT NULL auto_increment, - `order_reference` VARCHAR(9), - `id_currency` INT UNSIGNED NOT NULL, - `amount` DECIMAL(20, 6) NOT NULL, - `payment_method` varchar(255) NOT NULL, - `conversion_rate` decimal(13, 6) NOT NULL DEFAULT 1, - `transaction_id` VARCHAR(254) NULL, - `card_number` VARCHAR(254) NULL, - `card_brand` VARCHAR(254) NULL, - `card_expiration` CHAR(7) NULL, - `card_holder` VARCHAR(254) NULL, - `date_add` DATETIME NOT NULL, - PRIMARY KEY (`id_order_payment`), - KEY `order_reference`(`order_reference`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* list of products */ -CREATE TABLE `PREFIX_product` ( - `id_product` int(10) unsigned NOT NULL auto_increment, - `id_supplier` int(10) unsigned DEFAULT NULL, - `id_manufacturer` int(10) unsigned DEFAULT NULL, - `id_category_default` int(10) unsigned DEFAULT NULL, - `id_shop_default` int(10) unsigned NOT NULL DEFAULT 1, - `id_tax_rules_group` INT(11) UNSIGNED NOT NULL, - `on_sale` tinyint(1) unsigned NOT NULL DEFAULT '0', - `online_only` tinyint(1) unsigned NOT NULL DEFAULT '0', - `ean13` varchar(13) DEFAULT NULL, - `isbn` varchar(32) DEFAULT NULL, - `upc` varchar(12) DEFAULT NULL, - `mpn` varchar(40) DEFAULT NULL, - `ecotax` decimal(17, 6) NOT NULL DEFAULT '0.00', - `quantity` int(10) NOT NULL DEFAULT '0', - `minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1', - `low_stock_threshold` int(10) NULL DEFAULT NULL, - `low_stock_alert` TINYINT(1) NOT NULL DEFAULT 0, - `price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `wholesale_price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `unity` varchar(255) DEFAULT NULL, - `unit_price_ratio` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `additional_shipping_cost` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `reference` varchar(64) DEFAULT NULL, - `supplier_reference` varchar(64) DEFAULT NULL, - `location` varchar(64) DEFAULT NULL, - `width` DECIMAL(20, 6) NOT NULL DEFAULT '0', - `height` DECIMAL(20, 6) NOT NULL DEFAULT '0', - `depth` DECIMAL(20, 6) NOT NULL DEFAULT '0', - `weight` DECIMAL(20, 6) NOT NULL DEFAULT '0', - `out_of_stock` int(10) unsigned NOT NULL DEFAULT '2', - `additional_delivery_times` tinyint(1) unsigned NOT NULL DEFAULT '1', - `quantity_discount` tinyint(1) DEFAULT '0', - `customizable` tinyint(2) NOT NULL DEFAULT '0', - `uploadable_files` tinyint(4) NOT NULL DEFAULT '0', - `text_fields` tinyint(4) NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `redirect_type` ENUM( - '', '404', '301-product', '302-product', - '301-category', '302-category' - ) NOT NULL DEFAULT '', - `id_type_redirected` int(10) unsigned NOT NULL DEFAULT '0', - `available_for_order` tinyint(1) NOT NULL DEFAULT '1', - `available_date` date DEFAULT NULL, - `show_condition` tinyint(1) NOT NULL DEFAULT '0', - `condition` ENUM('new', 'used', 'refurbished') NOT NULL DEFAULT 'new', - `show_price` tinyint(1) NOT NULL DEFAULT '1', - `indexed` tinyint(1) NOT NULL DEFAULT '0', - `visibility` ENUM( - 'both', 'catalog', 'search', 'none' - ) NOT NULL DEFAULT 'both', - `cache_is_pack` tinyint(1) NOT NULL DEFAULT '0', - `cache_has_attachments` tinyint(1) NOT NULL DEFAULT '0', - `is_virtual` tinyint(1) NOT NULL DEFAULT '0', - `cache_default_attribute` int(10) unsigned DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `advanced_stock_management` tinyint(1) DEFAULT '0' NOT NULL, - `pack_stock_type` int(11) unsigned DEFAULT '3' NOT NULL, - `state` int(11) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id_product`), - INDEX reference_idx(`reference`), - INDEX supplier_reference_idx(`supplier_reference`), - KEY `product_supplier` (`id_supplier`), - KEY `product_manufacturer` (`id_manufacturer`, `id_product`), - KEY `id_category_default` (`id_category_default`), - KEY `indexed` (`indexed`), - KEY `date_add` (`date_add`), - KEY `state` (`state`, `date_upd`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* shop specific product info */ -CREATE TABLE IF NOT EXISTS `PREFIX_product_shop` ( - `id_product` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL, - `id_category_default` int(10) unsigned DEFAULT NULL, - `id_tax_rules_group` INT(11) UNSIGNED NOT NULL, - `on_sale` tinyint(1) unsigned NOT NULL DEFAULT '0', - `online_only` tinyint(1) unsigned NOT NULL DEFAULT '0', - `ecotax` decimal(17, 6) NOT NULL DEFAULT '0.000000', - `minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1', - `low_stock_threshold` int(10) NULL DEFAULT NULL, - `low_stock_alert` TINYINT(1) NOT NULL DEFAULT 0, - `price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `wholesale_price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `unity` varchar(255) DEFAULT NULL, - `unit_price_ratio` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `additional_shipping_cost` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `customizable` tinyint(2) NOT NULL DEFAULT '0', - `uploadable_files` tinyint(4) NOT NULL DEFAULT '0', - `text_fields` tinyint(4) NOT NULL DEFAULT '0', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `redirect_type` ENUM( - '', '404', '301-product', '302-product', - '301-category', '302-category' - ) NOT NULL DEFAULT '', - `id_type_redirected` int(10) unsigned NOT NULL DEFAULT '0', - `available_for_order` tinyint(1) NOT NULL DEFAULT '1', - `available_date` date DEFAULT NULL, - `show_condition` tinyint(1) NOT NULL DEFAULT '1', - `condition` enum('new', 'used', 'refurbished') NOT NULL DEFAULT 'new', - `show_price` tinyint(1) NOT NULL DEFAULT '1', - `indexed` tinyint(1) NOT NULL DEFAULT '0', - `visibility` enum( - 'both', 'catalog', 'search', 'none' - ) NOT NULL DEFAULT 'both', - `cache_default_attribute` int(10) unsigned DEFAULT NULL, - `advanced_stock_management` tinyint(1) DEFAULT '0' NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `pack_stock_type` int(11) unsigned DEFAULT '3' NOT NULL, - PRIMARY KEY (`id_product`, `id_shop`), - KEY `id_category_default` (`id_category_default`), - KEY `date_add` ( - `date_add`, `active`, `visibility` - ), - KEY `indexed` ( - `indexed`, `active`, `id_product` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* list of product attributes (E.g. : color) */ -CREATE TABLE `PREFIX_product_attribute` ( - `id_product_attribute` int(10) unsigned NOT NULL auto_increment, - `id_product` int(10) unsigned NOT NULL, - `reference` varchar(64) DEFAULT NULL, - `supplier_reference` varchar(64) DEFAULT NULL, - `location` varchar(64) DEFAULT NULL, - `ean13` varchar(13) DEFAULT NULL, - `isbn` varchar(32) DEFAULT NULL, - `upc` varchar(12) DEFAULT NULL, - `mpn` varchar(40) DEFAULT NULL, - `wholesale_price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `ecotax` decimal(17, 6) NOT NULL DEFAULT '0.00', - `quantity` int(10) NOT NULL DEFAULT '0', - `weight` DECIMAL(20, 6) NOT NULL DEFAULT '0', - `unit_price_impact` DECIMAL(20, 6) NOT NULL DEFAULT '0.00', - `default_on` tinyint(1) unsigned NULL DEFAULT NULL, - `minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1', - `low_stock_threshold` int(10) NULL DEFAULT NULL, - `low_stock_alert` TINYINT(1) NOT NULL DEFAULT 0, - `available_date` date DEFAULT NULL, - PRIMARY KEY (`id_product_attribute`), - KEY `product_attribute_product` (`id_product`), - KEY `reference` (`reference`), - KEY `supplier_reference` (`supplier_reference`), - UNIQUE KEY `product_default` (`id_product`, `default_on`), - KEY `id_product_id_product_attribute` ( - `id_product_attribute`, `id_product` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* shop specific attribute info */ -CREATE TABLE `PREFIX_product_attribute_shop` ( - `id_product` int(10) unsigned NOT NULL, - `id_product_attribute` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL, - `wholesale_price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `price` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `ecotax` decimal(17, 6) NOT NULL DEFAULT '0.00', - `weight` DECIMAL(20, 6) NOT NULL DEFAULT '0', - `unit_price_impact` DECIMAL(20, 6) NOT NULL DEFAULT '0.00', - `default_on` tinyint(1) unsigned NULL DEFAULT NULL, - `minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1', - `low_stock_threshold` int(10) NULL DEFAULT NULL, - `low_stock_alert` TINYINT(1) NOT NULL DEFAULT 0, - `available_date` date DEFAULT NULL, - PRIMARY KEY ( - `id_product_attribute`, `id_shop` - ), - UNIQUE KEY `id_product` ( - `id_product`, `id_shop`, `default_on` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* association between attribute and combination */ -CREATE TABLE `PREFIX_product_attribute_combination` ( - `id_attribute` int(10) unsigned NOT NULL, - `id_product_attribute` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_attribute`, `id_product_attribute` - ), - KEY `id_product_attribute` (`id_product_attribute`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* image associated with an attribute */ -CREATE TABLE `PREFIX_product_attribute_image` ( - `id_product_attribute` int(10) unsigned NOT NULL, - `id_image` int(10) unsigned NOT NULL, - PRIMARY KEY ( - `id_product_attribute`, `id_image` - ), - KEY `id_image` (`id_image`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Virtual product download info */ -CREATE TABLE `PREFIX_product_download` ( - `id_product_download` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_product` int(10) unsigned NOT NULL, - `display_filename` varchar(255) DEFAULT NULL, - `filename` varchar(255) DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_expiration` datetime DEFAULT NULL, - `nb_days_accessible` int(10) unsigned DEFAULT NULL, - `nb_downloadable` int(10) unsigned DEFAULT '1', - `active` tinyint(1) unsigned NOT NULL DEFAULT '1', - `is_shareable` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_product_download`), - KEY `product_active` (`id_product`, `active`), - UNIQUE KEY `id_product` (`id_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized product info */ -CREATE TABLE `PREFIX_product_lang` ( - `id_product` int(10) unsigned NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_lang` int(10) unsigned NOT NULL, - `description` text, - `description_short` text, - `link_rewrite` varchar(128) NOT NULL, - `meta_description` varchar(512) DEFAULT NULL, - `meta_keywords` varchar(255) DEFAULT NULL, - `meta_title` varchar(128) DEFAULT NULL, - `name` varchar(128) NOT NULL, - `available_now` varchar(255) DEFAULT NULL, - `available_later` varchar(255) DEFAULT NULL, - `delivery_in_stock` varchar(255) DEFAULT NULL, - `delivery_out_stock` varchar(255) DEFAULT NULL, - PRIMARY KEY ( - `id_product`, `id_shop`, `id_lang` - ), - KEY `id_lang` (`id_lang`), - KEY `name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* info about number of products sold */ -CREATE TABLE `PREFIX_product_sale` ( - `id_product` int(10) unsigned NOT NULL, - `quantity` int(10) unsigned NOT NULL DEFAULT '0', - `sale_nbr` int(10) unsigned NOT NULL DEFAULT '0', - `date_upd` date DEFAULT NULL, - PRIMARY KEY (`id_product`), - KEY `quantity` (`quantity`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* tags associated with a product */ -CREATE TABLE `PREFIX_product_tag` ( - `id_product` int(10) unsigned NOT NULL, - `id_tag` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_product`, `id_tag`), - KEY `id_tag` (`id_tag`), - KEY `id_lang` (`id_lang`, `id_tag`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of profile (admin, superadmin, etc...) */ -CREATE TABLE `PREFIX_profile` ( - `id_profile` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id_profile`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized profile names */ -CREATE TABLE `PREFIX_profile_lang` ( - `id_lang` int(10) unsigned NOT NULL, - `id_profile` int(10) unsigned NOT NULL, - `name` varchar(128) NOT NULL, - PRIMARY KEY (`id_profile`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of quick access link used in the admin */ -CREATE TABLE `PREFIX_quick_access` ( - `id_quick_access` int(10) unsigned NOT NULL auto_increment, - `new_window` tinyint(1) NOT NULL DEFAULT '0', - `link` varchar(255) NOT NULL, - PRIMARY KEY (`id_quick_access`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized quick access names */ -CREATE TABLE `PREFIX_quick_access_lang` ( - `id_quick_access` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(32) NOT NULL, - PRIMARY KEY (`id_quick_access`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* price ranges used for delivery */ -CREATE TABLE `PREFIX_range_price` ( - `id_range_price` int(10) unsigned NOT NULL auto_increment, - `id_carrier` int(10) unsigned NOT NULL, - `delimiter1` decimal(20, 6) NOT NULL, - `delimiter2` decimal(20, 6) NOT NULL, - PRIMARY KEY (`id_range_price`), - UNIQUE KEY `id_carrier` ( - `id_carrier`, `delimiter1`, `delimiter2` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Weight ranges used for delivery */ -CREATE TABLE `PREFIX_range_weight` ( - `id_range_weight` int(10) unsigned NOT NULL auto_increment, - `id_carrier` int(10) unsigned NOT NULL, - `delimiter1` decimal(20, 6) NOT NULL, - `delimiter2` decimal(20, 6) NOT NULL, - PRIMARY KEY (`id_range_weight`), - UNIQUE KEY `id_carrier` ( - `id_carrier`, `delimiter1`, `delimiter2` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Referrer stats */ -CREATE TABLE `PREFIX_referrer` ( - `id_referrer` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `passwd` varchar(255) DEFAULT NULL, - `http_referer_regexp` varchar(64) DEFAULT NULL, - `http_referer_like` varchar(64) DEFAULT NULL, - `request_uri_regexp` varchar(64) DEFAULT NULL, - `request_uri_like` varchar(64) DEFAULT NULL, - `http_referer_regexp_not` varchar(64) DEFAULT NULL, - `http_referer_like_not` varchar(64) DEFAULT NULL, - `request_uri_regexp_not` varchar(64) DEFAULT NULL, - `request_uri_like_not` varchar(64) DEFAULT NULL, - `base_fee` decimal(5, 2) NOT NULL DEFAULT '0.00', - `percent_fee` decimal(5, 2) NOT NULL DEFAULT '0.00', - `click_fee` decimal(5, 2) NOT NULL DEFAULT '0.00', - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_referrer`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Referrer cache (stats) */ -CREATE TABLE `PREFIX_referrer_cache` ( - `id_connections_source` int(11) unsigned NOT NULL, - `id_referrer` int(11) unsigned NOT NULL, - PRIMARY KEY ( - `id_connections_source`, `id_referrer` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Referrer shop info (stats) */ -CREATE TABLE `PREFIX_referrer_shop` ( - `id_referrer` int(10) unsigned NOT NULL auto_increment, - `id_shop` int(10) unsigned NOT NULL DEFAULT '1', - `cache_visitors` int(11) DEFAULT NULL, - `cache_visits` int(11) DEFAULT NULL, - `cache_pages` int(11) DEFAULT NULL, - `cache_registrations` int(11) DEFAULT NULL, - `cache_orders` int(11) DEFAULT NULL, - `cache_sales` decimal(17, 2) DEFAULT NULL, - `cache_reg_rate` decimal(5, 4) DEFAULT NULL, - `cache_order_rate` decimal(5, 4) DEFAULT NULL, - PRIMARY KEY (`id_referrer`, `id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of custom SQL request saved on the admin (used to generate exports) */ -CREATE TABLE IF NOT EXISTS `PREFIX_request_sql` ( - `id_request_sql` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(200) NOT NULL, - `sql` text NOT NULL, - PRIMARY KEY (`id_request_sql`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of search engine + query string (used by SEO module) */ -CREATE TABLE `PREFIX_search_engine` ( - `id_search_engine` int(10) unsigned NOT NULL auto_increment, - `server` varchar(64) NOT NULL, - `getvar` varchar(16) NOT NULL, - PRIMARY KEY (`id_search_engine`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Index constructed by the search engine */ -CREATE TABLE `PREFIX_search_index` ( - `id_product` int(11) unsigned NOT NULL, - `id_word` int(11) unsigned NOT NULL, - `weight` smallint(4) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`id_word`, `id_product`), - KEY `id_product` (`id_product`, `weight`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of words available for a given shop & lang */ -CREATE TABLE `PREFIX_search_word` ( - `id_word` int(10) unsigned NOT NULL auto_increment, - `id_shop` int(11) unsigned NOT NULL DEFAULT 1, - `id_lang` int(10) unsigned NOT NULL, - `word` varchar(30) NOT NULL, - PRIMARY KEY (`id_word`), - UNIQUE KEY `id_lang` (`id_lang`, `id_shop`, `word`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of price reduction depending on given conditions */ -CREATE TABLE `PREFIX_specific_price` ( - `id_specific_price` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_specific_price_rule` INT(11) UNSIGNED NOT NULL, - `id_cart` INT(11) UNSIGNED NOT NULL, - `id_product` INT UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_shop_group` INT(11) UNSIGNED NOT NULL, - `id_currency` INT UNSIGNED NOT NULL, - `id_country` INT UNSIGNED NOT NULL, - `id_group` INT UNSIGNED NOT NULL, - `id_customer` INT UNSIGNED NOT NULL, - `id_product_attribute` INT UNSIGNED NOT NULL, - `price` DECIMAL(20, 6) NOT NULL, - `from_quantity` mediumint(8) UNSIGNED NOT NULL, - `reduction` DECIMAL(20, 6) NOT NULL, - `reduction_tax` tinyint(1) NOT NULL DEFAULT 1, - `reduction_type` ENUM('amount', 'percentage') NOT NULL, - `from` DATETIME NOT NULL, - `to` DATETIME NOT NULL, - PRIMARY KEY (`id_specific_price`), - KEY ( - `id_product`, `id_shop`, `id_currency`, - `id_country`, `id_group`, `id_customer`, - `from_quantity`, `from`, `to` - ), - KEY `from_quantity` (`from_quantity`), - KEY (`id_specific_price_rule`), - KEY (`id_cart`), - KEY `id_product_attribute` (`id_product_attribute`), - KEY `id_shop` (`id_shop`), - KEY `id_customer` (`id_customer`), - KEY `from` (`from`), - KEY `to` (`to`), - UNIQUE KEY `id_product_2` ( - `id_product`, `id_product_attribute`, - `id_customer`, `id_cart`, `from`, - `to`, `id_shop`, `id_shop_group`, - `id_currency`, `id_country`, `id_group`, - `from_quantity`, `id_specific_price_rule` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* State localization info */ -CREATE TABLE `PREFIX_state` ( - `id_state` int(10) unsigned NOT NULL auto_increment, - `id_country` int(11) unsigned NOT NULL, - `id_zone` int(11) unsigned NOT NULL, - `name` varchar(64) NOT NULL, - `iso_code` varchar(7) NOT NULL, - `tax_behavior` smallint(1) NOT NULL DEFAULT '0', - `active` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_state`), - KEY `id_country` (`id_country`), - KEY `name` (`name`), - KEY `id_zone` (`id_zone`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of suppliers */ -CREATE TABLE `PREFIX_supplier` ( - `id_supplier` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id_supplier`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized supplier data */ -CREATE TABLE `PREFIX_supplier_lang` ( - `id_supplier` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `description` text, - `meta_title` varchar(255) DEFAULT NULL, - `meta_keywords` varchar(255) DEFAULT NULL, - `meta_description` varchar(512) DEFAULT NULL, - PRIMARY KEY (`id_supplier`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of tags */ -CREATE TABLE `PREFIX_tag` ( - `id_tag` int(10) unsigned NOT NULL auto_increment, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(32) NOT NULL, - PRIMARY KEY (`id_tag`), - KEY `tag_name` (`name`), - KEY `id_lang` (`id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Count info associated with each tag depending on lang, group & shop (cloud tags) */ -CREATE TABLE `PREFIX_tag_count` ( - `id_group` int(10) unsigned NOT NULL DEFAULT 0, - `id_tag` int(10) unsigned NOT NULL DEFAULT 0, - `id_lang` int(10) unsigned NOT NULL DEFAULT 0, - `id_shop` int(11) unsigned NOT NULL DEFAULT 0, - `counter` int(10) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`id_group`, `id_tag`), - KEY ( - `id_group`, `id_lang`, `id_shop`, - `counter` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of taxes */ -CREATE TABLE `PREFIX_tax` ( - `id_tax` int(10) unsigned NOT NULL auto_increment, - `rate` DECIMAL(10, 3) NOT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '1', - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_tax`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Localized tax names */ -CREATE TABLE `PREFIX_tax_lang` ( - `id_tax` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(32) NOT NULL, - PRIMARY KEY (`id_tax`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of timezone */ -CREATE TABLE `PREFIX_timezone` ( - id_timezone int(10) unsigned NOT NULL auto_increment, - name VARCHAR(32) NOT NULL, - PRIMARY KEY (`id_timezone`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of web browsers */ -CREATE TABLE `PREFIX_web_browser` ( - `id_web_browser` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) DEFAULT NULL, - PRIMARY KEY (`id_web_browser`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of geographic zones */ -CREATE TABLE `PREFIX_zone` ( - `id_zone` int(10) unsigned NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_zone`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Carrier available for a specific group */ -CREATE TABLE `PREFIX_carrier_group` ( - `id_carrier` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_carrier`, `id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* List of stores */ -CREATE TABLE `PREFIX_store` ( - `id_store` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_country` int(10) unsigned NOT NULL, - `id_state` int(10) unsigned DEFAULT NULL, - `city` varchar(64) NOT NULL, - `postcode` varchar(12) NOT NULL, - `latitude` decimal(13, 8) DEFAULT NULL, - `longitude` decimal(13, 8) DEFAULT NULL, - `phone` varchar(16) DEFAULT NULL, - `fax` varchar(16) DEFAULT NULL, - `email` varchar(255) DEFAULT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_store`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_store_lang` ( - `id_store` int(11) unsigned NOT NULL, - `id_lang` int(11) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - `address1` varchar(255) NOT NULL, - `address2` varchar(255) DEFAULT NULL, - `hours` text, - `note` text, - PRIMARY KEY (`id_store`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Webservice account infos */ -CREATE TABLE `PREFIX_webservice_account` ( - `id_webservice_account` int(11) NOT NULL AUTO_INCREMENT, - `key` varchar(32) NOT NULL, - `description` text NULL, - `class_name` VARCHAR(50) NOT NULL DEFAULT 'WebserviceRequest', - `is_module` TINYINT(2) NOT NULL DEFAULT '0', - `module_name` VARCHAR(50) NULL DEFAULT NULL, - `active` tinyint(2) NOT NULL, - PRIMARY KEY (`id_webservice_account`), - KEY `key` (`key`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -/* Permissions associated with a webservice account */ -CREATE TABLE `PREFIX_webservice_permission` ( - `id_webservice_permission` int(11) NOT NULL AUTO_INCREMENT, - `resource` varchar(50) NOT NULL, - `method` enum( - 'GET', 'POST', 'PUT', 'DELETE', 'HEAD' - ) NOT NULL, - `id_webservice_account` int(11) NOT NULL, - PRIMARY KEY (`id_webservice_permission`), - UNIQUE KEY `resource_2` ( - `resource`, `method`, `id_webservice_account` - ), - KEY `resource` (`resource`), - KEY `method` (`method`), - KEY `id_webservice_account` (`id_webservice_account`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_required_field` ( - `id_required_field` int(11) NOT NULL AUTO_INCREMENT, - `object_name` varchar(32) NOT NULL, - `field_name` varchar(32) NOT NULL, - PRIMARY KEY (`id_required_field`), - KEY `object_name` (`object_name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_memcached_servers` ( - `id_memcached_server` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - `ip` VARCHAR(254) NOT NULL, - `port` INT(11) UNSIGNED NOT NULL, - `weight` INT(11) UNSIGNED NOT NULL -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_product_country_tax` ( - `id_product` int(11) NOT NULL, - `id_country` int(11) NOT NULL, - `id_tax` int(11) NOT NULL, - PRIMARY KEY (`id_product`, `id_country`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_tax_rule` ( - `id_tax_rule` int(11) NOT NULL AUTO_INCREMENT, - `id_tax_rules_group` int(11) NOT NULL, - `id_country` int(11) NOT NULL, - `id_state` int(11) NOT NULL, - `zipcode_from` VARCHAR(12) NOT NULL, - `zipcode_to` VARCHAR(12) NOT NULL, - `id_tax` int(11) NOT NULL, - `behavior` int(11) NOT NULL, - `description` VARCHAR(100) NOT NULL, - PRIMARY KEY (`id_tax_rule`), - KEY `id_tax_rules_group` (`id_tax_rules_group`), - KEY `id_tax` (`id_tax`), - KEY `category_getproducts` ( - `id_tax_rules_group`, `id_country`, - `id_state`, `zipcode_from` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_tax_rules_group` ( - `id_tax_rules_group` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `name` VARCHAR(50) NOT NULL, - `active` INT NOT NULL, - `deleted` TINYINT(1) UNSIGNED NOT NULL, - `date_add` DATETIME NOT NULL, - `date_upd` DATETIME NOT NULL -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_specific_price_priority` ( - `id_specific_price_priority` INT NOT NULL AUTO_INCREMENT, - `id_product` INT NOT NULL, - `priority` VARCHAR(80) NOT NULL, - PRIMARY KEY ( - `id_specific_price_priority`, `id_product` - ), - UNIQUE KEY `id_product` (`id_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_log` ( - `id_log` int(10) unsigned NOT NULL AUTO_INCREMENT, - `severity` tinyint(1) NOT NULL, - `error_code` int(11) DEFAULT NULL, - `message` text NOT NULL, - `object_type` varchar(32) DEFAULT NULL, - `object_id` int(10) unsigned DEFAULT NULL, - `id_employee` int(10) unsigned DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_log`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_import_match` ( - `id_import_match` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(32) NOT NULL, - `match` text NOT NULL, - `skip` int(2) NOT NULL, - PRIMARY KEY (`id_import_match`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_shop_url` ( - `id_shop_url` int(11) unsigned NOT NULL AUTO_INCREMENT, - `id_shop` int(11) unsigned NOT NULL, - `domain` varchar(150) NOT NULL, - `domain_ssl` varchar(150) NOT NULL, - `physical_uri` varchar(64) NOT NULL, - `virtual_uri` varchar(64) NOT NULL, - `main` TINYINT(1) NOT NULL, - `active` TINYINT(1) NOT NULL, - PRIMARY KEY (`id_shop_url`), - KEY `id_shop` (`id_shop`, `main`), - UNIQUE KEY `full_shop_url` ( - `domain`, `physical_uri`, `virtual_uri` - ), - UNIQUE KEY `full_shop_url_ssl` ( - `domain_ssl`, `physical_uri`, `virtual_uri` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_country_shop` ( - `id_country` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_country`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_carrier_shop` ( - `id_carrier` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_carrier`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_address_format` ( - `id_country` int(10) unsigned NOT NULL, - `format` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id_country`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_cms_shop` ( - `id_cms` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_cms`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_currency_shop` ( - `id_currency` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - `conversion_rate` decimal(13, 6) NOT NULL, - PRIMARY KEY (`id_currency`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_contact_shop` ( - `id_contact` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_contact`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_image_shop` ( - `id_product` int(10) unsigned NOT NULL, - `id_image` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - `cover` tinyint(1) UNSIGNED NULL DEFAULT NULL, - PRIMARY KEY (`id_image`, `id_shop`), - UNIQUE KEY `id_product` (`id_product`, `id_shop`, `cover`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_feature_shop` ( - `id_feature` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_feature`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_group_shop` ( - `id_group` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_group`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_tax_rules_group_shop` ( - `id_tax_rules_group` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_tax_rules_group`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_zone_shop` ( - `id_zone` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_zone`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_manufacturer_shop` ( - `id_manufacturer` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_manufacturer`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supplier_shop` ( - `id_supplier` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_supplier`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_store_shop` ( - `id_store` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_store`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_module_shop` ( - `id_module` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - `enable_device` TINYINT(1) NOT NULL DEFAULT '7', - PRIMARY KEY (`id_module`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_webservice_account_shop` ( - `id_webservice_account` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY ( - `id_webservice_account`, `id_shop` - ), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_stock_mvt_reason` ( - `id_stock_mvt_reason` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `sign` tinyint(1) NOT NULL DEFAULT 1, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_stock_mvt_reason`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_stock_mvt_reason_lang` ( - `id_stock_mvt_reason` INT(11) UNSIGNED NOT NULL, - `id_lang` INT(11) UNSIGNED NOT NULL, - `name` VARCHAR(255) CHARACTER SET utf8 NOT NULL, - PRIMARY KEY ( - `id_stock_mvt_reason`, `id_lang` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_stock` ( - `id_stock` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_warehouse` INT(11) UNSIGNED NOT NULL, - `id_product` INT(11) UNSIGNED NOT NULL, - `id_product_attribute` INT(11) UNSIGNED NOT NULL, - `reference` VARCHAR(64) NOT NULL, - `ean13` VARCHAR(13) DEFAULT NULL, - `isbn` VARCHAR(32) DEFAULT NULL, - `upc` VARCHAR(12) DEFAULT NULL, - `mpn` VARCHAR(40) DEFAULT NULL, - `physical_quantity` INT(11) UNSIGNED NOT NULL, - `usable_quantity` INT(11) UNSIGNED NOT NULL, - `price_te` DECIMAL(20, 6) DEFAULT '0.000000', - PRIMARY KEY (`id_stock`), - KEY `id_warehouse` (`id_warehouse`), - KEY `id_product` (`id_product`), - KEY `id_product_attribute` (`id_product_attribute`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_warehouse` ( - `id_warehouse` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_currency` INT(11) UNSIGNED NOT NULL, - `id_address` INT(11) UNSIGNED NOT NULL, - `id_employee` INT(11) UNSIGNED NOT NULL, - `reference` VARCHAR(64) DEFAULT NULL, - `name` VARCHAR(45) NOT NULL, - `management_type` ENUM('WA', 'FIFO', 'LIFO') NOT NULL DEFAULT 'WA', - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_warehouse`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_warehouse_product_location` ( - `id_warehouse_product_location` int(11) unsigned NOT NULL AUTO_INCREMENT, - `id_product` int(11) unsigned NOT NULL, - `id_product_attribute` int(11) unsigned NOT NULL, - `id_warehouse` int(11) unsigned NOT NULL, - `location` varchar(64) DEFAULT NULL, - PRIMARY KEY ( - `id_warehouse_product_location` - ), - UNIQUE KEY `id_product` ( - `id_product`, `id_product_attribute`, - `id_warehouse` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_warehouse_shop` ( - `id_shop` INT(11) UNSIGNED NOT NULL, - `id_warehouse` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_warehouse`, `id_shop`), - KEY `id_warehouse` (`id_warehouse`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_warehouse_carrier` ( - `id_carrier` INT(11) UNSIGNED NOT NULL, - `id_warehouse` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id_warehouse`, `id_carrier`), - KEY `id_warehouse` (`id_warehouse`), - KEY `id_carrier` (`id_carrier`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_stock_available` ( - `id_stock_available` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_product` INT(11) UNSIGNED NOT NULL, - `id_product_attribute` INT(11) UNSIGNED NOT NULL, - `id_shop` INT(11) UNSIGNED NOT NULL, - `id_shop_group` INT(11) UNSIGNED NOT NULL, - `quantity` INT(10) NOT NULL DEFAULT '0', - `physical_quantity` INT(11) NOT NULL DEFAULT '0', - `reserved_quantity` INT(11) NOT NULL DEFAULT '0', - `depends_on_stock` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', - `out_of_stock` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', - `location` VARCHAR(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id_stock_available`), - KEY `id_shop` (`id_shop`), - KEY `id_shop_group` (`id_shop_group`), - KEY `id_product` (`id_product`), - KEY `id_product_attribute` (`id_product_attribute`), - UNIQUE `product_sqlstock` ( - `id_product`, `id_product_attribute`, - `id_shop`, `id_shop_group` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supply_order` ( - `id_supply_order` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_supplier` INT(11) UNSIGNED NOT NULL, - `supplier_name` VARCHAR(64) NOT NULL, - `id_lang` INT(11) UNSIGNED NOT NULL, - `id_warehouse` INT(11) UNSIGNED NOT NULL, - `id_supply_order_state` INT(11) UNSIGNED NOT NULL, - `id_currency` INT(11) UNSIGNED NOT NULL, - `id_ref_currency` INT(11) UNSIGNED NOT NULL, - `reference` VARCHAR(64) NOT NULL, - `date_add` DATETIME NOT NULL, - `date_upd` DATETIME NOT NULL, - `date_delivery_expected` DATETIME DEFAULT NULL, - `total_te` DECIMAL(20, 6) DEFAULT '0.000000', - `total_with_discount_te` DECIMAL(20, 6) DEFAULT '0.000000', - `total_tax` DECIMAL(20, 6) DEFAULT '0.000000', - `total_ti` DECIMAL(20, 6) DEFAULT '0.000000', - `discount_rate` DECIMAL(20, 6) DEFAULT '0.000000', - `discount_value_te` DECIMAL(20, 6) DEFAULT '0.000000', - `is_template` tinyint(1) DEFAULT '0', - PRIMARY KEY (`id_supply_order`), - KEY `id_supplier` (`id_supplier`), - KEY `id_warehouse` (`id_warehouse`), - KEY `reference` (`reference`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supply_order_detail` ( - `id_supply_order_detail` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_supply_order` INT(11) UNSIGNED NOT NULL, - `id_currency` INT(11) UNSIGNED NOT NULL, - `id_product` INT(11) UNSIGNED NOT NULL, - `id_product_attribute` INT(11) UNSIGNED NOT NULL, - `reference` VARCHAR(64) NOT NULL, - `supplier_reference` VARCHAR(64) NOT NULL, - `name` varchar(128) NOT NULL, - `ean13` VARCHAR(13) DEFAULT NULL, - `isbn` VARCHAR(32) DEFAULT NULL, - `upc` VARCHAR(12) DEFAULT NULL, - `mpn` VARCHAR(40) DEFAULT NULL, - `exchange_rate` DECIMAL(20, 6) DEFAULT '0.000000', - `unit_price_te` DECIMAL(20, 6) DEFAULT '0.000000', - `quantity_expected` INT(11) UNSIGNED NOT NULL, - `quantity_received` INT(11) UNSIGNED NOT NULL, - `price_te` DECIMAL(20, 6) DEFAULT '0.000000', - `discount_rate` DECIMAL(20, 6) DEFAULT '0.000000', - `discount_value_te` DECIMAL(20, 6) DEFAULT '0.000000', - `price_with_discount_te` DECIMAL(20, 6) DEFAULT '0.000000', - `tax_rate` DECIMAL(20, 6) DEFAULT '0.000000', - `tax_value` DECIMAL(20, 6) DEFAULT '0.000000', - `price_ti` DECIMAL(20, 6) DEFAULT '0.000000', - `tax_value_with_order_discount` DECIMAL(20, 6) DEFAULT '0.000000', - `price_with_order_discount_te` DECIMAL(20, 6) DEFAULT '0.000000', - PRIMARY KEY (`id_supply_order_detail`), - KEY `id_supply_order` (`id_supply_order`, `id_product`), - KEY `id_product_attribute` (`id_product_attribute`), - KEY `id_product_product_attribute` ( - `id_product`, `id_product_attribute` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supply_order_history` ( - `id_supply_order_history` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_supply_order` INT(11) UNSIGNED NOT NULL, - `id_employee` INT(11) UNSIGNED NOT NULL, - `employee_lastname` varchar(255) DEFAULT '', - `employee_firstname` varchar(255) DEFAULT '', - `id_state` INT(11) UNSIGNED NOT NULL, - `date_add` DATETIME NOT NULL, - PRIMARY KEY (`id_supply_order_history`), - KEY `id_supply_order` (`id_supply_order`), - KEY `id_employee` (`id_employee`), - KEY `id_state` (`id_state`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supply_order_state` ( - `id_supply_order_state` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `delivery_note` tinyint(1) NOT NULL DEFAULT '0', - `editable` tinyint(1) NOT NULL DEFAULT '0', - `receipt_state` tinyint(1) NOT NULL DEFAULT '0', - `pending_receipt` tinyint(1) NOT NULL DEFAULT '0', - `enclosed` tinyint(1) NOT NULL DEFAULT '0', - `color` VARCHAR(32) DEFAULT NULL, - PRIMARY KEY (`id_supply_order_state`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supply_order_state_lang` ( - `id_supply_order_state` INT(11) UNSIGNED NOT NULL, - `id_lang` INT(11) UNSIGNED NOT NULL, - `name` VARCHAR(128) DEFAULT NULL, - PRIMARY KEY ( - `id_supply_order_state`, `id_lang` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_supply_order_receipt_history` ( - `id_supply_order_receipt_history` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_supply_order_detail` INT(11) UNSIGNED NOT NULL, - `id_employee` INT(11) UNSIGNED NOT NULL, - `employee_lastname` varchar(255) DEFAULT '', - `employee_firstname` varchar(255) DEFAULT '', - `id_supply_order_state` INT(11) UNSIGNED NOT NULL, - `quantity` INT(11) UNSIGNED NOT NULL, - `date_add` DATETIME NOT NULL, - PRIMARY KEY ( - `id_supply_order_receipt_history` - ), - KEY `id_supply_order_detail` (`id_supply_order_detail`), - KEY `id_supply_order_state` (`id_supply_order_state`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_product_supplier` ( - `id_product_supplier` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_product` int(11) UNSIGNED NOT NULL, - `id_product_attribute` int(11) UNSIGNED NOT NULL DEFAULT '0', - `id_supplier` int(11) UNSIGNED NOT NULL, - `product_supplier_reference` varchar(64) DEFAULT NULL, - `product_supplier_price_te` decimal(20, 6) NOT NULL DEFAULT '0.000000', - `id_currency` int(11) unsigned NOT NULL, - PRIMARY KEY (`id_product_supplier`), - UNIQUE KEY `id_product` ( - `id_product`, `id_product_attribute`, - `id_supplier` - ), - KEY `id_supplier` (`id_supplier`, `id_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_order_carrier` ( - `id_order_carrier` int(11) NOT NULL AUTO_INCREMENT, - `id_order` int(11) unsigned NOT NULL, - `id_carrier` int(11) unsigned NOT NULL, - `id_order_invoice` int(11) unsigned DEFAULT NULL, - `weight` DECIMAL(20, 6) DEFAULT NULL, - `shipping_cost_tax_excl` decimal(20, 6) DEFAULT NULL, - `shipping_cost_tax_incl` decimal(20, 6) DEFAULT NULL, - `tracking_number` varchar(64) DEFAULT NULL, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_order_carrier`), - KEY `id_order` (`id_order`), - KEY `id_carrier` (`id_carrier`), - KEY `id_order_invoice` (`id_order_invoice`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` ( - `id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` VARCHAR(255) NOT NULL, - `id_shop` int(11) unsigned NOT NULL DEFAULT '1', - `id_currency` int(10) unsigned NOT NULL, - `id_country` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - `from_quantity` mediumint(8) unsigned NOT NULL, - `price` DECIMAL(20, 6), - `reduction` decimal(20, 6) NOT NULL, - `reduction_tax` tinyint(1) NOT NULL DEFAULT 1, - `reduction_type` enum('amount', 'percentage') NOT NULL, - `from` datetime NOT NULL, - `to` datetime NOT NULL, - PRIMARY KEY (`id_specific_price_rule`), - KEY `id_product` ( - `id_shop`, `id_currency`, `id_country`, - `id_group`, `from_quantity`, `from`, - `to` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_specific_price_rule_condition_group` ( - `id_specific_price_rule_condition_group` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_specific_price_rule` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY ( - `id_specific_price_rule_condition_group`, - `id_specific_price_rule` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_specific_price_rule_condition` ( - `id_specific_price_rule_condition` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_specific_price_rule_condition_group` INT(11) UNSIGNED NOT NULL, - `type` VARCHAR(255) NOT NULL, - `value` VARCHAR(255) NOT NULL, - PRIMARY KEY ( - `id_specific_price_rule_condition` - ), - INDEX ( - `id_specific_price_rule_condition_group` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_risk` ( - `id_risk` int(11) unsigned NOT NULL AUTO_INCREMENT, - `percent` tinyint(3) NOT NULL, - `color` varchar(32) NULL, - PRIMARY KEY (`id_risk`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_risk_lang` ( - `id_risk` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(20) NOT NULL, - PRIMARY KEY (`id_risk`, `id_lang`), - KEY `id_risk` (`id_risk`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_category_shop` ( - `id_category` int(11) NOT NULL, - `id_shop` int(11) NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_category`, `id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_module_preference` ( - `id_module_preference` int(11) NOT NULL auto_increment, - `id_employee` int(11) NOT NULL, - `module` varchar(191) NOT NULL, - `interest` tinyint(1) DEFAULT NULL, - `favorite` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`id_module_preference`), - UNIQUE KEY `employee_module` (`id_employee`, `module`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_tab_module_preference` ( - `id_tab_module_preference` int(11) NOT NULL auto_increment, - `id_employee` int(11) NOT NULL, - `id_tab` int(11) NOT NULL, - `module` varchar(191) NOT NULL, - PRIMARY KEY (`id_tab_module_preference`), - UNIQUE KEY `employee_module` ( - `id_employee`, `id_tab`, `module` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_carrier_tax_rules_group_shop` ( - `id_carrier` int(11) unsigned NOT NULL, - `id_tax_rules_group` int(11) unsigned NOT NULL, - `id_shop` int(11) unsigned NOT NULL, - PRIMARY KEY ( - `id_carrier`, `id_tax_rules_group`, - `id_shop` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_order_invoice_payment` ( - `id_order_invoice` int(11) unsigned NOT NULL, - `id_order_payment` int(11) unsigned NOT NULL, - `id_order` int(11) unsigned NOT NULL, - PRIMARY KEY ( - `id_order_invoice`, `id_order_payment` - ), - KEY `order_payment` (`id_order_payment`), - KEY `id_order` (`id_order`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_smarty_cache` ( - `id_smarty_cache` char(40) NOT NULL, - `name` char(40) NOT NULL, - `cache_id` varchar(254) DEFAULT NULL, - `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `content` longtext NOT NULL, - PRIMARY KEY (`id_smarty_cache`), - KEY `name` (`name`), - KEY `cache_id` (`cache_id`), - KEY `modified` (`modified`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_order_slip_detail_tax` ( - `id_order_slip_detail` int(11) unsigned NOT NULL, - `id_tax` int(11) unsigned NOT NULL, - `unit_amount` decimal(16, 6) NOT NULL DEFAULT '0.000000', - `total_amount` decimal(16, 6) NOT NULL DEFAULT '0.000000', - KEY (`id_order_slip_detail`), - KEY `id_tax` (`id_tax`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE IF NOT EXISTS `PREFIX_mail` ( - `id_mail` int(11) unsigned NOT NULL AUTO_INCREMENT, - `recipient` varchar(126) NOT NULL, - `template` varchar(62) NOT NULL, - `subject` varchar(254) NOT NULL, - `id_lang` int(11) unsigned NOT NULL, - `date_add` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id_mail`), - KEY `recipient` ( - `recipient`(10) - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_smarty_lazy_cache` ( - `template_hash` varchar(32) NOT NULL DEFAULT '', - `cache_id` varchar(191) NOT NULL DEFAULT '', - `compile_id` varchar(32) NOT NULL DEFAULT '', - `filepath` varchar(255) NOT NULL DEFAULT '', - `last_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY ( - `template_hash`, `cache_id`, `compile_id` - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4; - -CREATE TABLE `PREFIX_smarty_last_flush` ( - `type` ENUM('compile', 'template'), - `last_flush` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (`type`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4; - -CREATE TABLE IF NOT EXISTS `PREFIX_cms_role` ( - `id_cms_role` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, - `id_cms` int(11) unsigned NOT NULL, - PRIMARY KEY (`id_cms_role`, `id_cms`), - UNIQUE KEY `name` (`name`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4; - -CREATE TABLE IF NOT EXISTS `PREFIX_cms_role_lang` ( - `id_cms_role` int(11) unsigned NOT NULL, - `id_lang` int(11) unsigned NOT NULL, - `id_shop` int(11) unsigned NOT NULL, - `name` varchar(128) DEFAULT NULL, - PRIMARY KEY ( - `id_cms_role`, `id_lang`, id_shop - ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4; - -CREATE TABLE `PREFIX_employee_session` ( - `id_employee_session` int(11) unsigned NOT NULL auto_increment, - `id_employee` int(10) unsigned DEFAULT NULL, - `token` varchar(40) DEFAULT NULL, - PRIMARY KEY `id_employee_session` (`id_employee_session`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; - -CREATE TABLE `PREFIX_customer_session` ( - `id_customer_session` int(11) unsigned NOT NULL auto_increment, - `id_customer` int(10) unsigned DEFAULT NULL, - `token` varchar(40) DEFAULT NULL, - PRIMARY KEY `id_customer_session` (`id_customer_session`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION; diff --git a/experiments/schema-annot/README.md b/experiments/schema-annot/README.md new file mode 100644 index 00000000..56df8e70 --- /dev/null +++ b/experiments/schema-annot/README.md @@ -0,0 +1,427 @@ +# Sample applications + +`experiments/schema-annot/annotated` contains the schemas of a number of sample applications along with annotated versions of them which capture data ownership relationships important for compliance with privacy laws like the GDPR. + +## Data Ownership Patterns + +- `commento`: accessorship for nested comments. The `comments` table contains a `parentHex` with a self referencing foreign key. +- `ghchat`: groups have admins, so each member of a group only has access to the group such that chat messages are owned exclusively by their sender and only accessed by a member of a group. +- `instagram`: messages/conversations are `OWNED_BY` both recipient and sender, shares are `ACCESSED_BY` the user being shared with, group membership is `ACCESSED_BY` the person who adds members +- `schnack`: each comment is `OWNED_BY` a single user. +- `hotcrp`: Authors should see a `PaperReview`, but not who conducted the review. Hence fields related to who requested the review (`requestedBy`) should be anonymized when the author `GDPR GET`s their data. +- `mouthful`: `Author` column represents a data subject embedded within the `Comment` table. Unlike other schemas, there is no separate table that clearly refers to a data subject. + +## Annotations Used + +- `commento`: 3 `DATA_SUBJECT`, 8 `OWNED_BY`, 2 `ACCESSED_BY`, 2 `ON GET ANON`, 1 `ON DEL DELETE_ROW` +- `ghchat`: 1 `DATA_SUBJECT`, 7 `OWNED_BY`, 1 `ACCESSED_BY`, 1 `ACCESSES`, +- `instagram`: 1 `DATA_SUBJECT`, 18 `OWNED_BY`, 1 `ACCESSED_BY` +- `schnack`: 1 `DATA_SUBJECT`, 1 `OWNED_BY` +- `hotcrp`: 2 `DATA_SUBJECT`, 14 `OWNED_BY`, 1 `OWNS`, 10 `ACCESSED_BY`, 4 `ON GET ANON`, 3 `ON DEL ANON` +- `socify`: 1 `DATA_SUBJECT`, 10 `OWNED_BY` +- `mouthful`: 1 `DATA_SUBJECT`, 1 `OWNED_BY` + +## Unsupported Features + +Converting and annotating these schemas required removing certain SQL features currently unsupported by k9db. However, removing these features does not affect privacy compliance. A list of unsupported features is provided below: + +- `all schemas`: reserved keywords as column or table names (e.g. groups, user, match, index, key, from), multi-column primary keys, `[UNIQUE] KEY`, `CREATE TABLE IF NOT EXISTS`, `DEFAULT` values, certain column type definitions (e.g. timestamp, boolean, varchar, tinyint), `AUTO_INCREMENT` + +Specific schemas: + +- `commento`: self referencing foreign keys with `ACCESSED_BY` for `parentHex` in the `comments` table are unsupported (issue #170) +- `mouthful`: `Author` column representing a data subject embedded within the `Comment` table. As a work around, we add a separate table for users (see issue #171). + +# Explain Compliance + +The following shows the output of running k9db's `EXPLAIN COMPLIANCE` command on each schema. + +## Commento + +``` +----------------------------------------- +config: UNSHARDED +----------------------------------------- +owners: DATASUBJECT +----------------------------------------- +ownerSessions: SHARDED + ownerHex shards to owners (explicit annotation) + via ownerSessions(ownerHex) -> owners(ownerHex) +----------------------------------------- +commenterSessions: SHARDED + commenterHex shards to commenters (explicit annotation) + via commenterSessions(commenterHex) -> commenters(commenterHex) +----------------------------------------- +ownerConfirmHexes: SHARDED + ownerHex shards to owners (explicit annotation) + via ownerConfirmHexes(ownerHex) -> owners(ownerHex) +----------------------------------------- +ownerResetHexes: SHARDED + ownerHex shards to owners (explicit annotation) + via ownerResetHexes(ownerHex) -> owners(ownerHex) +----------------------------------------- +domains: SHARDED + ownerHex shards to owners (explicit annotation) + via domains(ownerHex) -> owners(ownerHex) +----------------------------------------- +moderators: DATASUBJECT +----------------------------------------- +commenters: DATASUBJECT +----------------------------------------- +comments: SHARDED + commenterHex shards to commenters (explicit annotation) + via comments(commenterHex) -> commenters(commenterHex) +----------------------------------------- +votes: SHARDED + commenterHex shards to commenters (explicit annotation) + via votes(commenterHex) -> commenters(commenterHex) +----------------------------------------- +views: SHARDED + commenterHex shards to commenters (explicit annotation) + via views(commenterHex) -> commenters(commenterHex) +``` + +## ghchat + +``` +----------------------------------------- +user_info: DATASUBJECT +----------------------------------------- +group_msg: SHARDED + from_user shards to user_info (explicit annotation) + via group_msg(from_user) -> user_info(id) +----------------------------------------- +group_info: SHARDED + creator_id shards to user_info (explicit annotation) + via group_info(creator_id) -> user_info(id) +----------------------------------------- +group_user_relation: SHARDED + user_id shards to user_info (explicit annotation) + via group_user_relation(user_id) -> user_info(id) +----------------------------------------- +private_msg: SHARDED + from_user shards to user_info (explicit annotation) + via private_msg(from_user) -> user_info(id) + to_user shards to user_info (explicit annotation) + via private_msg(to_user) -> user_info(id) +----------------------------------------- +user_user_relation: SHARDED + user_id shards to user_info (explicit annotation) + via user_user_relation(user_id) -> user_info(id) + from_user shards to user_info (explicit annotation) + via user_user_relation(from_user) -> user_info(id) +``` + +## Instagram + +``` +----------------------------------------- +likes: SHARDED + like_by shards to users (explicit annotation) + via likes(like_by) -> users(id) +----------------------------------------- +hashtags: SHARDED + user_id shards to users (explicit annotation) + via hashtags(user_id) -> users(id) +----------------------------------------- +messages: SHARDED + mssg_by shards to users (explicit annotation) + via messages(mssg_by) -> users(id) + mssg_to shards to users (explicit annotation) + via messages(mssg_to) -> users(id) +----------------------------------------- +group_members: SHARDED + member shards to users (explicit annotation) + via group_members(member) -> users(id) +----------------------------------------- +follow_system: SHARDED + follow_by shards to users (explicit annotation) + via follow_system(follow_by) -> users(id) +----------------------------------------- +favourites: SHARDED + fav_by shards to users (explicit annotation) + via favourites(fav_by) -> users(id) +----------------------------------------- +groups1: SHARDED + admin shards to users (implicitly deduced) + via groups1(admin) -> users(id) +----------------------------------------- +comments: SHARDED + comment_by shards to users (explicit annotation) + via comments(comment_by) -> users(id) +----------------------------------------- +conversations: SHARDED + user_one shards to users (explicit annotation) + via conversations(user_one) -> users(id) + user_two shards to users (explicit annotation) + via conversations(user_two) -> users(id) +----------------------------------------- +bookmarks: SHARDED + bkmrk_by shards to users (explicit annotation) + via bookmarks(bkmrk_by) -> users(id) +----------------------------------------- +blocks: SHARDED + block_by shards to users (explicit annotation) + via blocks(block_by) -> users(id) +----------------------------------------- +posts: SHARDED + user_id shards to users (explicit annotation) + via posts(user_id) -> users(id) +----------------------------------------- +users: DATASUBJECT +----------------------------------------- +notifications: SHARDED + notify_to shards to users (explicit annotation) + via notifications(notify_to) -> users(id) +----------------------------------------- +post_tags: SHARDED + user shards to users (explicit annotation) + via post_tags(user) -> users(id) +----------------------------------------- +profile_views: SHARDED + view_by shards to users (explicit annotation) + via profile_views(view_by) -> users(id) +----------------------------------------- +tags: SHARDED + user shards to users (implicitly deduced) + via tags(user) -> users(id) +----------------------------------------- +recommendations: SHARDED + recommend_by shards to users (explicit annotation) + via recommendations(recommend_by) -> users(id) +----------------------------------------- +shares: SHARDED + share_by shards to users (explicit annotation) + via shares(share_by) -> users(id) +``` + +## Schnack + +``` +----------------------------------------- +user: DATASUBJECT +----------------------------------------- +subscription: UNSHARDED +----------------------------------------- +comment: SHARDED + user_id shards to user (explicit annotation) + via comment(user_id) -> user(id) +----------------------------------------- +setting: UNSHARDED +----------------------------------------- +oauth_provider: UNSHARDED +``` + +## Hotcrp + +``` +----------------------------------------- +PaperOption: SHARDED + paperId shards to ContactInfo (implicitly deduced) + via PaperOption(paperId) -> Paper(paperId) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 3 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +PaperTopic: SHARDED + paperId shards to ContactInfo (explicit annotation) + via PaperTopic(paperId) -> Paper(paperId) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 3 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +PaperComment: SHARDED + contactId shards to ContactInfo (explicit annotation) + via PaperComment(contactId) -> ContactInfo(contactId) +----------------------------------------- +TopicInterest: SHARDED + contactId shards to ContactInfo (implicitly deduced) + via TopicInterest(contactId) -> ContactInfo(contactId) +----------------------------------------- +MailLog: UNSHARDED + [Warning] The column "emailBody" sounds like it may belong to a data subject, but the table is not sharded. You may want to review your annotations. +----------------------------------------- +FilteredDocument: SHARDED + inDocId shards to ContactInfo (explicit annotation) + via FilteredDocument(inDocId) -> DocumentLink(documentId) + via DocumentLink(paperId) -> Paper(paperId) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 4 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +PaperWatch: SHARDED + contactId shards to ContactInfo (explicit annotation) + via PaperWatch(contactId) -> ContactInfo(contactId) +----------------------------------------- +DeletedContactInfo: SHARDED + contactId shards to ContactInfo (explicit annotation) + via DeletedContactInfo(contactId) -> ContactInfo(contactId) +----------------------------------------- +DocumentLink: SHARDED + paperId shards to ContactInfo (implicitly deduced) + via DocumentLink(paperId) -> Paper(paperId) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 3 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +Capability: SHARDED + contactId shards to ContactInfo (explicit annotation) + via Capability(contactId) -> ContactInfo(contactId) +----------------------------------------- +ActionLog: SHARDED + contactId shards to ContactInfo (explicit annotation) + via ActionLog(contactId) -> ContactInfo(contactId) +----------------------------------------- +ReviewRequest: DATASUBJECT AND SHARDED + paperId shards to ContactInfo (implicitly deduced) + via ReviewRequest(paperId) -> Paper(paperId) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 3 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +PaperAuthors: SHARDED + contactId shards to ContactInfo (explicit annotation) + via PaperAuthors(contactId) -> ContactInfo(contactId) +----------------------------------------- +Paper: SHARDED + paperId shards to ContactInfo (explicit annotation) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 2 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +PaperReview: SHARDED + contactId shards to ContactInfo (explicit annotation) + via PaperReview(contactId) -> ContactInfo(contactId) +----------------------------------------- +ReviewRating: SHARDED + contactId shards to ContactInfo (explicit annotation) + via ReviewRating(contactId) -> ContactInfo(contactId) +----------------------------------------- +PaperStorage: UNSHARDED +----------------------------------------- +Formula: SHARDED + createdBy shards to ContactInfo (explicit annotation) + via Formula(createdBy) -> ContactInfo(contactId) +----------------------------------------- +ContactInfo: DATASUBJECT +----------------------------------------- +PaperReviewPreference: SHARDED + contactId shards to ContactInfo (explicit annotation) + via PaperReviewPreference(contactId) -> ContactInfo(contactId) +----------------------------------------- +PaperReviewRefused: SHARDED + contactId shards to ContactInfo (explicit annotation) + via PaperReviewRefused(contactId) -> ContactInfo(contactId) +----------------------------------------- +PaperTag: SHARDED + paperId shards to ContactInfo (implicitly deduced) + via PaperTag(paperId) -> Paper(paperId) + via Paper(paperId) -> PaperAuthors(paperId) + via PaperAuthors(contactId) -> ContactInfo(contactId) + with a total distance of 3 + [Info] This table is variably owned (via PaperAuthors) +----------------------------------------- +TopicArea: UNSHARDED +----------------------------------------- +PaperTagAnno: UNSHARDED +----------------------------------------- +Settings: UNSHARDED +``` + +## Socify + +``` +----------------------------------------- +merit_scores: UNSHARDED +----------------------------------------- +event_attendees: SHARDED + user_id shards to users (explicit annotation) + via event_attendees(user_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +merit_score_points: UNSHARDED +----------------------------------------- +authentications: SHARDED + user_id shards to users (explicit annotation) + via authentications(user_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +follows: SHARDED + follower_id shards to users (explicit annotation) + via follows(follower_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +merit_actions: SHARDED + user_id shards to users (explicit annotation) + via merit_actions(user_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +events: SHARDED + user_id shards to users (explicit annotation) + via events(user_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +sashes: UNSHARDED +----------------------------------------- +attachments: UNSHARDED +----------------------------------------- +merit_activity_logs: SHARDED + action_id shards to users (explicit annotation) + via merit_activity_logs(action_id) -> merit_actions(id) + via merit_actions(user_id) -> users(id) + with a total distance of 2 + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +votes: SHARDED + voter_id shards to users (implicitly deduced) + via votes(voter_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +badges_sashes: SHARDED + notified_user shards to users (implicitly deduced) + via badges_sashes(notified_user) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +activities: SHARDED + owner_id shards to users (explicit annotation) + via activities(owner_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +users: DATASUBJECT +----------------------------------------- +photo_albums: SHARDED + user_id shards to users (explicit annotation) + via photo_albums(user_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +photos: SHARDED + photo_album_id shards to users (implicitly deduced) + via photos(photo_album_id) -> photo_albums(id) + via photo_albums(user_id) -> users(id) + with a total distance of 2 + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +----------------------------------------- +posts: SHARDED + user_id shards to users (explicit annotation) + via posts(user_id) -> users(id) + [Warning] This table is sharded, but all sharding paths are nullable. This will lead to records being stored in a global table if those columns are NULL and could be a source of non-compliance. +``` + +## Mouthful + +``` +----------------------------------------- +user: DATASUBJECT +----------------------------------------- +Thread: UNSHARDED +----------------------------------------- +Comment: SHARDED + Author shards to user (explicit annotation) + via Comment(Author) -> user(id) +``` diff --git a/experiments/schema-annot/annotated/commento-annotated.sql b/experiments/schema-annot/annotated/commento-annotated.sql new file mode 100644 index 00000000..a7f905d1 --- /dev/null +++ b/experiments/schema-annot/annotated/commento-annotated.sql @@ -0,0 +1,175 @@ +CREATE TABLE config ( \ + allowNewOwners int NOT NULL, \ + PRIMARY KEY(allowNewOwners) \ +); + +-- INSERT INTO +-- config (allowNewOwners) +-- VALUES (true); + +CREATE DATA_SUBJECT TABLE owners ( \ + ownerHex TEXT NOT NULL UNIQUE PRIMARY KEY, \ + email TEXT NOT NULL, \ + name TEXT NOT NULL, \ + passwordHash TEXT NOT NULL, \ + confirmedEmail TEXT NOT NULL, + joinDate datetime NOT NULL \ +); + +CREATE TABLE ownerSessions ( \ + session TEXT NOT NULL UNIQUE PRIMARY KEY, \ + ownerHex TEXT NOT NULL, \ + loginDate datetime NOT NULL, \ + FOREIGN KEY (ownerHex) OWNED_BY owners(ownerHex) \ +); + +CREATE TABLE ownerConfirmHexes ( + confirmHex TEXT NOT NULL UNIQUE PRIMARY KEY, \ + ownerHex TEXT NOT NULL, \ + sendDate TEXT NOT NULL, \ + FOREIGN KEY (ownerHex) OWNED_BY owners(ownerHex) \ +); + +CREATE TABLE ownerResetHexes ( \ + resetHex TEXT NOT NULL UNIQUE PRIMARY KEY, \ + ownerHex TEXT NOT NULL, \ + sendDate TEXT NOT NULL, \ + FOREIGN KEY (ownerHex) OWNED_BY owners(ownerHex) \ +); + +CREATE TABLE domains ( \ + domain TEXT NOT NULL UNIQUE PRIMARY KEY, \ + ownerHex TEXT NOT NULL, \ + name TEXT NOT NULL, \ + creationDate datetime NOT NULL, \ + state TEXT NOT NULL, \ + importedComments TEXT NOT NULL, \ + autoSpamFilter int NOT NULL, \ + requireModeration int NOT NULL, \ + requireIdentification int NOT NULL, \ + viewsThisMonth INTEGER NOT NULL, \ + FOREIGN KEY (ownerHex) OWNED_BY owners(ownerHex) \ +); + +CREATE DATA_SUBJECT TABLE moderators ( \ + id int NOT NULL, + domain TEXT NOT NULL, \ + email TEXT NOT NULL, \ + addDate datetime NOT NULL, \ + PRIMARY KEY(id), \ + FOREIGN KEY (domain) REFERENCES ONLY domains(domain) \ +); + +CREATE DATA_SUBJECT TABLE commenters ( \ + commenterHex TEXT NOT NULL UNIQUE PRIMARY KEY, \ + email TEXT NOT NULL, \ + name TEXT NOT NULL, \ + link TEXT NOT NULL, \ + photo TEXT NOT NULL, \ + provider TEXT NOT NULL, \ + joinDate datetime NOT NULL, \ + state TEXT NOT NULL \ +); + +CREATE TABLE commenterSessions ( \ + session TEXT NOT NULL UNIQUE PRIMARY KEY, \ + commenterHex TEXT NOT NULL, \ + creationDate datetime NOT NULL, \ + FOREIGN KEY (commenterHex) OWNED_BY commenters(commenterHex) \ +); + +CREATE TABLE comments ( \ + commentHex TEXT NOT NULL UNIQUE PRIMARY KEY, \ + domain TEXT NOT NULL, \ + path TEXT NOT NULL, \ + commenterHex TEXT NOT NULL, \ + markdown TEXT NOT NULL, \ + html TEXT NOT NULL, \ + parentHex TEXT NOT NULL, \ + score INTEGER NOT NULL, \ + state TEXT NOT NULL, \ + creationDate datetime NOT NULL, \ + FOREIGN KEY (commenterHex) OWNED_BY commenters(commenterHex), \ + FOREIGN KEY (domain) ACCESSED_BY domains(domain), \ + ON DEL parentHex DELETE_ROW, \ + FOREIGN KEY (parentHex) ACCESSED_BY comments(commentHex), \ + ON GET parentHex ANON (commenterHex, score, state), \ + ON GET domain ANON (commenterHex, score, state) \ +); + +-- DELETEing a comment should recursively delete all children +-- CREATE OR REPLACE FUNCTION commentsDeleteTriggerFunction() RETURNS TRIGGER AS $trigger$ +-- BEGIN +-- DELETE FROM comments +-- WHERE parentHex = old.commentHex; + +-- RETURN NULL; +-- END; +-- $trigger$ LANGUAGE plpgsql; + +-- CREATE TRIGGER commentsDeleteTrigger AFTER DELETE ON comments +-- FOR EACH ROW EXECUTE PROCEDURE commentsDeleteTriggerFunction(); + +CREATE TABLE votes ( \ + commentHex TEXT NOT NULL, \ + commenterHex TEXT NOT NULL, \ + direction INTEGER NOT NULL, \ + voteDate datetime NOT NULL, \ + PRIMARY KEY(commentHex), \ + FOREIGN KEY (commenterHex) OWNED_BY commenters(commenterHex) \ +); + +-- CREATE UNIQUE INDEX votesUniqueIndex ON votes(commentHex, commenterHex); + +-- CREATE OR REPLACE FUNCTION votesInsertTriggerFunction() RETURNS TRIGGER AS $trigger$ +-- BEGIN +-- UPDATE comments +-- SET score = score + new.direction +-- WHERE commentHex = new.commentHex; + +-- RETURN NEW; +-- END; +-- $trigger$ LANGUAGE plpgsql; + +-- CREATE TRIGGER votesInsertTrigger AFTER INSERT ON votes +-- FOR EACH ROW EXECUTE PROCEDURE votesInsertTriggerFunction(); + +-- CREATE OR REPLACE FUNCTION votesUpdateTriggerFunction() RETURNS TRIGGER AS $trigger$ +-- BEGIN +-- UPDATE comments +-- SET score = score - old.direction + new.direction +-- WHERE commentHex = old.commentHex; + +-- RETURN NEW; +-- END; +-- $trigger$ LANGUAGE plpgsql; + +-- CREATE TRIGGER votesUpdateTrigger AFTER UPDATE ON votes +-- FOR EACH ROW EXECUTE PROCEDURE votesUpdateTriggerFunction(); + +-- note: had to add PRIMARY KEY(domain) to avoid "invalid PK" error +CREATE TABLE views ( \ + id int NOT NULL UNIQUE PRIMARY KEY, \ + domain text NOT NULL, \ + commenterHex text NOT NULL, \ + viewDate datetime NOT NULL, \ + FOREIGN KEY (commenterHex) OWNED_BY commenters(commenterHex), \ + FOREIGN KEY (domain) REFERENCES domains(domain) \ +); + +-- CREATE INDEX IF NOT EXISTS domainIndex ON views(domain); + +-- CREATE OR REPLACE FUNCTION viewsInsertTriggerFunction() RETURNS TRIGGER AS $trigger$ +-- BEGIN +-- UPDATE domains +-- SET viewsThisMonth = viewsThisMonth + 1 +-- WHERE domain = new.domain; + +-- RETURN NULL; +-- END; +-- $trigger$ LANGUAGE plpgsql; + +-- CREATE TRIGGER viewsInsertTrigger AFTER INSERT ON views +-- FOR EACH ROW EXECUTE PROCEDURE viewsInsertTriggerFunction(); + +EXPLAIN COMPLIANCE; \ No newline at end of file diff --git a/experiments/schema-annot/annotated/count.sh b/experiments/schema-annot/annotated/count.sh new file mode 100755 index 00000000..41d1a39e --- /dev/null +++ b/experiments/schema-annot/annotated/count.sh @@ -0,0 +1,14 @@ +#!/bin/bash +for f in *.sql; do + tbls=$(grep -i -R -E "CREATE (DATA_SUBJECT )?TABLE" $f | grep -E -v "^\s*--" | wc -l) + ds=$(grep -i -R -E "CREATE DATA_SUBJECT TABLE" $f | grep -E -v "^\s*--" | wc -l) + own=$(grep -i -R -E " (OWNED_BY|OWNS) " $f | grep -E -v "^\s*--" | wc -l) + acc=$(grep -i -R -E " (ACCESSED_BY|ACCESSES) " $f | grep -E -v "^\s*--" | wc -l) + anon=$(grep -i -R -E "ON (GET|DEL) .* (ANON|DELETE_ROW)" $f | grep -E -v "^\s*--" | wc -l) + prefix=(${f//-/ }) + prefix=${prefix[0]} + prefix=(${prefix//_/ }) + prefix=${prefix[0]} + printf "\\\\%-20s & %-6s & %-9s & %-3s & %-6s & %-5s \\\\\\ \\hline" $prefix $tbls $ds $own $acc $anon + echo "" +done diff --git a/experiments/schema-annot/annotated/ghchat-annotated.sql b/experiments/schema-annot/annotated/ghchat-annotated.sql new file mode 100644 index 00000000..53111d15 --- /dev/null +++ b/experiments/schema-annot/annotated/ghchat-annotated.sql @@ -0,0 +1,79 @@ +CREATE DATA_SUBJECT TABLE user_info ( + id int NOT NULL, + github_id int, + name text NOT NULL, + password text, + avatar text, + location text, + socketid text, + website text, + github text, + intro text, + company text, + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE group_info ( + id int NOT NULL, + to_group_id int NOT NULL, + name text NOT NULL, + group_notice text NOT NULL, + creator_id int NOT NULL, + create_time int NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (creator_id) OWNED_BY user_info(id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE group_user_relation ( + id text NOT NULL, + to_group_id int NOT NULL, + user_id int NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY user_info(id), + FOREIGN KEY (to_group_id) ACCESSES group_info(id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE group_msg ( + id text NOT NULL, + from_user int NOT NULL, + to_group_id int NOT NULL, + message text NOT NULL, + time text NOT NULL, + attachments text, + PRIMARY KEY (id), + -- KEY to_group (to_group_id), + FOREIGN KEY (from_user) OWNED_BY user_info(id), + FOREIGN KEY (to_group_id) ACCESSED_BY group_info(id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE private_msg ( + id text NOT NULL, + from_user text NOT NULL, + to_user text NOT NULL, + message text, + time text NOT NULL, + attachments text, + PRIMARY KEY (id), + -- KEY from_user (from_user), + -- KEY to_user (to_user), + FOREIGN KEY (from_user) OWNED_BY user_info(id), + FOREIGN KEY (to_user) OWNED_BY user_info(id), + ON DEL from_user ANON (from_user), + ON DEL to_user ANON (to_user) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE user_user_relation ( + id text NOT NULL, + user_id int NOT NULL, + from_user text NOT NULL, + remark text, + shield int NOT NULL, + time text NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY user_info(id), + FOREIGN KEY (from_user) OWNED_BY user_info(id), + ON DEL user_id ANON (user_id), + ON DEL from_user ANON (from_user) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +EXPLAIN COMPLIANCE; diff --git a/experiments/schema-annot/annotated/hotcrp-annotated.sql b/experiments/schema-annot/annotated/hotcrp-annotated.sql new file mode 100644 index 00000000..9204fa51 --- /dev/null +++ b/experiments/schema-annot/annotated/hotcrp-annotated.sql @@ -0,0 +1,415 @@ +-- not supported by k9db: +-- col types varbinary, blob, varchar +-- multi column primary keys +-- auto increment +-- default values +-- KEY / UNIQUE KEY + +CREATE DATA_SUBJECT TABLE ContactInfo ( + contactId int NOT NULL, + firstName text NOT NULL, + lastName text NOT NULL, + unaccentedName text NOT NULL, + email text NOT NULL, + preferredEmail text, + affiliation text NOT NULL, + phone text, + country text, + password text NOT NULL, + passwordTime int NOT NULL, + passwordUseTime int NOT NULL, + collaborators text, + creationTime int NOT NULL, + updateTime int NOT NULL, + lastLogin int NOT NULL, + defaultWatch int NOT NULL, + roles int NOT NULL, + disabled int NOT NULL, + contactTags text, + birthday int, + gender text, + data text, + PRIMARY KEY (contactId) + -- UNIQUE KEY email (email), + -- KEY roles (roles) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperStorage ( + paperId int NOT NULL, + paperStorageId int NOT NULL, + timestamp int NOT NULL, + mimetype text NOT NULL, + paper text, + compression int NOT NULL, + sha1 text NOT NULL, + crc32 text, + documentType int NOT NULL, + filename text, + infoJson text, + size int, + filterType int, + originalStorageId int, + inactive int NOT NULL, + PRIMARY KEY (paperStorageId), + FOREIGN KEY (originalStorageId) REFERENCES PaperStorage(paperStorageId) + -- UNIQUE KEY paperStorageId (paperStorageId), +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE Paper ( + paperId int NOT NULL, + title text, + authorInformation text, + abstract text, + collaborators text, + timeSubmitted int NOT NULL, + timeWithdrawn int NOT NULL, + timeFinalSubmitted int NOT NULL, + timeModified int NOT NULL, + paperStorageId int NOT NULL, + -- # sha1 copied from PaperStorage to reduce joins + sha1 text NOT NULL, + finalPaperStorageId int NOT NULL, + blind int NOT NULL, + outcome int NOT NULL, + leadContactId int NOT NULL, + shepherdContactId int NOT NULL, + managerContactId int NOT NULL, + capVersion int NOT NULL, + -- # next 3 fields copied from PaperStorage to reduce joins + size int NOT NULL, + mimetype text NOT NULL, + timestamp int NOT NULL, + pdfFormatStatus int NOT NULL, + withdrawReason text, + paperFormat int, + dataOverflow text, + PRIMARY KEY (paperId), + -- KEY timeSubmitted (timeSubmitted), + -- KEY leadContactId (leadContactId), + -- KEY shepherdContactId (shepherdContactId), + FOREIGN KEY (paperStorageId) REFERENCES PaperStorage(paperStorageId), + FOREIGN KEY (finalPaperStorageId) REFERENCES PaperStorage(paperStorageId), + FOREIGN KEY (leadContactId) REFERENCES ONLY ContactInfo(contactId), + FOREIGN KEY (shepherdContactId) ACCESSED_BY ContactInfo(contactId), + FOREIGN KEY (managerContactId) ACCESSED_BY ContactInfo(contactId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +-- Added this table to work around issue #172. +-- Extracts co-author conflictType from PaperConflict +CREATE TABLE PaperAuthors ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + contactId int NOT NULL, + FOREIGN KEY (paperId) OWNS Paper(paperId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId) +) + +CREATE TABLE PaperConflict ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + contactId int NOT NULL, + conflictType int NOT NULL, + FOREIGN KEY (paperId) ACCESSED_BY Paper(paperId), + -- see issue #172: ownership/edge in data ownership graph dependent on column value of conflictType, + -- which could be co-author, institutional, etc. + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + ON DEL (paperId) DELETE_ROW +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE ActionLog ( + logId int NOT NULL, + contactId int NOT NULL, + destContactId int, + trueContactId int, + paperId int, + timestamp datetime NOT NULL, + ipaddr text, + -- this column name causes k9db to crash with "no viable alternative at input ',\n action'" + -- action text NOT NULL, + data text, + PRIMARY KEY (logId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + FOREIGN KEY (destContactId) ACCESSED_BY ContactInfo(contactId), + FOREIGN KEY (trueContactId) ACCESSED_BY ContactInfo(contactId), + FOREIGN KEY (paperId) REFERENCES Paper(paperId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE Capability ( + capabilityType int NOT NULL, + contactId int NOT NULL, + paperId int NOT NULL, + timeExpires int NOT NULL, + salt text NOT NULL, + data text, + PRIMARY KEY (salt), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + FOREIGN KEY (paperId) REFERENCES Paper(paperId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE DeletedContactInfo ( + contactId int NOT NULL, + firstName text NOT NULL, + lastName text NOT NULL, + unaccentedName text NOT NULL, + email text NOT NULL, + PRIMARY KEY (contactId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE DocumentLink ( + paperId int NOT NULL, + linkId int NOT NULL, + linkType int NOT NULL, + documentId int NOT NULL, + PRIMARY KEY (documentId), + FOREIGN KEY (paperId) REFERENCES Paper(paperId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE FilteredDocument ( + inDocId int NOT NULL, + filterType int NOT NULL, + outDocId int NOT NULL, + createdAt int NOT NULL, + PRIMARY KEY (inDocId), + FOREIGN KEY (inDocId) OWNED_BY DocumentLink(documentId), + FOREIGN KEY (outDocId) REFERENCES DocumentLink(documentId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE Formula ( + formulaId int NOT NULL, + name text NOT NULL, + expression text NOT NULL, + createdBy int NOT NULL, + timeModified int NOT NULL, + PRIMARY KEY (formulaId), + FOREIGN KEY (createdBy) OWNED_BY ContactInfo(contactId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE MailLog ( + mailId int NOT NULL, + recipients text NOT NULL, + q text, + t text, + paperIds text, + cc text, + replyto text, + subject text, + emailBody text, + fromNonChair int NOT NULL, + status int NOT NULL, + PRIMARY KEY (mailId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperComment ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, -- should be OWNER if we could filter on comment type + commentId int NOT NULL, + contactId int NOT NULL, + timeModified int NOT NULL, + timeNotified int NOT NULL, + timeDisplayed int NOT NULL, + comment text, + commentType int NOT NULL, + replyTo int NOT NULL, + ordinal int NOT NULL, + authorOrdinal int NOT NULL, + commentTags text, + commentRound int NOT NULL, + commentFormat int, + commentOverflow text, + -- UNIQUE KEY commentId (commentId), + -- KEY contactId (contactId), + -- KEY timeModifiedContact (timeModified,contactId), + FOREIGN KEY (paperId) REFERENCES Paper(paperId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperOption ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + optionId int NOT NULL, + value int NOT NULL, + data text, + dataOverflow text, + FOREIGN KEY (paperId) REFERENCES Paper(paperId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperReview ( + paperId int NOT NULL, + reviewId int NOT NULL, + contactId int NOT NULL, + reviewToken int NOT NULL, + reviewType int NOT NULL, + reviewRound int NOT NULL, + requestedBy int NOT NULL, + timeRequested int NOT NULL, + timeRequestNotified int NOT NULL, + reviewBlind int NOT NULL, + reviewModified int NOT NULL, + reviewAuthorModified int, + reviewSubmitted int, + reviewNotified int, + reviewAuthorNotified int NOT NULL, + reviewAuthorSeen int, + reviewOrdinal int NOT NULL, + reviewViewScore int NOT NULL, + timeDisplayed int NOT NULL, + timeApprovalRequested int NOT NULL, + reviewEditVersion int NOT NULL, + reviewNeedsSubmit int NOT NULL, + reviewWordCount int, + reviewFormat int, + overAllMerit int NOT NULL, + reviewerQualification int NOT NULL, + novelty int NOT NULL, + technicalMerit int NOT NULL, + interestToCommunity int NOT NULL, + longevity int NOT NULL, + grammar int NOT NULL, + likelyPresentation int NOT NULL, + suitableForShort int NOT NULL, + potential int NOT NULL, + fixability int NOT NULL, + tfields text, + sfields text, + data text, + PRIMARY KEY (reviewId), + -- UNIQUE KEY reviewId (reviewId), + -- KEY contactId (contactId), + -- KEY reviewType (reviewType), + -- KEY reviewRound (reviewRound), + -- KEY requestedBy (requestedBy), + FOREIGN KEY (paperId) ACCESSED_BY Paper(paperId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + FOREIGN KEY (requestedBy) ACCESSED_BY ContactInfo(contactId), + -- author should see review, but not who reviewed it + -- only thing author should see is content of review, and when submitted (dates) + ON GET paperId ANON (reviewId, contactId, requestedBy, reviewToken, reviewType, reviewRound, reviewBlind, reviewModified, reviewAuthorModified, reviewSubmitted, reviewNotified, reviewAuthorNotified, reviewAuthorSeen, reviewOrdinal) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperReviewPreference ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + contactId int NOT NULL, + preference int NOT NULL, + expertise int, + FOREIGN KEY (paperId) REFERENCES Paper(paperId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperReviewRefused ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + email text NOT NULL, + firstName text, + lastName text, + affiliation text, + contactId int NOT NULL, + requestedBy int NOT NULL, + timeRequested int, + refusedBy int, + timeRefused int, + reviewType int NOT NULL, + reviewRound int, + data text, + reason text, + FOREIGN KEY (paperId) REFERENCES Paper(paperId), + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + FOREIGN KEY (requestedBy) ACCESSED_BY ContactInfo(contactId), + FOREIGN KEY (refusedBy) ACCESSED_BY ContactInfo(contactId), + ON GET requestedBy ANON (email, firstName, lastName, affiliation, contactId), + ON DEL requestedBy ANON (requestedBy), + ON GET refusedBy ANON (email, firstName, lastName, affiliation, contactId), + ON DEL refusedBy ANON (refusedBy) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperTag ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + -- # case-insensitive; see TAG_MAXLEN in init.php + tag text NOT NULL, + tagIndex int NOT NULL, + FOREIGN KEY (paperId) REFERENCES Paper(paperId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperTagAnno ( + -- # case-insensitive; see TAG_MAXLEN in init.php + tag text NOT NULL, + annoId int NOT NULL, + tagIndex int NOT NULL, + heading text, + annoFormat int, + infoJson text, + PRIMARY KEY (annoId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE TopicArea ( + topicId int NOT NULL, + topicName text, + PRIMARY KEY (topicId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperTopic ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + topicId int NOT NULL, + FOREIGN KEY (paperId) OWNED_BY Paper(paperId), + FOREIGN KEY (topicId) REFERENCES TopicArea(topicId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE PaperWatch ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + contactId int NOT NULL, + watch int NOT NULL, + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + FOREIGN KEY (paperId) REFERENCES Paper(paperId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE ReviewRating ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + reviewId int NOT NULL, + contactId int NOT NULL, + rating int NOT NULL, + FOREIGN KEY (contactId) OWNED_BY ContactInfo(contactId), + FOREIGN KEY (paperId) REFERENCES Paper(paperId), + FOREIGN KEY (reviewId) REFERENCES PaperReview(reviewId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- data subject because this could refer to a person who does not have an account on hotcrp +CREATE DATA_SUBJECT TABLE ReviewRequest ( + id int PRIMARY KEY NOT NULL, + paperId int NOT NULL, + email text NOT NULL, + firstName text, + lastName text, + affiliation text, + reason text, + requestedBy int NOT NULL, + timeRequested int NOT NULL, + reviewRound int, + FOREIGN KEY (paperId) REFERENCES Paper(paperId), + FOREIGN KEY (requestedBy) ACCESSED_BY ContactInfo(contactId), + -- authors of papers should not see who reviewed their paper + ON GET paperId ANON (email, firstName, lastName, affiliation, requestedBy, timeRequested) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE Settings ( + name text NOT NULL, + value int NOT NULL, + data text, + PRIMARY KEY (name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE TopicInterest ( + contactId int NOT NULL, + topicId int NOT NULL, + interest int NOT NULL, + PRIMARY KEY (contactId), + FOREIGN KEY (contactId) REFERENCES ContactInfo(contactId), + FOREIGN KEY (topicId) REFERENCES TopicArea(topicId) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +EXPLAIN COMPLIANCE; diff --git a/experiments/schema-annot/annotated/instagram_2-annotated.sql b/experiments/schema-annot/annotated/instagram_2-annotated.sql new file mode 100644 index 00000000..613f48e9 --- /dev/null +++ b/experiments/schema-annot/annotated/instagram_2-annotated.sql @@ -0,0 +1,235 @@ +CREATE DATA_SUBJECT TABLE users ( + id int NOT NULL, + username text NOT NULL, + firstname text NOT NULL, + surname text NOT NULL, + email text NOT NULL, + password text NOT NULL, + bio text NOT NULL, + joined text NOT NULL, + email_verified text NOT NULL, + account_type text NOT NULL, + instagram text NOT NULL, + twitter text NOT NULL, + facebook text NOT NULL, + github text NOT NULL, + website text NOT NULL, + phone text NOT NULL, + isOnline text NOT NULL, + lastOnline text NOT NULL, + PRIMARY KEY (id) +); + +-- Reserved keyword: k9db crashes when this table is called 'groups', so renamed to groups1 +CREATE TABLE groups1 ( + id int NOT NULL, + name text NOT NULL, + bio text NOT NULL, + admin int NOT NULL, + group_type text NOT NULL, + created text NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (admin) REFERENCES users(id) +); + +CREATE TABLE posts ( + id int NOT NULL, + -- Reserved keyword: renamed from 'user' to 'user_id' to avoid k9db crashing + user_id int NOT NULL, + description text NOT NULL, + imgSrc text NOT NULL, + -- Reserved keyword: k9db crashes when column is called 'filter' + -- filter text NOT NULL, + location text NOT NULL, + type text NOT NULL, + group_id int NOT NULL, + post_time text NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY users(id), + FOREIGN KEY (group_id) REFERENCES groups1(id) +); + +CREATE TABLE blocks ( + block_id int NOT NULL, + block_by int NOT NULL, + user_id int NOT NULL, + block_time text NOT NULL, + PRIMARY KEY (block_id), + FOREIGN KEY (user_id) REFERENCES users(id), + FOREIGN KEY (block_by) OWNED_BY users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE bookmarks ( + bkmrk_id int NOT NULL, + bkmrk_by int NOT NULL, + post_id int NOT NULL, + bkmrk_time text NOT NULL, + PRIMARY KEY (bkmrk_id), + FOREIGN KEY (post_id) REFERENCES posts(id), + FOREIGN KEY (bkmrk_by) OWNED_BY users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE comments ( + comment_id int NOT NULL, + type text NOT NULL, + text text NOT NULL, + commentSrc text NOT NULL, + comment_by int NOT NULL, + post_id int NOT NULL, + comment_time text NOT NULL, + PRIMARY KEY (comment_id), + FOREIGN KEY (post_id) REFERENCES posts(id), + FOREIGN KEY (comment_by) OWNED_BY users(id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +CREATE TABLE conversations ( + con_id int NOT NULL, + user_one int NOT NULL, + user_two int NOT NULL, + con_time text NOT NULL, + PRIMARY KEY (con_id), + FOREIGN KEY (user_one) OWNED_BY users(id), + FOREIGN KEY (user_two) OWNED_BY users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE favourites ( + fav_id int NOT NULL, + fav_by int NOT NULL, + user int NOT NULL, + fav_time text NOT NULL, + PRIMARY KEY (fav_id), + FOREIGN KEY (user) REFERENCES users(id), + FOREIGN KEY (fav_by) OWNED_BY users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE follow_system ( + follow_id int NOT NULL, + follow_by int NOT NULL, + follow_by_username text NOT NULL, + follow_to int NOT NULL, + follow_to_username text NOT NULL, + follow_time text NOT NULL, + PRIMARY KEY (follow_id), + FOREIGN KEY (follow_by) OWNED_BY users(id), + FOREIGN KEY (follow_to) REFERENCES users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE group_members ( + grp_member_id int NOT NULL, + group_id int NOT NULL, + member int NOT NULL, + added_by int NOT NULL, + joined_group text NOT NULL, + PRIMARY KEY (grp_member_id), + FOREIGN KEY (member) OWNED_BY users(id), + FOREIGN KEY (added_by) ACCESSED_BY users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE hashtags ( + hashtag_id int NOT NULL, + hashtag text NOT NULL, + post_id int NOT NULL, + -- Reserved keyword: renamed from 'user' to 'user_id' to avoid k9db crashing + user_id int NOT NULL, + hashtag_time text NOT NULL, + PRIMARY KEY (hashtag_id), + FOREIGN KEY (user_id) OWNED_BY users(id), + FOREIGN KEY (post_id) REFERENCES posts(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE likes ( + like_id int NOT NULL, + post_id int NOT NULL, + like_by int NOT NULL, + like_time text NOT NULL, + PRIMARY KEY (like_id), + FOREIGN KEY (like_by) OWNED_BY users(id), + FOREIGN KEY (post_id) REFERENCES posts(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +CREATE TABLE messages ( + message_id int NOT NULL, + con_id int NOT NULL, + mssg_by int NOT NULL, + mssg_to int NOT NULL, + message text NOT NULL, + type text NOT NULL, + status text NOT NULL, + message_time text NOT NULL, + PRIMARY KEY (message_id), + FOREIGN KEY (mssg_by) OWNED_BY users(id), + FOREIGN KEY (mssg_to) OWNED_BY users(id), + FOREIGN KEY (con_id) REFERENCES conversations(con_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + + +CREATE TABLE notifications ( + notify_id int NOT NULL, + notify_by int NOT NULL, + notify_to int NOT NULL, + post_id int NOT NULL, + group_id int NOT NULL, + type text NOT NULL, + user int NOT NULL, + notify_time text NOT NULL, + status text NOT NULL, + PRIMARY KEY (notify_id), + FOREIGN KEY (post_id) REFERENCES posts(id), + FOREIGN KEY (group_id) REFERENCES groups1(id), + FOREIGN KEY (notify_by) REFERENCES users(id), + FOREIGN KEY (notify_to) OWNED_BY users(id), + FOREIGN KEY (user) REFERENCES users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE post_tags ( + post_tag_id int NOT NULL, + post_id int NOT NULL, + user int NOT NULL, + PRIMARY KEY (post_tag_id), + FOREIGN KEY (user) OWNED_BY users(id), + FOREIGN KEY (post_id) REFERENCES posts(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE profile_views ( + view_id int NOT NULL, + view_by int NOT NULL, + view_to int NOT NULL, + view_time text NOT NULL, + PRIMARY KEY (view_id), + FOREIGN KEY (view_by) OWNED_BY users(id), + FOREIGN KEY (view_to) REFERENCES users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE recommendations ( + recommend_id int NOT NULL, + recommend_by int NOT NULL, + recommend_to int NOT NULL, + recommend_of int NOT NULL, + recommend_time text NOT NULL, + PRIMARY KEY (recommend_id), + FOREIGN KEY (recommend_by) OWNED_BY users(id), + FOREIGN KEY (recommend_to) REFERENCES users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE shares ( + share_id int NOT NULL, + share_by int NOT NULL, + share_to int NOT NULL, + post_id int NOT NULL, + share_time text NOT NULL, + PRIMARY KEY (share_id), + FOREIGN KEY (share_by) OWNED_BY users(id), + FOREIGN KEY (share_to) REFERENCES users(id), + FOREIGN KEY (post_id) REFERENCES posts(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE tags ( + tag_id int NOT NULL, + user int NOT NULL, + tag text NOT NULL, + PRIMARY KEY (tag_id), + FOREIGN KEY (user) REFERENCES users(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +EXPLAIN COMPLIANCE; \ No newline at end of file diff --git a/experiments/schema-annot/annotated/mouthful-annotated.sql b/experiments/schema-annot/annotated/mouthful-annotated.sql new file mode 100644 index 00000000..b8355dd6 --- /dev/null +++ b/experiments/schema-annot/annotated/mouthful-annotated.sql @@ -0,0 +1,25 @@ +-- modified from original, see issue #171 +CREATE DATA_SUBJECT TABLE user ( + id text PRIMARY KEY +); + +CREATE TABLE Thread( + Id int PRIMARY KEY, + CreatedAt datetime not null, + Path text not null +); + +CREATE TABLE Comment( + Id int PRIMARY KEY, + ThreadId int not null, + Body text not null, + Author text not null, + Confirmed int not null, + CreatedAt datetime not null, + ReplyTo int not null, + DeletedAt datetime not null, + FOREIGN KEY(ThreadId) references Thread(Id), + FOREIGN KEY(Author) OWNED_BY user(id) +); + +EXPLAIN COMPLIANCE; \ No newline at end of file diff --git a/experiments/schema-annot/annotated/schnack-annotated.sql b/experiments/schema-annot/annotated/schnack-annotated.sql new file mode 100644 index 00000000..f7650d5f --- /dev/null +++ b/experiments/schema-annot/annotated/schnack-annotated.sql @@ -0,0 +1,46 @@ +CREATE DATA_SUBJECT TABLE user ( + id int NOT NULL, + name text, + display_name text, + provider text, + provider_id text, + created_at text NOT NULL, + blocked int, + trusted int, + PRIMARY KEY (id) +); + +CREATE TABLE comment ( + id int NOT NULL, + user_id int NOT NULL, + slug text NOT NULL, + created_at text NOT NULL, + comment text NOT NULL, + rejected int, + approved int, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY user(id) +); + +CREATE TABLE setting ( + name text PRIMARY KEY NOT NULL, + active int NOT NULL +); + +CREATE TABLE subscription ( + endpoint text PRIMARY KEY NOT NULL, + publicKey text NOT NULL, + auth text NOT NULL +); + +CREATE TABLE oauth_provider ( + id int PRIMARY KEY NOT NULL, + provider text, + provider_app_id text, + domain text, + client_id text, + client_secret text, + created_at text NOT NULL +); + +EXPLAIN COMPLIANCE; \ No newline at end of file diff --git a/experiments/schema-annot/annotated/socify-annotated.sql b/experiments/schema-annot/annotated/socify-annotated.sql new file mode 100644 index 00000000..6e063a82 --- /dev/null +++ b/experiments/schema-annot/annotated/socify-annotated.sql @@ -0,0 +1,251 @@ +CREATE DATA_SUBJECT TABLE users ( + id int, + name text, + email text, + encrypted_password text, + bio text, + avatar text, + cover text, + reset_password_token text, + reset_password_sent_at datetime, + remember_created_at datetime, + sign_in_count int, + current_sign_in_at datetime, + last_sign_in_at datetime, + current_sign_in_ip text, + last_sign_in_ip text, + confirmation_token text, + confirmed_at datetime, + confirmation_sent_at datetime, + created_at datetime, + updated_at datetime, + sex text, + location text, + dob text, + phone_number text, + posts_count int, + slug text, + profile_complete text, + first_name text, + last_name text, + hometown text, + works_at text, + photo_albums_count int, + sash_id int, + level int, + PRIMARY KEY (id) +); + +CREATE TABLE activities ( + id int, + trackable_type text, + trackable_id int, + owner_type text, + owner_id int, + -- key text, + parameters text, + recipient_type text, + recipient_id int, + created_at datetime, + updated_at datetime, + PRIMARY KEY (id), + FOREIGN KEY (owner_id) OWNED_BY users(id), + FOREIGN KEY (recipient_id) REFERENCES users(id) +); + +CREATE TABLE attachments ( + file_name text, + attachable_type text, + attachable_id int, + created_at datetime, + updated_at datetime, + PRIMARY KEY (attachable_id) +); + +CREATE TABLE authentications ( + uuid text, + provider text, + oauth_token text, + user_id int, + created_at datetime, + updated_at datetime, + PRIMARY KEY (uuid), + FOREIGN KEY (user_id) OWNED_BY users(id) +); + +CREATE TABLE sashes ( + id int, + created_at datetime, + updated_at datetime, + PRIMARY KEY (id) +); + +CREATE TABLE badges_sashes ( + badge_id int, + sash_id int, + notified_user int, + updated_at datetime, + PRIMARY KEY (badge_id), + FOREIGN KEY (notified_user) REFERENCES users(id), + FOREIGN KEY (sash_id) REFERENCES sashes(id) +) + +CREATE TABLE comments ( + title text, + comment text, + commentable_type text, + commentable_id int, + user_id int, + role text, + created_at datetime, + updated_at datetime, + comment_html text, + PRIMARY KEY (commentable_id), + FOREIGN KEY (user_id) OWNED_BY users(id) +); + +CREATE TABLE events ( + id int, + name text, + event_datetime text, + user_id int, + created_at datetime, + updated_at datetime, + cached_votes_up int, + comments_count int, + location text, + latlon text, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY users(id) +); + +CREATE TABLE event_attendees ( + event_id int, + user_id int, + created_at datetime, + updated_at datetime, + status text, + PRIMARY KEY (event_id), + FOREIGN KEY (user_id) OWNED_BY users(id), + FOREIGN KEY (event_id) REFERENCES events(id) +); + +CREATE TABLE follows ( + followable_type text, + followable_id int, + follower_type text, + follower_id int, + blocked text, + created_at datetime, + updated_at datetime, + PRIMARY KEY (followable_id), + FOREIGN KEY (followable_id) REFERENCES users(id), + FOREIGN KEY (follower_id) OWNED_BY users(id) +) + +CREATE TABLE friendly_id_slugs ( + slug text, + sluggable_id int, + sluggable_type text, + scope text, + created_at datetime, + PRIMARY KEY (sluggable_id) +); + +CREATE TABLE merit_actions ( + id int, + user_id int, + action_method text, + action_value text, + had_errors text, + target_model text, + target_id int, + processed text, + log text, + created_at datetime, + updated_at datetime, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY users(id) +); + +CREATE TABLE merit_activity_logs ( + action_id int, + related_change_type text, + related_change_id int, + description text, + created_at datetime, + PRIMARY KEY (related_change_id), + FOREIGN KEY (action_id) OWNED_BY merit_actions(id) +); + +CREATE TABLE merit_scores ( + sash_id int, + category text, + PRIMARY KEY (sash_id), + FOREIGN KEY (sash_id) REFERENCES sashes(id) +); + +CREATE TABLE merit_score_points ( + score_id int, + num_points int, + log text, + created_at datetime, + PRIMARY KEY (score_id), + FOREIGN KEY (score_id) REFERENCES merit_scores(sash_id) +); + +CREATE TABLE photo_albums ( + id int, + title text, + front_image_url text, + photos_count int, + user_id int, + created_at datetime, + updated_at datetime, + slug text, + cached_votes_up int, + comments_count int, + PRIMARY KEY (id), + FOREIGN KEY (user_id) OWNED_BY users (id) +); + +CREATE TABLE photos ( + id int, + title text, + file text, + photo_album_id int, + created_at datetime, + updated_at datetime, + PRIMARY KEY (id), + FOREIGN KEY (photo_album_id) REFERENCES photo_albums(id) +); + +CREATE TABLE posts ( + content text, + user_id int, + attachment text, + created_at datetime, + updated_at datetime, + cached_votes_up int, + comments_count int, + preview_html text, + PRIMARY KEY (user_id), + FOREIGN KEY (user_id) OWNED_BY users(id) +); + +CREATE TABLE votes ( + id int, + votable_type text, + votable_id int, + voter_type text, + voter_id int, + vote_flag text, + vote_scope text, + vote_weight int, + created_at datetime, + updated_at datetime, + PRIMARY KEY (id), + FOREIGN KEY (voter_id) REFERENCES users(id) +); + +EXPLAIN COMPLIANCE; \ No newline at end of file diff --git a/experiments/schema-annot/commento.sql b/experiments/schema-annot/commento.sql deleted file mode 100644 index d7223ee9..00000000 --- a/experiments/schema-annot/commento.sql +++ /dev/null @@ -1,166 +0,0 @@ --- Initial PostgreSQL database schema - -CREATE TABLE IF NOT EXISTS config ( - allowNewOwners BOOLEAN NOT NULL -); - -INSERT INTO -config (allowNewOwners) -VALUES (true); - -CREATE TABLE IF NOT EXISTS owners ( - ownerHex TEXT NOT NULL UNIQUE PRIMARY KEY , - PII_email TEXT NOT NULL UNIQUE , - name TEXT NOT NULL , - passwordHash TEXT NOT NULL , - confirmedEmail TEXT NOT NULL DEFAULT false , - joinDate TIMESTAMP NOT NULL -); - -CREATE TABLE IF NOT EXISTS ownerSessions ( - session TEXT NOT NULL UNIQUE PRIMARY KEY , - ownerHex TEXT NOT NULL , - loginDate TIMESTAMP NOT NULL, - FOREIGN KEY (ownerHex) REFERENCES owners(ownerHex) -); - -CREATE TABLE IF NOT EXISTS ownerConfirmHexes ( - confirmHex TEXT NOT NULL UNIQUE PRIMARY KEY , - ownerHex TEXT NOT NULL , - sendDate TEXT NOT NULL, - FOREIGN KEY (ownerHex) REFERENCES owners(ownerHex) -); - -CREATE TABLE IF NOT EXISTS ownerResetHexes ( - resetHex TEXT NOT NULL UNIQUE PRIMARY KEY , - ownerHex TEXT NOT NULL , - sendDate TEXT NOT NULL, - FOREIGN KEY (ownerHex) REFERENCES owners(ownerHex) -); - -CREATE TABLE IF NOT EXISTS domains ( - domain TEXT NOT NULL UNIQUE PRIMARY KEY , - ownerHex TEXT NOT NULL , - name TEXT NOT NULL , - creationDate TIMESTAMP NOT NULL , - state TEXT NOT NULL DEFAULT 'unfrozen' , - importedComments TEXT NOT NULL DEFAULT false , - autoSpamFilter BOOLEAN NOT NULL DEFAULT true , - requireModeration BOOLEAN NOT NULL DEFAULT false , - requireIdentification BOOLEAN NOT NULL DEFAULT true , - viewsThisMonth INTEGER NOT NULL DEFAULT 0, - FOREIGN KEY (ownerHex) REFERENCES owners(ownerHex) -); - -CREATE TABLE IF NOT EXISTS moderators ( - domain TEXT NOT NULL , - PII_email TEXT NOT NULL , - addDate TIMESTAMP NOT NULL , - PRIMARY KEY (domain, email), - FOREIGN KEY (domain) REFERENCES domains(domain) -); - -CREATE TABLE IF NOT EXISTS commenters ( - commenterHex TEXT NOT NULL UNIQUE PRIMARY KEY , - PII_email TEXT NOT NULL , - name TEXT NOT NULL , - link TEXT NOT NULL , - photo TEXT NOT NULL , - provider TEXT NOT NULL , - joinDate TIMESTAMP NOT NULL , - state TEXT NOT NULL DEFAULT 'ok' -); - -CREATE TABLE IF NOT EXISTS commenterSessions ( - session TEXT NOT NULL UNIQUE PRIMARY KEY , - commenterHex TEXT NOT NULL DEFAULT 'none' , - creationDate TIMESTAMP NOT NULL, - FOREIGN KEY (commenterHex) REFERENCES commenters(commenterHex) -); - -CREATE TABLE IF NOT EXISTS comments ( - commentHex TEXT NOT NULL UNIQUE PRIMARY KEY , - domain TEXT NOT NULL , - path TEXT NOT NULL , - OWNER_commenterHex TEXT NOT NULL , - markdown TEXT NOT NULL , - html TEXT NOT NULL , - parentHex TEXT NOT NULL , - score INTEGER NOT NULL DEFAULT 0 , - state TEXT NOT NULL DEFAULT 'unapproved' , -- not a BOOLEAN because I expect more states in the future - creationDate TIMESTAMP NOT NULL, - FOREIGN KEY (OWNER_commenterHex) REFERENCES commenters(commenterHex), - FOREIGN KEY (domain) REFERENCES domains(domain) -); - --- DELETEing a comment should recursively delete all children -CREATE OR REPLACE FUNCTION commentsDeleteTriggerFunction() RETURNS TRIGGER AS $trigger$ -BEGIN - DELETE FROM comments - WHERE parentHex = old.commentHex; - - RETURN NULL; -END; -$trigger$ LANGUAGE plpgsql; - -CREATE TRIGGER commentsDeleteTrigger AFTER DELETE ON comments -FOR EACH ROW EXECUTE PROCEDURE commentsDeleteTriggerFunction(); - -CREATE TABLE IF NOT EXISTS votes ( - commentHex TEXT NOT NULL , - commenterHex TEXT NOT NULL , - direction INTEGER NOT NULL , - voteDate TIMESTAMP NOT NULL, - FOREIGN KEY (commenterHex) REFERENCES commenters(commenterHex) -); - -CREATE UNIQUE INDEX votesUniqueIndex ON votes(commentHex, commenterHex); - -CREATE OR REPLACE FUNCTION votesInsertTriggerFunction() RETURNS TRIGGER AS $trigger$ -BEGIN - UPDATE comments - SET score = score + new.direction - WHERE commentHex = new.commentHex; - - RETURN NEW; -END; -$trigger$ LANGUAGE plpgsql; - -CREATE TRIGGER votesInsertTrigger AFTER INSERT ON votes -FOR EACH ROW EXECUTE PROCEDURE votesInsertTriggerFunction(); - -CREATE OR REPLACE FUNCTION votesUpdateTriggerFunction() RETURNS TRIGGER AS $trigger$ -BEGIN - UPDATE comments - SET score = score - old.direction + new.direction - WHERE commentHex = old.commentHex; - - RETURN NEW; -END; -$trigger$ LANGUAGE plpgsql; - -CREATE TRIGGER votesUpdateTrigger AFTER UPDATE ON votes -FOR EACH ROW EXECUTE PROCEDURE votesUpdateTriggerFunction(); - -CREATE TABLE IF NOT EXISTS views ( - domain TEXT NOT NULL , - OWNER_commenterHex TEXT NOT NULL , - viewDate TIMESTAMP NOT NULL, - FOREIGN KEY (OWNER_commenterHex) REFERENCES commenters(commenterHex), - FOREIGN KEY (domain) REFERENCES domains(domain) -); - -CREATE INDEX IF NOT EXISTS domainIndex ON views(domain); - -CREATE OR REPLACE FUNCTION viewsInsertTriggerFunction() RETURNS TRIGGER AS $trigger$ -BEGIN - UPDATE domains - SET viewsThisMonth = viewsThisMonth + 1 - WHERE domain = new.domain; - - RETURN NULL; -END; -$trigger$ LANGUAGE plpgsql; - -CREATE TRIGGER viewsInsertTrigger AFTER INSERT ON views -FOR EACH ROW EXECUTE PROCEDURE viewsInsertTriggerFunction(); diff --git a/experiments/schema-annot/ghchat.sql b/experiments/schema-annot/ghchat.sql deleted file mode 100644 index 30d012f4..00000000 --- a/experiments/schema-annot/ghchat.sql +++ /dev/null @@ -1,143 +0,0 @@ -# ************************************************************ -# Sequel Pro SQL dump -# Version 4541 -# -# http://www.sequelpro.com/ -# https://github.com/sequelpro/sequelpro -# -# Host: localhost (MySQL 5.7.22) -# Database: ghchat -# Generation Time: 2019-07-29 03:01:21 +0000 -# ************************************************************ - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - - -# Dump of table group_info -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `group_info`; - -CREATE TABLE `group_info` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `to_group_id` char(100) NOT NULL DEFAULT '', - `name` varchar(20) NOT NULL DEFAULT '', - `group_notice` varchar(100) NOT NULL DEFAULT '', - `creator_id` int(11) NOT NULL, - `create_time` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`creator_id`) REFERENCES user_info(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - -# Dump of table group_msg -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `group_msg`; - -CREATE TABLE `group_msg` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `from_user` int(11) NOT NULL, - `to_group_id` char(100) NOT NULL DEFAULT '', - `message` text NOT NULL, - `time` int(11) NOT NULL, - `attachments` varchar(250) DEFAULT '''[]''', - PRIMARY KEY (`id`), - KEY `to_group` (`to_group_id`), - FOREIGN KEY (`from_user`) REFERENCES user_info(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - -# Dump of table group_user_relation -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `group_user_relation`; - -CREATE TABLE `group_user_relation` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `to_group_id` char(100) NOT NULL DEFAULT '', - `user_id` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`user_id`) REFERENCES user_info(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - -# Dump of table private_msg -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `private_msg`; - -CREATE TABLE `private_msg` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `OWNER_from_user` int(11) NOT NULL, - `OWNER_to_user` int(11) NOT NULL, - `message` text, - `time` int(11) NOT NULL, - `attachments` varchar(250) DEFAULT '[]', - PRIMARY KEY (`id`), - KEY `OWNER_from_user` (`OWNER_from_user`), - KEY `OWNER_to_user` (`OWNER_to_user`), - FOREIGN KEY (`OWNER_from_user`) REFERENCES user_info(id), - FOREIGN KEY (`OWNER_to_user`) REFERENCES user_info(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - -# Dump of table user_info -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `user_info`; - -CREATE TABLE `user_info` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `github_id` int(11) DEFAULT NULL, - `PII_name` varchar(20) NOT NULL DEFAULT 'NOT NULL', - `password` varchar(40) DEFAULT NULL, - `avatar` varchar(250) DEFAULT '', - `location` varchar(50) DEFAULT NULL, - `socketid` char(255) DEFAULT NULL, - `website` varchar(50) DEFAULT NULL, - `github` varchar(50) DEFAULT NULL, - `intro` varchar(100) DEFAULT NULL, - `company` varchar(50) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - -# Dump of table user_user_relation -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `user_user_relation`; - -CREATE TABLE `user_user_relation` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `OWNER_user_id` int(11) NOT NULL, - `OWNER_from_user` int(11) NOT NULL, - `remark` varchar(10) DEFAULT '', - `shield` tinyint(1) NOT NULL DEFAULT '0', - `time` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`OWNER_user_id`) REFERENCES user_info(id), - FOREIGN KEY (`OWNER_from_user`) REFERENCES user_info(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - - -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/experiments/schema-annot/hotcrp.sql b/experiments/schema-annot/hotcrp.sql deleted file mode 100644 index b119789d..00000000 --- a/experiments/schema-annot/hotcrp.sql +++ /dev/null @@ -1,583 +0,0 @@ --- --- Table structure for table `ActionLog` --- - -DROP TABLE IF EXISTS `ActionLog`; -CREATE TABLE `ActionLog` ( - `logId` int(11) NOT NULL AUTO_INCREMENT, - `OWNER_contactId` int(11) NOT NULL, - `destContactId` int(11) DEFAULT NULL, - `trueContactId` int(11) DEFAULT NULL, - `paperId` int(11) DEFAULT NULL, - `timestamp` bigint(11) NOT NULL, - `ipaddr` varbinary(39) DEFAULT NULL, - `action` varbinary(4096) NOT NULL, - `data` varbinary(8192) DEFAULT NULL, - PRIMARY KEY (`logId`), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactID), - FOREIGN KEY (destContactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (trueContactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `Capability` --- - -DROP TABLE IF EXISTS `Capability`; -CREATE TABLE `Capability` ( - `capabilityType` int(11) NOT NULL, - `OWNER_contactId` int(11) NOT NULL, - `paperId` int(11) NOT NULL, - `timeExpires` bigint(11) NOT NULL, - `salt` varbinary(255) NOT NULL, - `data` varbinary(4096) DEFAULT NULL, - PRIMARY KEY (`salt`), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `ContactInfo` --- - -DROP TABLE IF EXISTS `ContactInfo`; -CREATE TABLE `ContactInfo` ( - `contactId` int(11) NOT NULL AUTO_INCREMENT, - `firstName` varbinary(120) NOT NULL DEFAULT '', - `lastName` varbinary(120) NOT NULL DEFAULT '', - `unaccentedName` varbinary(240) NOT NULL DEFAULT '', - `PII_email` varchar(120) NOT NULL, - `preferredEmail` varchar(120) DEFAULT NULL, - `affiliation` varbinary(2048) NOT NULL DEFAULT '', - `phone` varbinary(64) DEFAULT NULL, - `country` varbinary(256) DEFAULT NULL, - `password` varbinary(2048) NOT NULL, - `passwordTime` bigint(11) NOT NULL DEFAULT '0', - `passwordUseTime` bigint(11) NOT NULL DEFAULT '0', - `collaborators` varbinary(8192) DEFAULT NULL, - `creationTime` bigint(11) NOT NULL DEFAULT '0', - `updateTime` bigint(11) NOT NULL DEFAULT '0', - `lastLogin` bigint(11) NOT NULL DEFAULT '0', - `defaultWatch` int(11) NOT NULL DEFAULT '2', - `roles` tinyint(1) NOT NULL DEFAULT '0', - `disabled` tinyint(1) NOT NULL DEFAULT '0', - `contactTags` varbinary(4096) DEFAULT NULL, - `birthday` int(11) DEFAULT NULL, - `gender` varbinary(24) DEFAULT NULL, - `data` varbinary(32767) DEFAULT NULL, - PRIMARY KEY (`contactId`), - UNIQUE KEY `email` (`email`), - KEY `roles` (`roles`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `DeletedContactInfo` --- - -DROP TABLE IF EXISTS `DeletedContactInfo`; -CREATE TABLE `DeletedContactInfo` ( - `contactId` int(11) NOT NULL, - `firstName` varbinary(120) NOT NULL, - `lastName` varbinary(120) NOT NULL, - `unaccentedName` varbinary(240) NOT NULL, - `email` varchar(120) NOT NULL, - FOREIGN KEY (contactId) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `DocumentLink` --- - -DROP TABLE IF EXISTS `DocumentLink`; -CREATE TABLE `DocumentLink` ( - `paperId` int(11) NOT NULL, - `linkId` int(11) NOT NULL, - `linkType` int(11) NOT NULL, - `documentId` int(11) NOT NULL, - PRIMARY KEY (`paperId`,`linkId`,`linkType`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `FilteredDocument` --- - -DROP TABLE IF EXISTS `FilteredDocument`; -CREATE TABLE `FilteredDocument` ( - `OWNER_inDocId` int(11) NOT NULL, - `filterType` int(11) NOT NULL, - `outDocId` int(11) NOT NULL, - `createdAt` bigint(11) NOT NULL, - PRIMARY KEY (`inDocId`,`filterType`), - FOREIGN KEY (OWNER_inDocId) REFERENCES DocumentLink(documentId), - FOREIGN KEY (outDocId) REFERENCES DocumentLink(documentId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `Formula` --- - -DROP TABLE IF EXISTS `Formula`; -CREATE TABLE `Formula` ( - `formulaId` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(200) NOT NULL, - `expression` varbinary(4096) NOT NULL, - `createdBy` int(11) NOT NULL DEFAULT '0', - `timeModified` bigint(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`formulaId`), - FOREIGN KEY (createdBy) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `MailLog` --- - -DROP TABLE IF EXISTS `MailLog`; -CREATE TABLE `MailLog` ( - `mailId` int(11) NOT NULL AUTO_INCREMENT, - `recipients` varbinary(200) NOT NULL, - `q` varbinary(4096) DEFAULT NULL, - `t` varbinary(200) DEFAULT NULL, - `paperIds` blob, - `cc` blob, - `replyto` blob, - `subject` blob, - `emailBody` blob, - `fromNonChair` tinyint(1) NOT NULL DEFAULT '0', - `status` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`mailId`), - FOREIGN KEY (paperIDs) REFERENCES Paper(paperId) -- sort of -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `Paper` --- - -DROP TABLE IF EXISTS `Paper`; -CREATE TABLE `Paper` ( - `paperId` int(11) NOT NULL AUTO_INCREMENT, - `title` varbinary(512) DEFAULT NULL, - `authorInformation` varbinary(8192) DEFAULT NULL, - `abstract` varbinary(16384) DEFAULT NULL, - `collaborators` varbinary(8192) DEFAULT NULL, - `timeSubmitted` bigint(11) NOT NULL DEFAULT '0', - `timeWithdrawn` bigint(11) NOT NULL DEFAULT '0', - `timeFinalSubmitted` bigint(11) NOT NULL DEFAULT '0', - `timeModified` bigint(11) NOT NULL DEFAULT '0', - `paperStorageId` int(11) NOT NULL DEFAULT '0', - # `sha1` copied from PaperStorage to reduce joins - `sha1` varbinary(64) NOT NULL DEFAULT '', - `finalPaperStorageId` int(11) NOT NULL DEFAULT '0', - `blind` tinyint(1) NOT NULL DEFAULT '1', - `outcome` tinyint(1) NOT NULL DEFAULT '0', - `OWNER_leadContactId` int(11) NOT NULL DEFAULT '0', - `OWNER_shepherdContactId` int(11) NOT NULL DEFAULT '0', - `managerContactId` int(11) NOT NULL DEFAULT '0', - `capVersion` int(1) NOT NULL DEFAULT '0', - # next 3 fields copied from PaperStorage to reduce joins - `size` int(11) NOT NULL DEFAULT '0', - `mimetype` varbinary(80) NOT NULL DEFAULT '', - `timestamp` bigint(11) NOT NULL DEFAULT '0', - `pdfFormatStatus` bigint(11) NOT NULL DEFAULT '0', - `withdrawReason` varbinary(1024) DEFAULT NULL, - `paperFormat` tinyint(1) DEFAULT NULL, - `dataOverflow` longblob, - PRIMARY KEY (`paperId`), - KEY `timeSubmitted` (`timeSubmitted`), - KEY `leadContactId` (`leadContactId`), - KEY `shepherdContactId` (`shepherdContactId`), - FOREIGN KEY (paperStorageId) REFERENCES PaperStorage(paperStorageId), - FOREIGN KEY (finalPaperStorageId) REFERENCES PaperStorage(paperStorageId), - FOREIGN KEY (OWNER_leadContactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (OWNER_shepherdContactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (managerContactId) REFERENCES ContactInfo(contactId), -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperComment` --- - -DROP TABLE IF EXISTS `PaperComment`; -CREATE TABLE `PaperComment` ( - `paperId` int(11) NOT NULL, -- should be OWNER if we could filter on comment type - `commentId` int(11) NOT NULL AUTO_INCREMENT, - `OWNER_contactId` int(11) NOT NULL, - `timeModified` bigint(11) NOT NULL, - `timeNotified` bigint(11) NOT NULL DEFAULT '0', - `timeDisplayed` bigint(11) NOT NULL DEFAULT '0', - `comment` varbinary(32767) DEFAULT NULL, - `commentType` int(11) NOT NULL DEFAULT '0', - `replyTo` int(11) NOT NULL, - `ordinal` int(11) NOT NULL DEFAULT '0', - `authorOrdinal` int(11) NOT NULL DEFAULT '0', - `commentTags` varbinary(1024) DEFAULT NULL, - `commentRound` int(11) NOT NULL DEFAULT '0', - `commentFormat` tinyint(1) DEFAULT NULL, - `commentOverflow` longblob, - PRIMARY KEY (`paperId`,`commentId`), - UNIQUE KEY `commentId` (`commentId`), - KEY `contactId` (`contactId`), - KEY `timeModifiedContact` (`timeModified`,`contactId`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperConflict` --- - -DROP TABLE IF EXISTS `PaperConflict`; -CREATE TABLE `PaperConflict` ( - `paperId` int(11) NOT NULL, - `OWNER_contactId` int(11) NOT NULL, - `conflictType` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`contactId`,`paperId`), - KEY `paperId` (`paperId`), - FOREIGN KEY (paperId) REFERENCES Paper(paperID), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperOption` --- - -DROP TABLE IF EXISTS `PaperOption`; -CREATE TABLE `PaperOption` ( - `paperId` int(11) NOT NULL, - `optionId` int(11) NOT NULL, - `value` bigint(11) NOT NULL DEFAULT '0', - `data` varbinary(32767) DEFAULT NULL, - `dataOverflow` longblob, - PRIMARY KEY (`paperId`,`optionId`,`value`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperReview` --- - -DROP TABLE IF EXISTS `PaperReview`; -CREATE TABLE `PaperReview` ( - `paperId` int(11) NOT NULL, - `reviewId` int(11) NOT NULL AUTO_INCREMENT, - `OWNER_contactId` int(11) NOT NULL, - `reviewToken` int(11) NOT NULL DEFAULT '0', - `reviewType` tinyint(1) NOT NULL DEFAULT '0', - `reviewRound` int(1) NOT NULL DEFAULT '0', - `requestedBy` int(11) NOT NULL DEFAULT '0', - `timeRequested` bigint(11) NOT NULL DEFAULT '0', - `timeRequestNotified` bigint(11) NOT NULL DEFAULT '0', - `reviewBlind` tinyint(1) NOT NULL DEFAULT '1', - `reviewModified` bigint(1) NOT NULL DEFAULT '0', - `reviewAuthorModified` bigint(1) DEFAULT NULL, - `reviewSubmitted` bigint(1) DEFAULT NULL, - `reviewNotified` bigint(1) DEFAULT NULL, - `reviewAuthorNotified` bigint(11) NOT NULL DEFAULT '0', - `reviewAuthorSeen` bigint(1) DEFAULT NULL, - `reviewOrdinal` int(1) NOT NULL DEFAULT '0', - `reviewViewScore` tinyint(2) NOT NULL DEFAULT '-3', - `timeDisplayed` bigint(11) NOT NULL DEFAULT '0', - `timeApprovalRequested` bigint(11) NOT NULL DEFAULT '0', - `reviewEditVersion` int(1) NOT NULL DEFAULT '0', - `reviewNeedsSubmit` tinyint(1) NOT NULL DEFAULT '1', - `reviewWordCount` int(11) DEFAULT NULL, - `reviewFormat` tinyint(1) DEFAULT NULL, - - `overAllMerit` tinyint(1) NOT NULL DEFAULT '0', - `reviewerQualification` tinyint(1) NOT NULL DEFAULT '0', - `novelty` tinyint(1) NOT NULL DEFAULT '0', - `technicalMerit` tinyint(1) NOT NULL DEFAULT '0', - `interestToCommunity` tinyint(1) NOT NULL DEFAULT '0', - `longevity` tinyint(1) NOT NULL DEFAULT '0', - `grammar` tinyint(1) NOT NULL DEFAULT '0', - `likelyPresentation` tinyint(1) NOT NULL DEFAULT '0', - `suitableForShort` tinyint(1) NOT NULL DEFAULT '0', - `potential` tinyint(4) NOT NULL DEFAULT '0', - `fixability` tinyint(4) NOT NULL DEFAULT '0', - - `tfields` longblob, - `sfields` varbinary(2048) DEFAULT NULL, - `data` varbinary(8192) DEFAULT NULL, - - PRIMARY KEY (`paperId`,`reviewId`), - UNIQUE KEY `reviewId` (`reviewId`), - KEY `contactId` (`contactId`), - KEY `reviewType` (`reviewType`), - KEY `reviewRound` (`reviewRound`), - KEY `requestedBy` (`requestedBy`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (requestedBy) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperReviewPreference` --- - -DROP TABLE IF EXISTS `PaperReviewPreference`; -CREATE TABLE `PaperReviewPreference` ( - `paperId` int(11) NOT NULL, - `OWNER_contactId` int(11) NOT NULL, - `preference` int(4) NOT NULL DEFAULT '0', - `expertise` int(4) DEFAULT NULL, - PRIMARY KEY (`paperId`,`contactId`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperReviewRefused` --- - -DROP TABLE IF EXISTS `PaperReviewRefused`; -CREATE TABLE `PaperReviewRefused` ( - `paperId` int(11) NOT NULL, - `PII_email` varchar(120) NOT NULL, - `firstName` varbinary(120) DEFAULT NULL, - `lastName` varbinary(120) DEFAULT NULL, - `affiliation` varbinary(2048) DEFAULT NULL, - `OWNER_contactId` int(11) NOT NULL, - `OWNER_requestedBy` int(11) NOT NULL, - `timeRequested` bigint(11) DEFAULT NULL, - `OWNER_refusedBy` int(11) DEFAULT NULL, - `timeRefused` bigint(11) DEFAULT NULL, - `reviewType` tinyint(1) NOT NULL DEFAULT '0', - `reviewRound` int(1) DEFAULT NULL, - `data` varbinary(8192) DEFAULT NULL, - `reason` varbinary(32767) DEFAULT NULL, - PRIMARY KEY (`paperId`,`email`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId), - FOREIGN KEY (OWNER_contactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (OWNER_requestedBy) REFERENCES ContactInfo(contactId), - FOREIGN KEY (OWNER_refusedBy) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperStorage` --- - -DROP TABLE IF EXISTS `PaperStorage`; -CREATE TABLE `PaperStorage` ( - `paperId` int(11) NOT NULL, - `paperStorageId` int(11) NOT NULL AUTO_INCREMENT, - `timestamp` bigint(11) NOT NULL, - `mimetype` varbinary(80) NOT NULL DEFAULT '', - `paper` longblob, - `compression` tinyint(1) NOT NULL DEFAULT '0', - `sha1` varbinary(64) NOT NULL DEFAULT '', - `crc32` binary(4) DEFAULT NULL, - `documentType` int(3) NOT NULL DEFAULT '0', - `filename` varbinary(255) DEFAULT NULL, - `infoJson` varbinary(32768) DEFAULT NULL, - `size` bigint(11) DEFAULT NULL, - `filterType` int(3) DEFAULT NULL, - `originalStorageId` int(11) DEFAULT NULL, - `inactive` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`paperId`,`paperStorageId`), - UNIQUE KEY `paperStorageId` (`paperStorageId`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperTag` --- - -DROP TABLE IF EXISTS `PaperTag`; -CREATE TABLE `PaperTag` ( - `paperId` int(11) NOT NULL, - `tag` varchar(80) NOT NULL, # case-insensitive; see TAG_MAXLEN in init.php - `tagIndex` float NOT NULL DEFAULT '0', - PRIMARY KEY (`paperId`,`tag`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperTagAnno` --- - -DROP TABLE IF EXISTS `PaperTagAnno`; -CREATE TABLE `PaperTagAnno` ( - `tag` varchar(80) NOT NULL, # case-insensitive; see TAG_MAXLEN in init.php - `annoId` int(11) NOT NULL, - `tagIndex` float NOT NULL DEFAULT '0', - `heading` varbinary(8192) DEFAULT NULL, - `annoFormat` tinyint(1) DEFAULT NULL, - `infoJson` varbinary(32768) DEFAULT NULL, - PRIMARY KEY (`tag`,`annoId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperTopic` --- - -DROP TABLE IF EXISTS `PaperTopic`; -CREATE TABLE `PaperTopic` ( - `OWNER_paperId` int(11) NOT NULL, - `OWNER_topicId` int(11) NOT NULL, - PRIMARY KEY (`paperId`,`topicId`), - FOREIGN KEY (OWNER_paperId) REFERENCES Paper(paperId), - FOREIGN KEY (OWNER_topicId) REFERENCES TopicArea(topicId), -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `PaperWatch` --- - -DROP TABLE IF EXISTS `PaperWatch`; -CREATE TABLE `PaperWatch` ( - `paperId` int(11) NOT NULL, - `OWNER_contactId` int(11) NOT NULL, - `watch` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`paperId`,`contactId`), - FOREIGN KEY (OWNER_contactId) REFERENCES Paper(contactId), - FOREIGN KEY (paperId) REFERENCES Paper(paperId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `ReviewRating` --- - -DROP TABLE IF EXISTS `ReviewRating`; -CREATE TABLE `ReviewRating` ( - `paperId` int(11) NOT NULL, - `reviewId` int(11) NOT NULL, - `OWNER_contactId` int(11) NOT NULL, - `rating` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`paperId`,`reviewId`,`contactId`) - FOREIGN KEY (OWNER_contactId) REFERENCES Paper(contactId), - FOREIGN KEY (paperId) REFERENCES Paper(paperId), - FOREIGN KEY (reviewId) REFERENCES PaperReview(reviewId), -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `ReviewRequest` --- - -DROP TABLE IF EXISTS `ReviewRequest`; -CREATE TABLE `ReviewRequest` ( - `paperId` int(11) NOT NULL, - `PII_email` varchar(120) NOT NULL, - `firstName` varbinary(120) DEFAULT NULL, - `lastName` varbinary(120) DEFAULT NULL, - `affiliation` varbinary(2048) DEFAULT NULL, - `reason` varbinary(32767) DEFAULT NULL, - `OWNER_requestedBy` int(11) NOT NULL, - `timeRequested` bigint(11) NOT NULL, - `reviewRound` int(1) DEFAULT NULL, - PRIMARY KEY (`paperId`,`email`), - FOREIGN KEY (paperId) REFERENCES Paper(paperId), - FOREIGN KEY (OWNER_requestedBy) REFERENCES ContactInfo(contactId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `Settings` --- - -DROP TABLE IF EXISTS `Settings`; -CREATE TABLE `Settings` ( - `name` varbinary(256) NOT NULL, - `value` bigint(11) NOT NULL, - `data` varbinary(32767) DEFAULT NULL, - PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `TopicArea` --- - -DROP TABLE IF EXISTS `TopicArea`; -CREATE TABLE `TopicArea` ( - `topicId` int(11) NOT NULL AUTO_INCREMENT, - `topicName` varbinary(1024) DEFAULT NULL, - PRIMARY KEY (`topicId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - --- --- Table structure for table `TopicInterest` --- - -DROP TABLE IF EXISTS `TopicInterest`; -CREATE TABLE `TopicInterest` ( - `contactId` int(11) NOT NULL, - `topicId` int(11) NOT NULL, - `interest` int(1) NOT NULL, - PRIMARY KEY (`contactId`,`topicId`), - FOREIGN KEY (contactId) REFERENCES ContactInfo(contactId), - FOREIGN KEY (topicId) REFERENCES TopicArea(topicId) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - - -insert into Settings (name, value) values ('allowPaperOption', 236); -insert into Settings (name, value) values ('setupPhase', 1); --- there are no submissions yet -insert into Settings (name, value) values ('no_papersub', 1); --- collect PC conflicts from authors by default, but not collaborators -insert into Settings (name, value) values ('sub_pcconf', 1); --- default chair-only tags -insert into Settings (name, value, data) values ('tag_chair', 1, 'accept reject pcpaper'); --- default: allow PC members to review any paper -insert into Settings (name, value) values ('pcrev_any', 1); --- default: allow external reviewers to see the other reviews -insert into Settings (name, value) values ('extrev_view', 2); --- default: administrators must approve potentially-conflicted external reviews -insert into Settings (name, value) values ('extrev_chairreq', 2); --- default outcome map -insert into Settings (name, value, data) values ('outcome_map', 1, '{"0":"Unspecified","-1":"Rejected","1":"Accepted"}'); --- default review form -insert into Settings (name, value, data) values ('review_form',1,'{"overAllMerit":{"name":"Overall merit","position":1,"visibility":"au","options":["Reject","Weak reject","Weak accept","Accept","Strong accept"]},"reviewerQualification":{"name":"Reviewer expertise","position":2,"visibility":"au","options":["No familiarity","Some familiarity","Knowledgeable","Expert"]},"t01":{"name":"Paper summary","position":3,"display_space":5,"visibility":"au"},"t02":{"name":"Comments for author","position":4,"display_space":15,"visibility":"au"},"t03":{"name":"Comments for PC","position":5,"display_space":10,"visibility":"pc"}}'); - -insert ignore into PaperStorage set - paperStorageId=1, paperId=0, timestamp=0, mimetype='text/plain', - paper='', sha1=x'da39a3ee5e6b4b0d3255bfef95601890afd80709', - documentType=0, size=0; diff --git a/experiments/schema-annot/instagram_2.sql b/experiments/schema-annot/instagram_2.sql deleted file mode 100644 index 78f3116a..00000000 --- a/experiments/schema-annot/instagram_2.sql +++ /dev/null @@ -1,1219 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.5.1 --- http://www.phpmyadmin.net --- --- Host: 127.0.0.1 --- Generation Time: Jun 10, 2018 at 02:16 PM --- Server version: 10.1.19-MariaDB --- PHP Version: 5.6.28 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; - --- --- Database: `react-instagram-clone` --- - --- -------------------------------------------------------- - --- --- Table structure for table `blocks` --- - -CREATE TABLE `blocks` ( - `block_id` int(11) NOT NULL, - `block_by` int(11) NOT NULL, - `user` int(11) NOT NULL, - `block_time` varchar(100) NOT NULL, - FOREIGN KEY (`user`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `blocks` --- - -INSERT INTO `blocks` (`block_id`, `block_by`, `user`, `block_time`) VALUES -(6, 30, 24, '1518512985015'), -(11, 7, 11, '1518973149200'), -(13, 24, 20, '1524915826749'), -(15, 28, 10, '1528222712390'); - --- -------------------------------------------------------- - --- --- Table structure for table `bookmarks` --- - -CREATE TABLE `bookmarks` ( - `bkmrk_id` int(11) NOT NULL, - `bkmrk_by` int(11) NOT NULL, - `post_id` int(11) NOT NULL, - `bkmrk_time` varchar(100) NOT NULL - FOREIGN KEY (`post_id`) REFERENCES posts(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `bookmarks` --- - -INSERT INTO `bookmarks` (`bkmrk_id`, `bkmrk_by`, `post_id`, `bkmrk_time`) VALUES -(2, 24, 43, '1524497939091'), -(3, 24, 57, '1526210615506'); - --- -------------------------------------------------------- - --- --- Table structure for table `comments` --- - -CREATE TABLE `comments` ( - `comment_id` int(11) NOT NULL, - `type` enum('text','image','sticker') COLLATE utf8mb4_bin NOT NULL, - `text` mediumtext COLLATE utf8mb4_bin NOT NULL, - `commentSrc` mediumtext COLLATE utf8mb4_bin NOT NULL, - `OWNER_comment_by` int(11) NOT NULL, - `post_id` int(11) NOT NULL, - `comment_time` varchar(100) COLLATE utf8mb4_bin NOT NULL - FOREIGN KEY (`post_id`) REFERENCES posts(id), - FOREIGN KEY (`OWNER_comment_by`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; - --- --- Dumping data for table `comments` --- - -INSERT INTO `comments` (`comment_id`, `type`, `text`, `commentSrc`, `comment_by`, `post_id`, `comment_time`) VALUES -(62, 'text', 'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm', '', 30, 57, '1518509780928'), -(63, 'text', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', '', 30, 57, '1518509825922'), -(64, 'text', '#Hello', '', 24, 57, '1518710983444'), -(66, 'text', 'wooo @takkar', '', 7, 88, '1518945524771'), -(69, 'image', '', 'instagram_comment_1518972851259.jpg', 24, 89, '1518972851259'), -(70, 'text', 'thnx @ghalib', '', 24, 88, '1518972932739'), -(71, 'text', 'hmmm', '', 7, 88, '1518973041037'), -(73, 'text', 'https://regexr.com/?37i6s fffffm', '', 24, 89, '1519113671582'), -(102, 'text', 'mmmm', '', 24, 61, '1524764250449'), -(103, 'sticker', '', 'instagram_comment_1527447892610.jpg', 24, 43, '1527447892610'), -(104, 'sticker', '', 'instagram_comment_1527447929485.jpg', 24, 43, '1527447929485'); - --- -------------------------------------------------------- - --- --- Table structure for table `conversations` --- - -CREATE TABLE `conversations` ( - `con_id` int(11) NOT NULL, - `OWNER_user_one` int(11) NOT NULL, - `OWNER_user_two` int(11) NOT NULL, - `con_time` varchar(100) NOT NULL - FOREIGN KEY (OWNER_user_one) REFERENCES users(id), - FOREIGN KEY (OWNER_user_two) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `conversations` --- - -INSERT INTO `conversations` (`con_id`, `user_one`, `user_two`, `con_time`) VALUES -(24, 24, 7, '1518016982813'), -(25, 24, 27, '1518972996540'), -(29, 24, 28, '1523883827593'), -(36, 28, 11, '1525092718181'), -(39, 24, 18, '1525194237021'); - --- -------------------------------------------------------- - --- --- Table structure for table `favourites` --- - -CREATE TABLE `favourites` ( - `fav_id` int(11) NOT NULL, - `fav_by` int(11) NOT NULL, - `user` int(11) NOT NULL, - `fav_time` varchar(100) NOT NULL, - FOREIGN KEY (`user`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `favourites` --- - -INSERT INTO `favourites` (`fav_id`, `fav_by`, `user`, `fav_time`) VALUES -(1, 30, 24, '1518456837902'), -(2, 27, 18, '1523434966799'), -(3, 24, 14, '1524503038800'), -(4, 24, 17, '1524914211955'); - --- -------------------------------------------------------- - --- --- Table structure for table `follow_system` --- - -CREATE TABLE `follow_system` ( - `follow_id` int(11) NOT NULL, - `OWNER_follow_by` int(11) NOT NULL, - `follow_by_username` varchar(32) NOT NULL, - `OWNER_follow_to` int(11) NOT NULL, - `follow_to_username` varchar(32) NOT NULL, - `follow_time` varchar(100) NOT NULL, - FOREIGN KEY (`OWNER_follow_by`) REFERENCES users(id), - FOREIGN KEY (`OWNER_follow_to`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `follow_system` --- - -INSERT INTO `follow_system` (`follow_id`, `follow_by`, `follow_by_username`, `follow_to`, `follow_to_username`, `follow_time`) VALUES -(116, 7, 'ghalib', 8, 'coldplay', '1515919705073'), -(118, 8, 'coldplay', 7, 'ghalib', '1515919766210'), -(183, 7, 'ghalib', 10, 'noddy', '1516633623334'), -(205, 29, 'steve_jobs', 24, 'takkar', '1518018551833'), -(211, 7, 'ghalib', 24, 'takkar', '1518973062269'), -(215, 30, 'doraemon', 24, 'takkar', '1520705816856'), -(228, 11, 'nobita', 18, 'ragnar', '1524499141695'), -(229, 11, 'nobita', 28, 'selena', '1524499144391'), -(230, 11, 'nobita', 10, 'noddy', '1524499148432'), -(231, 11, 'nobita', 8, 'coldplay', '1524499149841'), -(232, 11, 'nobita', 29, 'steve_jobs', '1524499155476'), -(234, 11, 'nobita', 19, 'jonsnow', '1524499189454'), -(235, 11, 'nobita', 12, 'pikachu', '1524499272440'), -(236, 11, 'nobita', 20, 'gian', '1524499274383'), -(237, 11, 'nobita', 13, 'iamsrk', '1524499275724'), -(238, 11, 'nobita', 15, 'suniyo', '1524499276894'), -(239, 11, 'nobita', 30, 'doraemon', '1524499278270'), -(243, 28, 'selena', 11, 'nobita', '1525007005368'), -(246, 24, 'takkar', 7, 'ghalib', '1526210411974'), -(248, 24, 'takkar', 29, 'steve_jobs', '1526210485352'), -(252, 24, 'takkar', 18, 'ragnar', '1526211950472'), -(255, 24, 'takkar', 19, 'jonsnow', '1526212081528'), -(258, 24, 'takkar', 8, 'coldplay', '1526212272503'), -(261, 24, 'takkar', 11, 'nobita', '1526212475856'), -(273, 27, 'taylor_swift', 24, 'takkar', '1526375090236'), -(275, 27, 'taylor_swift', 28, 'selena', '1526375875420'), -(277, 27, 'taylor_swift', 18, 'ragnar', '1526384344800'), -(278, 27, 'taylor_swift', 16, 'zayn', '1526384890053'), -(279, 27, 'taylor_swift', 10, 'noddy', '1526384912449'), -(289, 24, 'takkar', 10, 'noddy', '1526411089128'), -(301, 16, 'zayn', 24, 'takkar', '1526663420190'), -(302, 24, 'takkar', 16, 'zayn', '1528272513281'), -(303, 28, 'selena', 24, 'takkar', '1528534489463'); - --- -------------------------------------------------------- - --- --- Table structure for table `groups` --- - -CREATE TABLE `groups` ( - `group_id` int(11) NOT NULL, - `name` varchar(255) NOT NULL, - `bio` varchar(2000) NOT NULL, - `admin` int(11) NOT NULL, - `group_type` enum('public','private') NOT NULL DEFAULT 'public', - `created` varchar(100) NOT NULL, - FOREIGN KEY (`admin`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `groups` --- - -INSERT INTO `groups` (`group_id`, `name`, `bio`, `admin`, `group_type`, `created`) VALUES -(11, 'a groupss', '#random group', 24, 'private', '1518016737587'), -(12, 'nmnmnmnm', '', 7, 'public', '1518973077594'); - --- -------------------------------------------------------- - --- --- Table structure for table `group_members` --- - -CREATE TABLE `group_members` ( - `grp_member_id` int(11) NOT NULL, - `group_id` int(11) NOT NULL, - `OWNER_member` int(11) NOT NULL, - `added_by` int(11) NOT NULL, - `joined_group` varchar(100) NOT NULL, - FOREIGN KEY (`OWNER_member`) REFERENCES users(id), - FOREIGN KEY (`added_by`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `group_members` --- - -INSERT INTO `group_members` (`grp_member_id`, `group_id`, `member`, `added_by`, `joined_group`) VALUES -(31, 11, 24, 24, '1518016737697'), -(34, 11, 18, 24, '1518016769907'), -(36, 12, 7, 7, '1518973077690'), -(38, 12, 8, 7, '1518973109895'), -(49, 12, 28, 28, '1520846126331'), -(57, 11, 28, 24, '1526212331140'), -(58, 11, 7, 24, '1526212334989'); - --- -------------------------------------------------------- - --- --- Table structure for table `hashtags` --- - -CREATE TABLE `hashtags` ( - `hashtag_id` int(11) NOT NULL, - `hashtag` varchar(1000) NOT NULL, - `post_id` int(11) NOT NULL, - `OWNER_user` int(11) NOT NULL, - `hashtag_time` varchar(100) NOT NULL - FOREIGN KEY (`OWNER_user`) REFERENCES users(id), - FOREIGN KEY (`post_id`) REFERENCES posts(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `hashtags` --- - -INSERT INTO `hashtags` (`hashtag_id`, `hashtag`, `post_id`, `user`, `hashtag_time`) VALUES -(13, '#nice', 69, 24, '1518854776646'), -(14, '#travel', 69, 24, '1518854776646'), -(16, '#travel', 71, 24, '1518857913750'), -(43, '#checkout', 88, 24, '1524677077506'), -(53, '#checkout', 89, 24, '1526670596558'), -(54, '#dd', 89, 24, '1526670596840'), -(55, '#fgf', 89, 24, '1526670597020'); - --- -------------------------------------------------------- - --- --- Table structure for table `likes` --- - -CREATE TABLE `likes` ( - `like_id` int(11) NOT NULL, - `post_id` int(11) NOT NULL, - `OWNER_like_by` int(11) NOT NULL, - `like_time` varchar(100) NOT NULL, - FOREIGN KEY (`OWNER_like_by`) REFERENCES users(id), - FOREIGN KEY (`post_id`) REFERENCES posts(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `likes` --- - -INSERT INTO `likes` (`like_id`, `post_id`, `like_by`, `like_time`) VALUES -(31, 22, 12, '1516523221375'), -(33, 24, 13, '1516523819069'), -(34, 23, 11, '1516524845235'), -(35, 32, 10, '1516524986159'), -(36, 34, 16, '1516525136147'), -(37, 35, 17, '1516525294230'), -(38, 36, 18, '1516525560721'), -(39, 41, 20, '1516527811400'), -(42, 43, 18, '1516528068337'), -(57, 43, 23, '1518016342615'), -(58, 40, 24, '1518016509189'), -(59, 39, 24, '1518016512324'), -(63, 61, 27, '1518018364468'), -(64, 63, 30, '1518510087356'), -(65, 57, 24, '1518515315123'), -(67, 89, 28, '1524245733030'), -(69, 89, 18, '1525862381809'), -(71, 69, 24, '1526210612292'), -(75, 89, 24, '1526663921539'); - --- -------------------------------------------------------- - --- --- Table structure for table `messages` --- - -CREATE TABLE `messages` ( - `message_id` int(11) NOT NULL, - `con_id` int(11) NOT NULL, - `mssg_by` int(11) NOT NULL, - `mssg_to` int(11) NOT NULL, - `message` longtext COLLATE utf8mb4_bin NOT NULL, - `type` enum('text','image','sticker') COLLATE utf8mb4_bin NOT NULL, - `status` enum('read','unread') COLLATE utf8mb4_bin NOT NULL DEFAULT 'unread', - `message_time` varchar(100) COLLATE utf8mb4_bin NOT NULL, - FOREIGN KEY (`OWNER_mssg_by`) REFERENCES users(id), - FOREIGN KEY (`OWNER_mssg_to`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; - --- --- Dumping data for table `messages` --- - -INSERT INTO `messages` (`message_id`, `con_id`, `mssg_by`, `mssg_to`, `message`, `type`, `status`, `message_time`) VALUES -(77, 25, 24, 27, 'hello', 'text', 'read', '1518973001479'), -(78, 24, 7, 24, 'eo', 'text', 'read', '1518973051916'), -(79, 25, 24, 27, '@takkar', 'text', 'read', '1519028471421'), -(93, 29, 28, 24, 'instagram_message_1525091176544.jpg', 'sticker', 'read', '1525091176544'), -(94, 29, 24, 28, 'kjkjk', 'text', 'unread', '1525809227238'), -(95, 29, 24, 28, 'kjkjk', 'text', 'unread', '1525809483966'), -(96, 39, 24, 18, 'mnm', 'text', 'read', '1525809590186'), -(99, 29, 24, 28, 'instagram_message_1525809886884.jpg', 'sticker', 'unread', '1525809886884'), -(100, 29, 24, 28, 'mnmnmnm', 'text', 'unread', '1525858483641'), -(101, 39, 24, 18, 'kjkj', 'text', 'unread', '1526481006905'), -(102, 29, 24, 28, 'instagram_message_1528278864884.jpg', 'image', 'unread', '1528278864884'); - --- -------------------------------------------------------- - --- --- Table structure for table `notifications` --- - -CREATE TABLE `notifications` ( - `notify_id` int(11) NOT NULL, - `notify_by` int(11) NOT NULL, - `OWNER_notify_to` int(11) NOT NULL, - `post_id` int(11) NOT NULL, - `group_id` int(11) NOT NULL, - `type` enum('follow','tag','like','share','shared_your_post','comment','favourites','recommend','add_grp_member','invite','change_admin','new_con','mention_post','mention_comment') NOT NULL, - `user` int(11) NOT NULL, - `notify_time` varchar(100) NOT NULL, - `status` enum('read','unread') NOT NULL DEFAULT 'unread', - FOREIGN KEY (`post_id`) REFERENCES posts(id), - FOREIGN KEY (`group_id`) REFERENCES groups(id), - FOREIGN KEY (`notify_by`) REFERENCES users(id), - FOREIGN KEY (`OWNER_notify_to`) REFERENCES users(id), - FOREIGN KEY (`user`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `notifications` --- - -INSERT INTO `notifications` (`notify_id`, `notify_by`, `notify_to`, `post_id`, `group_id`, `type`, `user`, `notify_time`, `status`) VALUES -(286, 7, 10, 0, 0, 'follow', 0, '1516633623492', 'read'), -(343, 24, 19, 0, 0, 'follow', 0, '1518016486336', 'unread'), -(344, 24, 8, 0, 0, 'follow', 0, '1518016489912', 'unread'), -(345, 24, 19, 40, 0, 'like', 0, '1518016509257', 'unread'), -(346, 24, 19, 39, 0, 'like', 0, '1518016512530', 'unread'), -(353, 24, 8, 0, 11, 'add_grp_member', 0, '1518016765339', 'unread'), -(368, 24, 29, 0, 0, 'follow', 0, '1518342254957', 'unread'), -(382, 24, 7, 88, 0, 'mention_post', 0, '1518945386480', 'read'), -(392, 24, 7, 89, 0, 'share', 0, '1518972830237', 'read'), -(394, 24, 7, 88, 0, 'mention_comment', 0, '1518972932790', 'read'), -(400, 7, 8, 0, 12, 'add_grp_member', 0, '1518973109986', 'unread'), -(402, 24, 20, 0, 0, 'favourites', 0, '1520682122270', 'unread'), -(403, 24, 12, 0, 0, 'favourites', 0, '1520682142190', 'unread'), -(404, 24, 10, 0, 0, 'favourites', 0, '1520682146353', 'unread'), -(410, 30, 8, 0, 0, 'follow', 0, '1520705825470', 'unread'), -(412, 28, 10, 0, 0, 'follow', 0, '1520759245830', 'unread'), -(418, 24, 10, 0, 0, 'follow', 0, '1523373918324', 'unread'), -(429, 24, 28, 0, 0, 'new_con', 0, '1523477732516', 'read'), -(430, 24, 28, 0, 0, 'new_con', 0, '1523478354351', 'read'), -(431, 24, 28, 0, 0, 'new_con', 0, '1523480038393', 'read'), -(434, 24, 28, 61, 0, 'share', 0, '1524496868725', 'read'), -(436, 24, 28, 89, 0, 'share', 0, '1524496878537', 'read'), -(437, 24, 28, 88, 0, 'share', 0, '1524496883529', 'read'), -(439, 24, 28, 69, 0, 'share', 0, '1524496892542', 'read'), -(440, 24, 28, 43, 0, 'share', 0, '1524496908549', 'read'), -(443, 11, 28, 0, 0, 'follow', 0, '1524499144540', 'read'), -(444, 11, 10, 0, 0, 'follow', 0, '1524499148583', 'unread'), -(445, 11, 8, 0, 0, 'follow', 0, '1524499149973', 'unread'), -(446, 11, 29, 0, 0, 'follow', 0, '1524499155724', 'unread'), -(448, 11, 19, 0, 0, 'follow', 0, '1524499189604', 'unread'), -(449, 11, 12, 0, 0, 'follow', 0, '1524499272593', 'unread'), -(450, 11, 20, 0, 0, 'follow', 0, '1524499274479', 'unread'), -(451, 11, 13, 0, 0, 'follow', 0, '1524499275773', 'unread'), -(452, 11, 15, 0, 0, 'follow', 0, '1524499276963', 'unread'), -(453, 11, 30, 0, 0, 'follow', 0, '1524499278473', 'unread'), -(454, 24, 14, 0, 0, 'follow', 0, '1524502749953', 'unread'), -(455, 24, 14, 0, 0, 'favourites', 0, '1524503038903', 'unread'), -(456, 24, 29, 0, 0, 'new_con', 0, '1524504622584', 'unread'), -(497, 24, 12, 0, 0, 'follow', 0, '1524909984699', 'unread'), -(498, 24, 30, 0, 0, 'favourites', 0, '1524914191885', 'unread'), -(499, 24, 17, 0, 0, 'favourites', 0, '1524914212091', 'unread'), -(500, 24, 28, 0, 0, 'recommend', 20, '1524916352456', 'read'), -(501, 24, 10, 0, 0, 'recommend', 20, '1524916590677', 'unread'), -(502, 24, 28, 0, 11, 'invite', 0, '1525002881663', 'read'), -(503, 24, 28, 0, 0, 'recommend', 14, '1525003631635', 'read'), -(504, 24, 14, 0, 0, 'favourites', 0, '1525003730633', 'unread'), -(505, 28, 11, 0, 0, 'follow', 0, '1525006781296', 'unread'), -(506, 28, 11, 0, 0, 'follow', 0, '1525007005464', 'unread'), -(507, 28, 11, 0, 0, 'new_con', 0, '1525077963722', 'unread'), -(508, 28, 10, 0, 0, 'new_con', 0, '1525077978906', 'unread'), -(509, 28, 11, 0, 0, 'new_con', 0, '1525078033167', 'unread'), -(510, 28, 10, 0, 0, 'new_con', 0, '1525078047432', 'unread'), -(511, 28, 11, 0, 0, 'new_con', 0, '1525079204532', 'unread'), -(512, 28, 11, 0, 0, 'new_con', 0, '1525092718395', 'unread'), -(513, 24, 10, 0, 0, 'new_con', 0, '1525108766820', 'unread'), -(516, 24, 13, 0, 0, 'favourites', 0, '1525201599007', 'unread'), -(517, 24, 13, 0, 0, 'favourites', 0, '1525201635936', 'unread'), -(518, 24, 28, 0, 0, 'follow', 0, '1525274124046', 'read'), -(528, 24, 28, 0, 0, 'follow', 0, '1526210407245', 'read'), -(529, 24, 7, 0, 0, 'follow', 0, '1526210412148', 'unread'), -(530, 24, 29, 0, 0, 'follow', 0, '1526210416032', 'unread'), -(531, 24, 29, 0, 0, 'follow', 0, '1526210485494', 'unread'), -(532, 24, 28, 0, 0, 'follow', 0, '1526210510521', 'read'), -(533, 24, 18, 0, 0, 'follow', 0, '1526210869530', 'unread'), -(534, 24, 28, 0, 0, 'follow', 0, '1526211680381', 'read'), -(535, 24, 18, 0, 0, 'follow', 0, '1526211951179', 'unread'), -(536, 24, 28, 0, 0, 'follow', 0, '1526211958615', 'read'), -(537, 24, 15, 0, 0, 'follow', 0, '1526212078067', 'unread'), -(538, 24, 19, 0, 0, 'follow', 0, '1526212081924', 'unread'), -(540, 24, 11, 0, 0, 'follow', 0, '1526212268629', 'unread'), -(541, 24, 8, 0, 0, 'follow', 0, '1526212272635', 'unread'), -(542, 24, 13, 0, 0, 'follow', 0, '1526212282151', 'unread'), -(543, 24, 28, 0, 11, 'add_grp_member', 0, '1526212331248', 'read'), -(544, 24, 7, 0, 11, 'add_grp_member', 0, '1526212335123', 'unread'), -(545, 24, 14, 0, 0, 'follow', 0, '1526212349872', 'unread'), -(546, 24, 11, 0, 0, 'follow', 0, '1526212476055', 'unread'), -(547, 24, 10, 0, 0, 'follow', 0, '1526212485866', 'unread'), -(548, 24, 17, 0, 0, 'follow', 0, '1526212488118', 'unread'), -(549, 24, 16, 0, 0, 'follow', 0, '1526212489438', 'read'), -(550, 24, 12, 0, 0, 'follow', 0, '1526212619648', 'unread'), -(551, 24, 20, 0, 0, 'follow', 0, '1526212779672', 'unread'), -(552, 24, 20, 0, 0, 'follow', 0, '1526212889242', 'unread'), -(553, 24, 12, 0, 0, 'follow', 0, '1526212999593', 'unread'), -(554, 24, 10, 0, 0, 'new_con', 0, '1526235563358', 'unread'), -(555, 24, 16, 0, 0, 'follow', 0, '1526236905180', 'read'), -(567, 27, 28, 0, 0, 'follow', 0, '1526375870059', 'read'), -(568, 27, 28, 0, 0, 'follow', 0, '1526375875471', 'read'), -(569, 27, 18, 0, 0, 'follow', 0, '1526377413720', 'unread'), -(570, 27, 18, 0, 0, 'follow', 0, '1526384344929', 'unread'), -(571, 27, 16, 0, 0, 'follow', 0, '1526384890351', 'read'), -(572, 27, 10, 0, 0, 'follow', 0, '1526384912553', 'unread'), -(573, 24, 27, 0, 0, 'follow', 0, '1526406579336', 'unread'), -(574, 24, 27, 0, 0, 'follow', 0, '1526406708572', 'unread'), -(575, 24, 27, 0, 0, 'follow', 0, '1526406718860', 'unread'), -(576, 24, 27, 0, 0, 'follow', 0, '1526409349650', 'unread'), -(577, 24, 20, 0, 0, 'follow', 0, '1526409870998', 'unread'), -(578, 24, 17, 0, 0, 'follow', 0, '1526410525953', 'unread'), -(579, 24, 17, 0, 0, 'follow', 0, '1526410529295', 'unread'), -(580, 24, 13, 0, 0, 'follow', 0, '1526410971128', 'unread'), -(581, 24, 20, 0, 0, 'follow', 0, '1526411015595', 'unread'), -(582, 24, 10, 0, 0, 'follow', 0, '1526411089320', 'unread'), -(583, 24, 27, 0, 0, 'follow', 0, '1526411705500', 'unread'), -(584, 24, 28, 0, 0, 'follow', 0, '1526411720123', 'read'), -(585, 24, 27, 0, 0, 'follow', 0, '1526412929207', 'unread'), -(586, 24, 27, 0, 0, 'follow', 0, '1526413744730', 'unread'), -(587, 24, 13, 0, 0, 'follow', 0, '1526460822621', 'unread'), -(588, 24, 16, 0, 0, 'follow', 0, '1526460868489', 'read'), -(589, 24, 12, 0, 0, 'follow', 0, '1526460874775', 'unread'), -(590, 24, 27, 0, 0, 'follow', 0, '1526460940835', 'unread'), -(591, 24, 20, 0, 0, 'follow', 0, '1526460962757', 'unread'), -(592, 24, 17, 0, 0, 'follow', 0, '1526460976691', 'unread'), -(593, 24, 11, 0, 0, 'new_con', 0, '1526480355976', 'unread'), -(594, 24, 10, 0, 0, 'new_con', 0, '1526480886797', 'unread'), -(595, 24, 28, 0, 11, 'invite', 0, '1526490301695', 'read'), -(598, 24, 19, 0, 0, 'recommend', 13, '1526643564523', 'unread'), -(599, 24, 28, 89, 0, 'share', 0, '1526647033125', 'read'), -(600, 24, 10, 89, 0, 'share', 0, '1526660088955', 'unread'), -(620, 24, 28, 89, 0, 'share', 0, '1526745600076', 'read'), -(621, 24, 10, 89, 0, 'share', 0, '1526745635731', 'unread'), -(622, 24, 11, 89, 0, 'share', 0, '1526745636769', 'unread'), -(625, 24, 18, 43, 0, 'comment', 0, '1527447892770', 'unread'), -(626, 24, 18, 43, 0, 'comment', 0, '1527447929709', 'unread'), -(627, 7, 28, 0, 12, 'change_admin', 0, '1527942637960', 'read'), -(628, 28, 7, 0, 12, 'change_admin', 0, '1527942673969', 'unread'), -(629, 24, 16, 0, 0, 'follow', 0, '1528272513475', 'unread'), -(630, 24, 10, 0, 0, 'new_con', 0, '1528274472284', 'unread'), -(632, 28, 24, 0, 0, 'follow', 0, '1528534489731', 'read'); - --- -------------------------------------------------------- - --- --- Table structure for table `posts` --- - -CREATE TABLE `posts` ( - `post_id` int(11) NOT NULL, - `user` int(11) NOT NULL, - `description` mediumtext COLLATE utf8mb4_bin NOT NULL, - `imgSrc` mediumtext COLLATE utf8mb4_bin NOT NULL, - `filter` varchar(100) COLLATE utf8mb4_bin NOT NULL DEFAULT 'normal', - `location` mediumtext COLLATE utf8mb4_bin NOT NULL, - `type` enum('user','group') COLLATE utf8mb4_bin NOT NULL DEFAULT 'user', - `group_id` int(11) NOT NULL, - `post_time` varchar(100) COLLATE utf8mb4_bin NOT NULL, - FOREIGN KEY (`user`) REFERENCES users(id), - FOREIGN KEY (`group_id`) REFERENCES groups(id), - FOREIGN KEY (`post_id`) REFERENCES posts(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; - --- --- Dumping data for table `posts` --- - -INSERT INTO `posts` (`post_id`, `user`, `description`, `imgSrc`, `filter`, `location`, `type`, `group_id`, `post_time`) VALUES -(22, 12, '', 'instagram_1516522776339.jpg', 'filter-normal', 'A-301, 90 Feet Road, Dharavi, Mumbai, Maharashtra 400017, India', 'user', 0, '1516522776339'), -(23, 11, '', 'instagram_1516523468369.jpg', 'filter-normal', '', 'user', 0, '1516523468369'), -(24, 13, '@ghalib #travel', 'instagram_1516523813005.jpg', 'filter-normal', '', 'user', 0, '1516523813006'), -(25, 14, '', 'instagram_1516524010087.jpg', 'filter-normal', '', 'user', 0, '1516524010087'), -(26, 14, '', 'instagram_1516524031664.jpg', 'filter-normal', '', 'user', 0, '1516524031664'), -(27, 14, '', 'instagram_1516524056911.jpg', 'filter-normal', '', 'user', 0, '1516524056911'), -(28, 14, '', 'instagram_1516524098767.jpg', 'filter-normal', '', 'user', 0, '1516524098767'), -(29, 14, '', 'instagram_1516524133694.jpg', 'filter-normal', '', 'user', 0, '1516524133694'), -(30, 14, '', 'instagram_1516524190576.jpg', 'filter-normal', '', 'user', 0, '1516524190576'), -(31, 15, '', 'instagram_1516524753923.jpg', 'filter-normal', '', 'user', 0, '1516524753923'), -(32, 10, '', 'instagram_1516524981153.jpg', 'filter-normal', '', 'user', 0, '1516524981153'), -(33, 10, '', 'instagram_1516525040077.jpg', 'filter-normal', '', 'user', 0, '1516525040077'), -(34, 16, '', 'instagram_1516525129889.jpg', 'filter-normal', '', 'user', 0, '1516525129889'), -(35, 17, '', 'instagram_1516525289046.jpg', 'filter-normal', '', 'user', 0, '1516525289046'), -(36, 18, '', 'instagram_1516525555814.jpg', 'filter-normal', '', 'user', 0, '1516525555814'), -(37, 18, '', 'instagram_1516525648412.jpg', 'filter-normal', '', 'user', 0, '1516525648412'), -(38, 18, '', 'instagram_1516525703299.jpg', 'filter-normal', '', 'user', 0, '1516525703299'), -(39, 19, '', 'instagram_1516527391527.jpg', 'filter-normal', '', 'user', 0, '1516527391527'), -(40, 19, '', 'instagram_1516527403042.jpg', 'filter-normal', '', 'user', 0, '1516527403042'), -(41, 20, '', 'instagram_1516527804372.jpg', 'filter-normal', '', 'user', 0, '1516527804372'), -(43, 18, '', 'instagram_1516528062094.jpg', 'filter-normal', '', 'user', 0, '1516528062094'), -(57, 24, 'm', 'instagram_1518016704834.jpg', 'filter-normal', '', 'user', 0, '1518016704834'), -(61, 27, '', 'instagram_1518018358758.jpg', 'filter-normal', 'Progresive Building, 90 Feet Road, Dharavi, Mumbai, Maharashtra 400017, India', 'user', 0, '1518018358758'), -(63, 30, 'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm', 'instagram_1518510077635.jpg', 'filter-normal', '', 'user', 0, '1518510077635'), -(69, 24, 'That''s a #nice place to #travel', 'instagram_1518854775824.jpg', 'filter-normal', '', 'user', 0, '1518854775824'), -(71, 24, '#travel', 'instagram_1518857912246.jpg', 'filter-normal', '', 'group', 11, '1518857912246'), -(88, 24, 'Hello @ghalib @takkar #checkout', 'instagram_1518945386167.jpg', 'filter-normal', '', 'user', 0, '1518945386167'), -(89, 24, 'he @nobita, @doraemon #checkout, #dd #fgf', 'instagram_1518972814710.jpg', 'filter-ashby', 'A-301, 90 Feet Road, Dharavi, Mumbai, Maharashtra 400017, India', 'user', 0, '1518972814710'); - --- -------------------------------------------------------- - --- --- Table structure for table `post_tags` --- - -CREATE TABLE `post_tags` ( - `post_tag_id` int(11) NOT NULL, - `post_id` int(11) NOT NULL, - `OWNER_user` int(11) NOT NULL, - FOREIGN KEY (`OWNER_user`) REFERENCES users(id), - FOREIGN KEY (`post_id`) REFERENCES posts(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- - --- --- Table structure for table `profile_views` --- - -CREATE TABLE `profile_views` ( - `view_id` int(11) NOT NULL, - `OWNER_view_by` int(11) NOT NULL, - `view_to` int(11) NOT NULL, - `view_time` varchar(100) NOT NULL, - FOREIGN KEY (`OWNER_view_by`) REFERENCES users(id), - FOREIGN KEY (`view_to`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `profile_views` --- - -INSERT INTO `profile_views` (`view_id`, `view_by`, `view_to`, `view_time`) VALUES -(64, 7, 8, '1515919685209'), -(129, 8, 7, '1516289109364'), -(134, 11, 12, '1516524331307'), -(214, 17, 12, '1517245217599'), -(215, 30, 24, '1518454700846'), -(216, 30, 24, '1518455184176'), -(217, 30, 24, '1518455376510'), -(218, 30, 24, '1518455682363'), -(219, 30, 24, '1518455906011'), -(220, 30, 24, '1518456281600'), -(221, 30, 24, '1518456458857'), -(222, 30, 24, '1518456667371'), -(223, 30, 24, '1518456821996'), -(224, 30, 24, '1518509763525'), -(225, 30, 24, '1518512974289'), -(226, 24, 30, '1518513031554'), -(227, 24, 30, '1518513512507'), -(228, 24, 30, '1518513877073'), -(229, 24, 27, '1518513894932'), -(230, 24, 30, '1518514177877'), -(231, 24, 27, '1518514384042'), -(232, 24, 27, '1518514537230'), -(233, 24, 28, '1518514630544'), -(234, 24, 30, '1518514644447'), -(236, 24, 13, '1518708220016'), -(237, 24, 7, '1518941917187'), -(238, 7, 24, '1518973058828'), -(239, 7, 11, '1518973144401'), -(240, 11, 7, '1518973172978'), -(241, 30, 24, '1519060720216'), -(242, 30, 24, '1519061010274'), -(243, 24, 10, '1519982984548'), -(244, 24, 28, '1520109154617'), -(245, 24, 28, '1520263507826'), -(246, 24, 20, '1520682114789'), -(247, 24, 12, '1520682139254'), -(248, 24, 10, '1520682143580'), -(249, 24, 10, '1520682331646'), -(250, 24, 15, '1520682346748'), -(251, 24, 10, '1520682930864'), -(252, 24, 10, '1520683103210'), -(253, 24, 10, '1520683553605'), -(254, 24, 10, '1520683705677'), -(255, 24, 10, '1520683984036'), -(256, 28, 24, '1520684165242'), -(257, 28, 24, '1520684344535'), -(258, 24, 13, '1520700614119'), -(259, 30, 24, '1520704934832'), -(260, 30, 24, '1520705422202'), -(261, 30, 24, '1520705806963'), -(262, 30, 8, '1520705823148'), -(263, 24, 30, '1520705896659'), -(264, 24, 30, '1520706072262'), -(265, 24, 15, '1520706091479'), -(266, 24, 15, '1520707371087'), -(268, 24, 27, '1520757269439'), -(269, 28, 24, '1520757395377'), -(270, 28, 24, '1520758042798'), -(271, 28, 24, '1520758521053'), -(272, 28, 7, '1520759045954'), -(273, 28, 24, '1520759061987'), -(274, 28, 24, '1520759240672'), -(275, 28, 24, '1520759394313'), -(276, 28, 11, '1520760182860'), -(277, 28, 24, '1520760231609'), -(278, 28, 24, '1520760413780'), -(279, 28, 24, '1520760649662'), -(280, 28, 24, '1520763416452'), -(281, 28, 24, '1520763580899'), -(282, 24, 28, '1520763632558'), -(283, 24, 10, '1520763822416'), -(284, 24, 7, '1520763829919'), -(285, 24, 7, '1520764803286'), -(286, 24, 27, '1520768683384'), -(287, 24, 30, '1520768744688'), -(288, 28, 24, '1520768767061'), -(289, 28, 24, '1520846088071'), -(290, 24, 27, '1521657597271'), -(291, 24, 10, '1523203299143'), -(292, 24, 27, '1523203694321'), -(293, 24, 7, '1523285826149'), -(294, 7, 24, '1523285900611'), -(295, 7, 24, '1523286823165'), -(296, 7, 19, '1523286832523'), -(297, 7, 24, '1523287444850'), -(298, 7, 24, '1523287634357'), -(299, 24, 27, '1523363013276'), -(300, 28, 18, '1523433079935'), -(301, 28, 7, '1523433092131'), -(302, 24, 27, '1523433939315'), -(303, 27, 18, '1523434955932'), -(304, 27, 19, '1523435526472'), -(305, 27, 19, '1523435900715'), -(306, 27, 19, '1523436068720'), -(307, 27, 19, '1523436353096'), -(308, 27, 19, '1523436583990'), -(309, 27, 24, '1523470227327'), -(310, 28, 24, '1523478229597'), -(311, 24, 28, '1523478260076'), -(312, 24, 28, '1523480335616'), -(313, 24, 28, '1523480518791'), -(314, 24, 28, '1523480673399'), -(315, 24, 17, '1523480743091'), -(316, 24, 28, '1523480840164'), -(317, 24, 27, '1523481052883'), -(318, 24, 28, '1523481061016'), -(319, 24, 28, '1523520163346'), -(320, 24, 11, '1523520195794'), -(321, 24, 11, '1523522058173'), -(322, 24, 11, '1523522377373'), -(323, 24, 13, '1523523906067'), -(324, 24, 7, '1523523919090'), -(325, 24, 28, '1523809217007'), -(326, 24, 28, '1523809425412'), -(327, 24, 28, '1523809839903'), -(328, 24, 28, '1523883824181'), -(329, 24, 28, '1523883997997'), -(330, 24, 28, '1523884149792'), -(331, 24, 28, '1524303854984'), -(332, 24, 28, '1524304969884'), -(333, 24, 14, '1524491643913'), -(335, 24, 27, '1524496338680'), -(336, 24, 27, '1524496546326'), -(337, 24, 27, '1524496712202'), -(338, 28, 24, '1524497266922'), -(339, 28, 24, '1524497892732'), -(340, 11, 24, '1524499558576'), -(341, 24, 7, '1524500388417'), -(342, 24, 15, '1524502315748'), -(343, 24, 30, '1524502372291'), -(344, 24, 14, '1524502506939'), -(345, 24, 14, '1524502705551'), -(346, 24, 14, '1524502927995'), -(347, 7, 24, '1524568244340'), -(348, 24, 11, '1524899921633'), -(349, 24, 11, '1524900489517'), -(350, 24, 11, '1524901137499'), -(351, 24, 12, '1524909976673'), -(352, 24, 12, '1524910128420'), -(353, 24, 17, '1524913915710'), -(354, 24, 12, '1524914061858'), -(355, 24, 30, '1524914094586'), -(356, 24, 17, '1524914208025'), -(357, 24, 27, '1524914399568'), -(358, 24, 27, '1524914564964'), -(359, 24, 20, '1524914623480'), -(360, 24, 20, '1524914842473'), -(361, 24, 20, '1524915176492'), -(362, 24, 20, '1524915390599'), -(363, 24, 20, '1524915786612'), -(364, 24, 20, '1524916288722'), -(365, 24, 20, '1524916585292'), -(366, 24, 20, '1524916781821'), -(367, 24, 27, '1524989780774'), -(368, 24, 27, '1524990128560'), -(369, 24, 27, '1524990309705'), -(370, 24, 27, '1524990991554'), -(371, 24, 27, '1524991143125'), -(372, 24, 15, '1524991388179'), -(373, 24, 14, '1525003436336'), -(374, 24, 14, '1525003619784'), -(375, 28, 14, '1525006958059'), -(376, 24, 11, '1525098424953'), -(377, 24, 20, '1525198394818'), -(378, 24, 20, '1525198667641'), -(379, 24, 20, '1525199870782'), -(380, 24, 20, '1525200459538'), -(381, 24, 20, '1525200651248'), -(382, 24, 20, '1525200913564'), -(383, 24, 13, '1525201560603'), -(384, 24, 13, '1525202237368'), -(385, 24, 13, '1525202781901'), -(386, 24, 18, '1525274105388'), -(387, 24, 28, '1525274116884'), -(388, 24, 11, '1525279447778'), -(389, 24, 12, '1525283796077'), -(390, 24, 11, '1525283813290'), -(391, 24, 30, '1525283953105'), -(392, 24, 11, '1525284047942'), -(393, 24, 11, '1525336894682'), -(394, 24, 11, '1525337151771'), -(395, 24, 28, '1525860845202'), -(396, 18, 11, '1525860933493'), -(397, 18, 24, '1525860950434'), -(398, 18, 24, '1525861180691'), -(399, 18, 24, '1525862373277'), -(400, 18, 24, '1525862831385'), -(401, 18, 28, '1525863010973'), -(402, 18, 28, '1525863899563'), -(403, 18, 24, '1525864471645'), -(404, 18, 24, '1525866450462'), -(405, 28, 24, '1525949970805'), -(406, 24, 12, '1526114828063'), -(407, 24, 12, '1526114993065'), -(408, 24, 12, '1526115186443'), -(409, 24, 30, '1526210857205'), -(410, 24, 18, '1526210865704'), -(411, 24, 20, '1526222263078'), -(412, 24, 30, '1526223867777'), -(413, 24, 7, '1526223974494'), -(414, 24, 28, '1526223981432'), -(415, 24, 20, '1526231720648'), -(416, 24, 13, '1526232072287'), -(417, 24, 27, '1526235235069'), -(418, 24, 27, '1526235544756'), -(419, 24, 20, '1526235680659'), -(420, 24, 20, '1526236024136'), -(421, 24, 16, '1526236902708'), -(422, 28, 24, '1526286781681'), -(423, 28, 24, '1526286937276'), -(424, 24, 30, '1526303814130'), -(425, 24, 11, '1526304284597'), -(426, 24, 11, '1526304912977'), -(427, 24, 11, '1526305231105'), -(428, 27, 24, '1526375087267'), -(429, 27, 24, '1526375863409'), -(430, 27, 24, '1526377290451'), -(431, 27, 30, '1526384883219'), -(432, 27, 16, '1526384887256'), -(433, 27, 24, '1526384908369'), -(434, 27, 11, '1526384930921'), -(435, 27, 24, '1526385357731'), -(436, 24, 10, '1526411092405'), -(437, 24, 13, '1526460860034'), -(438, 24, 27, '1526460885177'), -(439, 24, 20, '1526460964700'), -(440, 24, 17, '1526460972573'), -(441, 24, 15, '1526461471871'), -(442, 24, 15, '1526461720126'), -(443, 24, 15, '1526461920815'), -(444, 24, 15, '1526462073482'), -(445, 24, 12, '1526495883875'), -(446, 24, 12, '1526497596082'), -(447, 24, 18, '1526576921892'), -(448, 24, 18, '1526577081822'), -(449, 24, 13, '1526643511822'), -(450, 24, 20, '1526643577607'), -(451, 24, 18, '1526646232568'), -(453, 16, 24, '1526663423808'), -(454, 24, 24, '1526983253270'), -(455, 24, 24, '1526983452233'), -(456, 24, 14, '1527157380114'), -(457, 24, 28, '1527194650295'), -(458, 24, 7, '1527239739482'), -(459, 24, 7, '1527339792721'), -(460, 24, 7, '1527349518644'), -(461, 24, 18, '1527621458025'), -(462, 24, 18, '1527680012932'), -(463, 24, 18, '1527682269056'), -(464, 28, 24, '1528222627685'), -(465, 28, 10, '1528222708564'), -(466, 24, 16, '1528272511064'), -(467, 28, 11, '1528534481649'), -(468, 28, 24, '1528534487195'), -(469, 24, 18, '1528534513630'); - --- -------------------------------------------------------- - --- --- Table structure for table `recommendations` --- - -CREATE TABLE `recommendations` ( - `OWNER_recommend_id` int(11) NOT NULL, - `OWNER_recommend_by` int(11) NOT NULL, - `recommend_to` int(11) NOT NULL, - `recommend_of` int(11) NOT NULL, - `recommend_time` varchar(100) NOT NULL, - FOREIGN KEY (`OWNER_recommend_by`) REFERENCES users(id), - FOREIGN KEY (`OWNER_recommend_to`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `recommendations` --- - -INSERT INTO `recommendations` (`recommend_id`, `recommend_by`, `recommend_to`, `recommend_of`, `recommend_time`) VALUES -(1, 24, 18, 30, '1518513518719'), -(2, 24, 27, 30, '1518513536449'), -(3, 24, 28, 20, '1524916352254'), -(4, 24, 10, 20, '1524916590540'), -(5, 24, 28, 14, '1525003631546'), -(6, 24, 18, 28, '1525860865598'), -(7, 24, 19, 13, '1526643564409'); - --- -------------------------------------------------------- - --- --- Table structure for table `shares` --- - -CREATE TABLE `shares` ( - `share_id` int(11) NOT NULL, - `OWNER_share_by` int(11) NOT NULL, - `share_to` int(11) NOT NULL, - `post_id` int(11) NOT NULL, - `share_time` varchar(100) NOT NULL, - FOREIGN KEY (`OWNER_shard_by`) REFERENCES users(id), - FOREIGN KEY (`share_to`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `shares` --- - -INSERT INTO `shares` (`share_id`, `share_by`, `share_to`, `post_id`, `share_time`) VALUES -(94, 27, 24, 61, '1518018368656'), -(98, 24, 28, 61, '1524496868576'), -(100, 24, 28, 88, '1524496883422'), -(103, 24, 28, 43, '1524496908401'), -(105, 24, 27, 61, '1524739767695'), -(112, 24, 28, 89, '1526745599923'), -(113, 24, 10, 89, '1526745635584'), -(114, 24, 11, 89, '1526745636581'); - --- -------------------------------------------------------- - --- --- Table structure for table `tags` --- - -CREATE TABLE `tags` ( - `tag_id` int(11) NOT NULL, - `user` int(11) NOT NULL, - `tag` varchar(255) NOT NULL, - FOREIGN KEY (`user`) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Dumping data for table `tags` --- - -INSERT INTO `tags` (`tag_id`, `user`, `tag`) VALUES -(1, 29, 'apple'), -(33, 24, 'bb'); - --- -------------------------------------------------------- - --- --- Table structure for table `users` --- - -CREATE TABLE `users` ( - `id` int(11) NOT NULL, - `username` varchar(32) COLLATE utf8mb4_bin NOT NULL, - `firstname` varchar(32) COLLATE utf8mb4_bin NOT NULL, - `surname` varchar(32) COLLATE utf8mb4_bin NOT NULL, - `PII_email` varchar(255) COLLATE utf8mb4_bin NOT NULL, - `password` varchar(255) COLLATE utf8mb4_bin NOT NULL, - `bio` varchar(1000) COLLATE utf8mb4_bin NOT NULL, - `joined` varchar(100) COLLATE utf8mb4_bin NOT NULL, - `email_verified` enum('yes','no') COLLATE utf8mb4_bin NOT NULL DEFAULT 'no', - `account_type` enum('public','private') COLLATE utf8mb4_bin NOT NULL DEFAULT 'public', - `instagram` varchar(500) COLLATE utf8mb4_bin NOT NULL, - `twitter` varchar(500) COLLATE utf8mb4_bin NOT NULL, - `facebook` varchar(500) COLLATE utf8mb4_bin NOT NULL, - `github` varchar(500) COLLATE utf8mb4_bin NOT NULL, - `website` varchar(500) COLLATE utf8mb4_bin NOT NULL, - `phone` varchar(20) COLLATE utf8mb4_bin NOT NULL, - `isOnline` enum('yes','no') COLLATE utf8mb4_bin NOT NULL DEFAULT 'no', - `lastOnline` varchar(100) COLLATE utf8mb4_bin NOT NULL, -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; - --- --- Dumping data for table `users` --- - -INSERT INTO `users` (`id`, `username`, `firstname`, `surname`, `email`, `password`, `bio`, `joined`, `email_verified`, `account_type`, `instagram`, `twitter`, `facebook`, `github`, `website`, `phone`, `isOnline`, `lastOnline`) VALUES -(7, 'ghalib', 'Mirza', 'Ghalib', 'ghalib@gmail.com', '$2a$10$E3ZgkSwaa6rUopG1CBUm8OoCMKVqzSwv79bfuUrICV0eLOqTlqR/m', '', '1514718748562', 'yes', 'private', '', '', '', '', '', '', 'no', '1527942645296'), -(8, 'coldplay', 'cold', 'play', 'coldplay@gmail.com', '$2a$10$zVPMDJKlOY00UnSlrLEUfuaeTwXkZ.VD4ixp.q1x2RjX/LbezoqPO', '', '1515918435853', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(10, 'noddy', 'your', 'noddy', 'noddy@gmail.com', '$2a$10$/FlxKj904j7TnMo.9gJJTe5cwFakoJc4/w9kba3LeAdP0hTWGCzCG', '', '1516454412744', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(11, 'nobita', 'nobita', 'nobi', 'nobita@gmail.com', '$2a$10$nzMI2G054StCufuo4fzkEOWhpwUWKqZwV67jbPqaqqSNDNnF5led2', '', '1516522466189', 'no', 'public', '', '', '', '', '', '', 'no', '1524499561897'), -(12, 'pikachu', 'your', 'pikachu', 'pikachu@gmail.com', '$2a$10$j/buNE/iwJquKzzyBsOhLe4dEVVXKs56KTet8E4arAjcjsQ87BZt2', '', '1516522598741', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(13, 'iamsrk', 'Shahrukh', 'Khan', 'iamsrk@gmail.com', '$2a$10$Xn99377.3Ns8.QoneTP4qeMuERyvNR2Ki86eRjpmHCsj01xvFoFIq', '', '1516523593107', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(14, 'kinkade', 'Thomas', 'Kinkade', 'kinkade@gmail.com', '$2a$10$IvK3CBxFh/dnkWZtRMh9k.S2/WIdQbd6adF78Bb16.G.62nrSUgcG', '', '1516523852488', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(15, 'suniyo', 'suniyo', 'honekawa', 'suniyo@gmail.com', '$2a$10$60TUnK2JiH8RoloKA/IdB.ZG07o.bc8FpHqu9Euc2kEXc28PslceS', '', '1516524667640', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(16, 'zayn', 'Zayn', 'Malik', 'zayn@gmail.com', '$2a$10$ktjq/vo/8nBxlOnixyTpQuN6gyXc5vN4.rslSVRt4eM6vhq7ftaxS', '', '1516525072573', 'no', 'private', '', '', '', '', '', '', 'yes', '1526663478084'), -(17, 'nfak', 'Nusratfateh', 'Alikhan', 'nfak@gmail.com', '$2a$10$TAzl3pUYIs/HRb8LPhvZdOclk/TSfnmicUVgHEGyUwnUxm7j7Z.Ie', '', '1516525201164', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(18, 'ragnar', 'Ragnar', 'Lothbrok', 'ragnar@gmail.com', '$2a$10$M7lx4wF.PUhAjSJVxb7bW.nk2G6zxeCjhXBnKTyFz3JNq8NQbQQ8m', '', '1516525343645', 'no', 'public', '', '', '', '', '', '', 'no', '1525866681046'), -(19, 'jonsnow', 'jon_', 'snow', 'jonsnow@gmail.com', '$2a$10$9Nb4hFjgg.MKKLLTeXMuWehralT21UCoeWsPq3./VWMkUnu19JpzS', '', '1516527326858', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(20, 'gian', 'Takeshi', 'Gauda', 'gian@gmail.com', '$2a$10$K3ijpio/4HIOKJhQ5yq3DOQ4IW5Oee4O5hwogEQtB/FBuNJRvd9T2', '', '1516527534985', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(24, 'takkar', 'iam_', 'takkar', 'takkar@gmail.com', '$2a$10$R/iWFCwEDgmOvg7mCB3wreerTC0hRuYyZflDN2Gyr3YV/ppMMNgJu', 'Hello #world', '1518016437193', 'no', 'private', '', '', 'm', '', '', 'gg', 'yes', '1528490530271'), -(27, 'taylor_swift', 'taylor', 'swift', 'taylor_swift@gmail.com', '$2a$10$rnQRsp0iWCdV8b6AD24mJ.7rL5XQ31ejULlOQMVkBpjxD7RlRxqKK', '', '1518018283428', 'no', 'public', '', '', '', '', '', '', 'no', '1526387270500'), -(28, 'selena', 'selena', 'gomez', 'selenagomez@gmail.com', '$2a$10$.ifdYlKQdt/acrXtn09NLuENJylSfZIJq2U4tqzZNqeRWaUG0nnQq', '', '1518018409165', 'no', 'public', 'mmmm', '', '', '', '', '', 'no', '1528534503389'), -(29, 'steve_jobs', 'steve', 'jobs', 'steve_jobs@gmail.com', '$2a$10$B05HNF3/pnK.8fU7kCJHpuaU5LpVxwao9Wmkn3Md2sAPc5GINiU6O', '', '1518018498672', 'no', 'public', '', '', '', '', '', '', 'no', ''), -(30, 'doraemon', 'iam_', 'doraemon', 'doraemon@gmail.com', '$2a$10$OjZg/mosNPOT297skkotUetzYL7mIEFDVxVPP2lsBAv4F0LSyK18m', '', '1518454660501', 'no', 'public', '', '', '', '', '', '', 'no', '1525801713580'); - --- --- Indexes for dumped tables --- - --- --- Indexes for table `blocks` --- -ALTER TABLE `blocks` - ADD PRIMARY KEY (`block_id`); - --- --- Indexes for table `bookmarks` --- -ALTER TABLE `bookmarks` - ADD PRIMARY KEY (`bkmrk_id`); - --- --- Indexes for table `comments` --- -ALTER TABLE `comments` - ADD PRIMARY KEY (`comment_id`); - --- --- Indexes for table `conversations` --- -ALTER TABLE `conversations` - ADD PRIMARY KEY (`con_id`); - --- --- Indexes for table `favourites` --- -ALTER TABLE `favourites` - ADD PRIMARY KEY (`fav_id`); - --- --- Indexes for table `follow_system` --- -ALTER TABLE `follow_system` - ADD PRIMARY KEY (`follow_id`); - --- --- Indexes for table `groups` --- -ALTER TABLE `groups` - ADD PRIMARY KEY (`group_id`); - --- --- Indexes for table `group_members` --- -ALTER TABLE `group_members` - ADD PRIMARY KEY (`grp_member_id`); - --- --- Indexes for table `hashtags` --- -ALTER TABLE `hashtags` - ADD PRIMARY KEY (`hashtag_id`); - --- --- Indexes for table `likes` --- -ALTER TABLE `likes` - ADD PRIMARY KEY (`like_id`); - --- --- Indexes for table `messages` --- -ALTER TABLE `messages` - ADD PRIMARY KEY (`message_id`); - --- --- Indexes for table `notifications` --- -ALTER TABLE `notifications` - ADD PRIMARY KEY (`notify_id`); - --- --- Indexes for table `posts` --- -ALTER TABLE `posts` - ADD PRIMARY KEY (`post_id`); - --- --- Indexes for table `post_tags` --- -ALTER TABLE `post_tags` - ADD PRIMARY KEY (`post_tag_id`); - --- --- Indexes for table `profile_views` --- -ALTER TABLE `profile_views` - ADD PRIMARY KEY (`view_id`); - --- --- Indexes for table `recommendations` --- -ALTER TABLE `recommendations` - ADD PRIMARY KEY (`recommend_id`); - --- --- Indexes for table `shares` --- -ALTER TABLE `shares` - ADD PRIMARY KEY (`share_id`); - --- --- Indexes for table `tags` --- -ALTER TABLE `tags` - ADD PRIMARY KEY (`tag_id`); - --- --- Indexes for table `users` --- -ALTER TABLE `users` - ADD PRIMARY KEY (`id`); - --- --- AUTO_INCREMENT for dumped tables --- - --- --- AUTO_INCREMENT for table `blocks` --- -ALTER TABLE `blocks` - MODIFY `block_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; --- --- AUTO_INCREMENT for table `bookmarks` --- -ALTER TABLE `bookmarks` - MODIFY `bkmrk_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; --- --- AUTO_INCREMENT for table `comments` --- -ALTER TABLE `comments` - MODIFY `comment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=105; --- --- AUTO_INCREMENT for table `conversations` --- -ALTER TABLE `conversations` - MODIFY `con_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40; --- --- AUTO_INCREMENT for table `favourites` --- -ALTER TABLE `favourites` - MODIFY `fav_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; --- --- AUTO_INCREMENT for table `follow_system` --- -ALTER TABLE `follow_system` - MODIFY `follow_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=304; --- --- AUTO_INCREMENT for table `groups` --- -ALTER TABLE `groups` - MODIFY `group_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; --- --- AUTO_INCREMENT for table `group_members` --- -ALTER TABLE `group_members` - MODIFY `grp_member_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59; --- --- AUTO_INCREMENT for table `hashtags` --- -ALTER TABLE `hashtags` - MODIFY `hashtag_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=56; --- --- AUTO_INCREMENT for table `likes` --- -ALTER TABLE `likes` - MODIFY `like_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=76; --- --- AUTO_INCREMENT for table `messages` --- -ALTER TABLE `messages` - MODIFY `message_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=103; --- --- AUTO_INCREMENT for table `notifications` --- -ALTER TABLE `notifications` - MODIFY `notify_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=633; --- --- AUTO_INCREMENT for table `posts` --- -ALTER TABLE `posts` - MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=91; --- --- AUTO_INCREMENT for table `post_tags` --- -ALTER TABLE `post_tags` - MODIFY `post_tag_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; --- --- AUTO_INCREMENT for table `profile_views` --- -ALTER TABLE `profile_views` - MODIFY `view_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=470; --- --- AUTO_INCREMENT for table `recommendations` --- -ALTER TABLE `recommendations` - MODIFY `recommend_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; --- --- AUTO_INCREMENT for table `shares` --- -ALTER TABLE `shares` - MODIFY `share_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=115; --- --- AUTO_INCREMENT for table `tags` --- -ALTER TABLE `tags` - MODIFY `tag_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; --- --- AUTO_INCREMENT for table `users` --- -ALTER TABLE `users` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/experiments/schema-annot/PrestaShop-original.sql b/experiments/schema-annot/original/PrestaShop-original.sql similarity index 100% rename from experiments/schema-annot/PrestaShop-original.sql rename to experiments/schema-annot/original/PrestaShop-original.sql diff --git a/experiments/schema-annot/commento-original.sql b/experiments/schema-annot/original/commento-original.sql similarity index 100% rename from experiments/schema-annot/commento-original.sql rename to experiments/schema-annot/original/commento-original.sql diff --git a/experiments/schema-annot/ghchat-original.sql b/experiments/schema-annot/original/ghchat-original.sql similarity index 100% rename from experiments/schema-annot/ghchat-original.sql rename to experiments/schema-annot/original/ghchat-original.sql diff --git a/experiments/schema-annot/hotcrp-original.sql b/experiments/schema-annot/original/hotcrp-original.sql similarity index 100% rename from experiments/schema-annot/hotcrp-original.sql rename to experiments/schema-annot/original/hotcrp-original.sql diff --git a/experiments/schema-annot/instagram.sql b/experiments/schema-annot/original/instagram_1-original.sql similarity index 100% rename from experiments/schema-annot/instagram.sql rename to experiments/schema-annot/original/instagram_1-original.sql diff --git a/experiments/schema-annot/instagram_2-original.sql b/experiments/schema-annot/original/instagram_2-original.sql similarity index 100% rename from experiments/schema-annot/instagram_2-original.sql rename to experiments/schema-annot/original/instagram_2-original.sql diff --git a/experiments/schema-annot/mouthful.go b/experiments/schema-annot/original/mouthful.go similarity index 100% rename from experiments/schema-annot/mouthful.go rename to experiments/schema-annot/original/mouthful.go diff --git a/experiments/schema-annot/opencart.php b/experiments/schema-annot/original/opencart.php similarity index 100% rename from experiments/schema-annot/opencart.php rename to experiments/schema-annot/original/opencart.php diff --git a/experiments/schema-annot/ownCloud.sql b/experiments/schema-annot/original/ownCloud.sql similarity index 100% rename from experiments/schema-annot/ownCloud.sql rename to experiments/schema-annot/original/ownCloud.sql diff --git a/experiments/schema-annot/schnack-original.sql b/experiments/schema-annot/original/schnack-original.sql similarity index 100% rename from experiments/schema-annot/schnack-original.sql rename to experiments/schema-annot/original/schnack-original.sql diff --git a/experiments/schema-annot/socify-original.rb b/experiments/schema-annot/original/socify-original.rb similarity index 100% rename from experiments/schema-annot/socify-original.rb rename to experiments/schema-annot/original/socify-original.rb diff --git a/experiments/schema-annot/socify.rb b/experiments/schema-annot/original/socify.rb similarity index 100% rename from experiments/schema-annot/socify.rb rename to experiments/schema-annot/original/socify.rb diff --git a/experiments/schema-annot/schnack.sql b/experiments/schema-annot/schnack.sql deleted file mode 100644 index 7fcc63da..00000000 --- a/experiments/schema-annot/schnack.sql +++ /dev/null @@ -1,131 +0,0 @@ --- Up -CREATE TABLE comment ( - id INTEGER PRIMARY KEY NOT NULL, - user_id NOT NULL, - slug CHAR(128) NOT NULL, - created_at TEXT NOT NULL, - comment CHAR(4000) NOT NULL, - rejected BOOLEAN, - approved BOOLEAN, - FOREIGN KEY (user_id) REFERENCES user(id) -); - -CREATE TABLE user ( - id INTEGER PRIMARY KEY NOT NULL, - PII_name CHAR(128), - display_name CHAR(128), - provider CHAR(128), - provider_id CHAR(128), - created_at TEXT NOT NULL, - blocked BOOLEAN, - trusted BOOLEAN -); - --- Down -DROP TABLE comment; -DROP TABLE user; - - --- Up -CREATE TABLE setting ( - name CHAR(128) PRIMARY KEY NOT NULL, - active BOOLEAN NOT NULL -); - -INSERT INTO setting (name, active) VALUES ('notification', 1); - -CREATE TABLE subscription ( - endpoint CHAR(600) PRIMARY KEY NOT NULL, - publicKey CHAR(4096) NOT NULL, - auth CHAR(600) NOT NULL -); - --- Down -DROP TABLE setting; -DROP TABLE subscription; - - --- Up -ALTER TABLE comment ADD COLUMN reply_to INTEGER; - --- Down -ALTER TABLE comment RENAME TO comment_old; -CREATE TABLE comment ( - id INTEGER PRIMARY KEY NOT NULL, - user_id NOT NULL, - slug CHAR(128) NOT NULL, - created_at TEXT NOT NULL, - comment CHAR(4000) NOT NULL, - rejected BOOLEAN, - approved BOOLEAN, - FOREIGN KEY (user_id) REFERENCES user(id) -); -INSERT INTO comment SELECT id, user_id, slug, created_at, comment, rejected, approved FROM comment_old; -DROP TABLE comment_old; - - --- Up -CREATE UNIQUE INDEX idx_user_id ON user(id); -CREATE INDEX idx_user_blocked ON user(blocked); -CREATE INDEX idx_user_trusted ON user(trusted); -CREATE UNIQUE INDEX idx_comment_id ON comment(id); -CREATE INDEX idx_comment_approved ON comment(approved); -CREATE INDEX idx_comment_created_at ON comment(created_at); -CREATE INDEX idx_comment_rejected ON comment(rejected); -CREATE INDEX idx_comment_user_id ON comment(user_id); -CREATE UNIQUE INDEX idx_setting_name ON setting(name); -CREATE INDEX idx_subscription_endpoint ON subscription(endpoint); - --- Down -DROP INDEX idx_user_id; -DROP INDEX idx_user_blocked; -DROP INDEX idx_user_trusted; -DROP INDEX idx_comment_id; -DROP INDEX idx_comment_approved; -DROP INDEX idx_comment_created_at; -DROP INDEX idx_comment_rejected; -DROP INDEX idx_comment_user_id; -DROP INDEX idx_setting_name; -DROP INDEX idx_subscription_endpoint; - - --- Up -CREATE UNIQUE INDEX idx_user_provider_id ON user(provider, provider_id); - --- Down -DROP INDEX idx_user_provider_id; - - --- Up -ALTER TABLE user ADD COLUMN url CHAR(255); - --- Down -ALTER TABLE user RENAME TO user_old; -CREATE TABLE user ( - id INTEGER PRIMARY KEY NOT NULL, - PII_name CHAR(128), - display_name CHAR(128), - provider CHAR(128), - provider_id CHAR(128), - created_at TEXT NOT NULL, - blocked BOOLEAN, - trusted BOOLEAN -); -INSERT INTO user SELECT id, name, display_name, provider, provider_id, - created_at, blocked, trusted FROM user_old; -DROP TABLE user_old; - - --- Up -CREATE TABLE oauth_provider ( - id INTEGER PRIMARY KEY NOT NULL, - provider CHAR(128), - provider_app_id CHAR(255), - domain CHAR(255), - client_id CHAR(255), - client_secret CHAR(255), - created_at TEXT NOT NULL -); - --- Down -DROP TABLE oauth_provider; diff --git a/k9db/explain.cc b/k9db/explain.cc index fad47300..1f1533fe 100644 --- a/k9db/explain.cc +++ b/k9db/explain.cc @@ -180,6 +180,7 @@ void ReportShardingInformation(const shards::TableName &table_name, default: LOG(FATAL) << "UNREACHABLE"; } + last_table = info.next_table(); // << info->next_table() << "(" << tinfo.upcolumn() << ")"; out << std::endl; } diff --git a/k9db/shards/sqlengine/create.cc b/k9db/shards/sqlengine/create.cc index 6040647c..95da24a7 100644 --- a/k9db/shards/sqlengine/create.cc +++ b/k9db/shards/sqlengine/create.cc @@ -33,22 +33,40 @@ absl::StatusOr CreateContext::DiscoverValidate() { // Make sure all FK point to existing tables. const sqlast::ColumnConstraint &fk = col.GetForeignKeyConstraint(); const auto &[foreign_table, foreign_column, fk_type] = fk.ForeignKey(); - ASSERT_RET(this->sstate_.TableExists(foreign_table), InvalidArgument, - "FK points to nonexisting table"); - const Table &target = this->sstate_.GetTable(foreign_table); + + // In case this is a self-referring FK. + bool self_fk = foreign_table == this->stmt_.table_name(); + if (!self_fk) { + ASSERT_RET(this->sstate_.TableExists(foreign_table), InvalidArgument, + "FK points to nonexisting table"); + } + + const Table &target = + self_fk ? this->table_ : this->sstate_.GetTable(foreign_table); ASSERT_RET(target.schema.HasColumn(foreign_column), InvalidArgument, "FK points to nonexisting column"); - // Check if this points to the PK. - size_t index = target.schema.IndexOf(foreign_column); - bool points_to_pk = target.schema.keys().at(0) == index; + // Check if this points to the PK, handle various annotations. + bool foreign_owned, foreign_accessed, points_to_pk; + if (self_fk) { + foreign_owned = !annotations.explicit_owners.empty() || + !annotations.implicit_owners.empty() || + this->stmt_.IsDataSubject(); + foreign_accessed = !annotations.accessors.empty() || foreign_owned; + points_to_pk = + this->stmt_.GetColumn(foreign_column) + .HasConstraint(sqlast::ColumnConstraint::Type::PRIMARY_KEY); + } else { + foreign_owned = this->sstate_.IsOwned(foreign_table); + foreign_accessed = this->sstate_.IsAccessed(foreign_table); + points_to_pk = + target.schema.keys().at(0) == target.schema.IndexOf(foreign_column); + } - // Handle various annotations. - bool foreign_owned = this->sstate_.IsOwned(foreign_table); - bool foreign_accessed = this->sstate_.IsAccessed(foreign_table); if (fk_type == sqlast::ColumnConstraint::FKType::OWNED_BY) { ASSERT_RET(foreign_owned, InvalidArgument, "OWNER to a non data subject"); ASSERT_RET(points_to_pk, InvalidArgument, "OWNER doesn't point to PK"); + ASSERT_RET(!self_fk, InvalidArgument, "OWNER on a self-referencing FK"); annotations.explicit_owners.push_back(i); } else if (fk_type == sqlast::ColumnConstraint::FKType::ACCESSED_BY) { ASSERT_RET(foreign_accessed, InvalidArgument, @@ -57,6 +75,7 @@ absl::StatusOr CreateContext::DiscoverValidate() { annotations.accessors.push_back(i); } else if (fk_type == sqlast::ColumnConstraint::FKType::OWNS) { ASSERT_RET(points_to_pk, InvalidArgument, "OWNS doesn't point to PK"); + ASSERT_RET(!self_fk, InvalidArgument, "OWNS on a self-referencing FK"); annotations.owns.push_back(i); } else if (fk_type == sqlast::ColumnConstraint::FKType::ACCESSES) { ASSERT_RET(points_to_pk, InvalidArgument, "ACCESSES doesn't point to PK"); @@ -99,7 +118,11 @@ std::vector> CreateContext::MakeFDescriptors( const std::string &fk_colname = fk_col.column_name(); const sqlast::ColumnConstraint &fk = fk_col.GetForeignKeyConstraint(); const auto &[next_table, next_col, _] = fk.ForeignKey(); - Table &tbl = this->sstate_.GetTable(next_table); + + Table &tbl = next_table == this->table_name_ + ? this->table_ + : this->sstate_.GetTable(next_table); + size_t next_col_index = tbl.schema.IndexOf(next_col); const std::vector> &vec = owners ? tbl.owners : tbl.accessors; @@ -117,11 +140,13 @@ std::vector> CreateContext::MakeFDescriptors( // First time we see this shard_kind. ShardDescriptor descriptor; descriptor.shard_kind = shard_kind; - if (shard_kind == next_table) { // Direct sharding. + if (shard_kind == next_table && next_table != this->table_name_) { + // Direct sharding. descriptor.type = InfoType::DIRECT; descriptor.info = DirectInfo{fk_colname, fk_column_index, fk_column_type, next_col, next_col_index}; - } else { // Transitive sharding. + } else { + // Transitive sharding. descriptor.type = InfoType::TRANSITIVE; IndexDescriptor *index = nullptr; if (create_indices) { diff --git a/k9db/shards/sqlengine/gdpr.cc b/k9db/shards/sqlengine/gdpr.cc index ec635dc8..baff4c85 100644 --- a/k9db/shards/sqlengine/gdpr.cc +++ b/k9db/shards/sqlengine/gdpr.cc @@ -199,6 +199,9 @@ absl::Status GDPRContext::RecurseOverDependents() { */ absl::Status GDPRContext::RecurseOverAccessDependents( const std::string &table_name, std::vector &&records) { + if (records.empty()) { + return absl::OkStatus(); + } // Iterate over all the access dependents. const Table &table = this->sstate_.GetTable(table_name); for (const auto &[next_table, desc] : table.access_dependents) { diff --git a/k9db/shards/sqlengine/gdpr_forget.cc b/k9db/shards/sqlengine/gdpr_forget.cc index 6cb9885d..16146eb5 100644 --- a/k9db/shards/sqlengine/gdpr_forget.cc +++ b/k9db/shards/sqlengine/gdpr_forget.cc @@ -224,6 +224,9 @@ absl::StatusOr GDPRForgetContext::Exec() { this->db_->CommitTransaction(); CHECK_STATUS(this->conn_->ctx->CommitCheckpoint()); + // Decrement users. + this->sstate_.DecrementUsers(this->shard_kind_, 1); + // Update dataflow. for (auto &[table_name, records] : this->records_) { this->dstate_.ProcessRecords(table_name, std::move(records)); diff --git a/k9db/shards/sqlengine/gdpr_forget_anon_unittest.cc b/k9db/shards/sqlengine/gdpr_forget_anon_unittest.cc index bee97b99..70627cc2 100644 --- a/k9db/shards/sqlengine/gdpr_forget_anon_unittest.cc +++ b/k9db/shards/sqlengine/gdpr_forget_anon_unittest.cc @@ -605,6 +605,58 @@ TEST_F(GDPRForgetAnonTest, ComplexVariableAccessorshipAnon) { db->RollbackTransaction(); } +TEST_F(GDPRForgetAnonTest, SelfFKTable) { + // Parse create table statements. + std::string commenters = + MakeCreate("commenters", {"commenterHex" STR PK}, true); + std::string comments = MakeCreate( + "comments", + {"commentHex" STR PK, "commenterHex" STR OB "commenters(commenterHex)", + "parentHex" STR AB "comments(commentHex)"}, + false, ", " ON_DEL "parentHex" DEL_ROW); + + // Make a k9db connection. + Connection conn = CreateConnection(); + sql::Session *db = conn.session.get(); + + // Create the tables. + EXPECT_SUCCESS(Execute(commenters, &conn)); + EXPECT_SUCCESS(Execute(comments, &conn)); + + // Perform some inserts. + auto &&[cr0_stmt, cr0] = MakeInsert("commenters", {"'0'"}); + auto &&[cr1_stmt, cr1] = MakeInsert("commenters", {"'1'"}); + auto &&[cr2_stmt, cr2] = MakeInsert("commenters", {"'2'"}); + + EXPECT_UPDATE(Execute(cr0_stmt, &conn), 1); + EXPECT_UPDATE(Execute(cr1_stmt, &conn), 1); + EXPECT_UPDATE(Execute(cr2_stmt, &conn), 1); + + auto &&[c0_stmt, c0] = MakeInsert("comments", {"'0'", "'0'", "NULL"}); + auto &&[c1_stmt, c1] = MakeInsert("comments", {"'1'", "'0'", "'0'"}); + auto &&[c2_stmt, c2] = MakeInsert("comments", {"'2'", "'1'", "'1'"}); + auto &&[c3_stmt, c3] = MakeInsert("comments", {"'3'", "'2'", "'2'"}); + auto &&[c4_stmt, c4] = MakeInsert("comments", {"'4'", "'0'", "'3'"}); + auto &&[c5_stmt, c5] = MakeInsert("comments", {"'5'", "'1'", "'3'"}); + + EXPECT_UPDATE(Execute(c0_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c1_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c2_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c3_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c4_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c5_stmt, &conn), 1); + + // Validate get. + std::string forget = MakeGDPRForget("commenters", "0"); + EXPECT_UPDATE(Execute(forget, &conn), 7); + + db->BeginTransaction(false); + EXPECT_EQ(db->GetShard("comments", SN("commenter", "0")), (V{})); + EXPECT_EQ(db->GetShard("comments", SN("commenter", "1")), (V{})); + EXPECT_EQ(db->GetShard("comments", SN("commenter", "2")), (V{})); + db->RollbackTransaction(); +} + } // namespace sqlengine } // namespace shards } // namespace k9db diff --git a/k9db/shards/sqlengine/gdpr_get_anon_unittest.cc b/k9db/shards/sqlengine/gdpr_get_anon_unittest.cc index d124ae6b..2d94abcd 100644 --- a/k9db/shards/sqlengine/gdpr_get_anon_unittest.cc +++ b/k9db/shards/sqlengine/gdpr_get_anon_unittest.cc @@ -677,6 +677,53 @@ TEST_F(GDPRGetAnonTest, ComplexVariableAccessorship) { (V{fanon1, fanon2})})); } +TEST_F(GDPRGetAnonTest, SelfFKTable) { + // Parse create table statements. + std::string commenters = + MakeCreate("commenters", {"commenterHex" STR PK}, true); + std::string comments = MakeCreate( + "comments", + {"commentHex" STR PK, "commenterHex" STR OB "commenters(commenterHex)", + "parentHex" STR AB "comments(commentHex)"}, + false, ", " ON_GET "parentHex" ANON "(commenterHex)"); + + // Make a k9db connection. + Connection conn = CreateConnection(); + + // Create the tables. + EXPECT_SUCCESS(Execute(commenters, &conn)); + EXPECT_SUCCESS(Execute(comments, &conn)); + + // Perform some inserts. + auto &&[cr0_stmt, cr0] = MakeInsert("commenters", {"'0'"}); + auto &&[cr1_stmt, cr1] = MakeInsert("commenters", {"'1'"}); + auto &&[cr2_stmt, cr2] = MakeInsert("commenters", {"'2'"}); + + EXPECT_UPDATE(Execute(cr0_stmt, &conn), 1); + EXPECT_UPDATE(Execute(cr1_stmt, &conn), 1); + EXPECT_UPDATE(Execute(cr2_stmt, &conn), 1); + + auto &&[c0_stmt, c0] = MakeInsert("comments", {"'0'", "'0'", "NULL"}); + auto &&[c1_stmt, c1] = MakeInsert("comments", {"'1'", "'0'", "'0'"}); + auto &&[c2_stmt, c2] = MakeInsert("comments", {"'2'", "'1'", "'1'"}); + auto &&[c3_stmt, c3] = MakeInsert("comments", {"'3'", "'2'", "'2'"}); + auto &&[c4_stmt, c4] = MakeInsert("comments", {"'4'", "'0'", "'3'"}); + auto &&[c5_stmt, c5] = MakeInsert("comments", {"'5'", "'1'", "'3'"}); + + EXPECT_UPDATE(Execute(c0_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c1_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c2_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c3_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c4_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c5_stmt, &conn), 1); + + // Validate get. + std::string get = MakeGDPRGet("commenters", "0"); + EXPECT_EQ(Execute(get, &conn).ResultSets(), + (VV{(V{cr0}), (V{c0, "|1|NULL|0|", "|2|NULL|1|", "|3|NULL|2|", + "|4|NULL|3|", "|5|NULL|3|"})})); +} + } // namespace sqlengine } // namespace shards } // namespace k9db diff --git a/k9db/shards/sqlengine/gdpr_get_unittest.cc b/k9db/shards/sqlengine/gdpr_get_unittest.cc index 4bc012b4..2f67cfd6 100644 --- a/k9db/shards/sqlengine/gdpr_get_unittest.cc +++ b/k9db/shards/sqlengine/gdpr_get_unittest.cc @@ -482,7 +482,7 @@ TEST_F(GDPRGetTest, TransitiveAccessorship) { // Validate get for user with id 5. std::string get1 = MakeGDPRGet("user", "5"); EXPECT_EQ(Execute(get1, &conn).ResultSets(), - (VV{(V{row4, row3}), (V{u1}), (V{}), (V{})})); + (VV{(V{row4, row3}), (V{u1}), (V{})})); // Validate get for user with id 10. std::string get2 = MakeGDPRGet("user", "10"); @@ -670,6 +670,51 @@ TEST_F(GDPRGetTest, ComplexVariableAccessorship) { (VV{(V{frow1, frow2}), (V{grow1, grow2}), (V{d0}), (V{farow1, farow2})})); } +TEST_F(GDPRGetTest, SelfFKTable) { + // Parse create table statements. + std::string commenters = + MakeCreate("commenters", {"commenterHex" STR PK}, true); + std::string comments = + MakeCreate("comments", {"commentHex" STR PK, + "commenterHex" STR OB "commenters(commenterHex)", + "parentHex" STR AB "comments(commentHex)"}); + + // Make a k9db connection. + Connection conn = CreateConnection(); + + // Create the tables. + EXPECT_SUCCESS(Execute(commenters, &conn)); + EXPECT_SUCCESS(Execute(comments, &conn)); + + // Perform some inserts. + auto &&[cr0_stmt, cr0] = MakeInsert("commenters", {"'0'"}); + auto &&[cr1_stmt, cr1] = MakeInsert("commenters", {"'1'"}); + auto &&[cr2_stmt, cr2] = MakeInsert("commenters", {"'2'"}); + + EXPECT_UPDATE(Execute(cr0_stmt, &conn), 1); + EXPECT_UPDATE(Execute(cr1_stmt, &conn), 1); + EXPECT_UPDATE(Execute(cr2_stmt, &conn), 1); + + auto &&[c0_stmt, c0] = MakeInsert("comments", {"'0'", "'0'", "NULL"}); + auto &&[c1_stmt, c1] = MakeInsert("comments", {"'1'", "'0'", "'0'"}); + auto &&[c2_stmt, c2] = MakeInsert("comments", {"'2'", "'1'", "'1'"}); + auto &&[c3_stmt, c3] = MakeInsert("comments", {"'3'", "'2'", "'2'"}); + auto &&[c4_stmt, c4] = MakeInsert("comments", {"'4'", "'0'", "'3'"}); + auto &&[c5_stmt, c5] = MakeInsert("comments", {"'5'", "'1'", "'3'"}); + + EXPECT_UPDATE(Execute(c0_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c1_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c2_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c3_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c4_stmt, &conn), 1); + EXPECT_UPDATE(Execute(c5_stmt, &conn), 1); + + // Validate get. + std::string get = MakeGDPRGet("commenters", "0"); + EXPECT_EQ(Execute(get, &conn).ResultSets(), + (VV{(V{cr0}), (V{c0, c1, c2, c3, c4, c5})})); +} + } // namespace sqlengine } // namespace shards } // namespace k9db diff --git a/k9db/shards/state.cc b/k9db/shards/state.cc index 05de7cc5..faea9834 100644 --- a/k9db/shards/state.cc +++ b/k9db/shards/state.cc @@ -52,12 +52,20 @@ Table *SharderState::AddTable(Table &&table) { } case InfoType::TRANSITIVE: { const TransitiveInfo &info = std::get(descriptor->info); - parent = &this->tables_.at(info.next_table); + if (info.next_table == table.table_name) { + parent = &table; + } else { + parent = &this->tables_.at(info.next_table); + } break; } case InfoType::VARIABLE: { const VariableInfo &info = std::get(descriptor->info); - parent = &this->tables_.at(info.origin_relation); + if (info.origin_relation == table.table_name) { + parent = &table; + } else { + parent = &this->tables_.at(info.origin_relation); + } break; } }