Browse Source

Update schema.sql

Vova Tkach 5 years ago
parent
commit
285964edda
1 changed files with 92 additions and 76 deletions
  1. 92 76
      support/schema.sql

+ 92 - 76
support/schema.sql

@@ -1,5 +1,5 @@
 # Tables
-CREATE TABLE blog_cats (
+CREATE TABLE fave_blog_cats (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	user int(11) NOT NULL COMMENT 'User id',
 	name varchar(255) NOT NULL COMMENT 'Category name',
@@ -8,11 +8,13 @@ CREATE TABLE blog_cats (
 	rgt int(11) NOT NULL COMMENT 'For nested set model',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE blog_cat_post_rel (
+
+CREATE TABLE fave_blog_cat_post_rel (
 	post_id int(11) NOT NULL COMMENT 'Post id',
 	category_id int(11) NOT NULL COMMENT 'Category id'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE blog_posts (
+
+CREATE TABLE fave_blog_posts (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	user int(11) NOT NULL COMMENT 'User id',
 	name varchar(255) NOT NULL COMMENT 'Post name',
@@ -24,7 +26,8 @@ CREATE TABLE blog_posts (
 	active int(1) NOT NULL COMMENT 'Is active post or not',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE notify_mail (
+
+CREATE TABLE fave_notify_mail (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	email varchar(255) NOT NULL COMMENT 'Email address',
 	subject varchar(800) NOT NULL COMMENT 'Email subject',
@@ -34,7 +37,8 @@ CREATE TABLE notify_mail (
 	status int(1) NOT NULL COMMENT 'Sending status',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE pages (
+
+CREATE TABLE fave_pages (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	user int(11) NOT NULL COMMENT 'User id',
 	name varchar(255) NOT NULL COMMENT 'Page name',
@@ -47,15 +51,18 @@ CREATE TABLE pages (
 	active int(1) NOT NULL COMMENT 'Is active page or not',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE settings (
+
+CREATE TABLE fave_settings (
 	name varchar(255) NOT NULL COMMENT 'Setting name',
 	value text NOT NULL COMMENT 'Setting value'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_cat_product_rel (
+
+CREATE TABLE fave_shop_cat_product_rel (
 	product_id int(11) NOT NULL COMMENT 'Product id',
 	category_id int(11) NOT NULL COMMENT 'Category id'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_cats (
+
+CREATE TABLE fave_shop_cats (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	user int(11) NOT NULL COMMENT 'User id',
 	name varchar(255) NOT NULL COMMENT 'Category name',
@@ -64,7 +71,8 @@ CREATE TABLE shop_cats (
 	rgt int(11) NOT NULL COMMENT 'For nested set model',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_currencies (
+
+CREATE TABLE fave_shop_currencies (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	name varchar(255) NOT NULL COMMENT 'Currency name',
 	coefficient float(8,4) NOT NULL DEFAULT '1.0000' COMMENT 'Currency coefficient',
@@ -72,23 +80,27 @@ CREATE TABLE shop_currencies (
 	symbol varchar(5) NOT NULL COMMENT 'Currency symbol',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_filter_product_values (
+
+CREATE TABLE fave_shop_filter_product_values (
 	product_id int(11) NOT NULL COMMENT 'Product id',
 	filter_value_id int(11) NOT NULL COMMENT 'Filter value id'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_filters (
+
+CREATE TABLE fave_shop_filters (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	name varchar(255) NOT NULL COMMENT 'Filter name in CP',
 	filter varchar(255) NOT NULL COMMENT 'Filter name in site',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_filters_values (
+
+CREATE TABLE fave_shop_filters_values (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	filter_id int(11) NOT NULL COMMENT 'Filter id',
 	name varchar(255) NOT NULL COMMENT 'Value name',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_order_products (
+
+CREATE TABLE fave_shop_order_products (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	order_id int(11) NOT NULL COMMENT 'Order ID',
 	product_id int(11) NOT NULL COMMENT 'Product ID',
@@ -96,7 +108,8 @@ CREATE TABLE shop_order_products (
 	quantity int(11) NOT NULL COMMENT 'Quantity',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_orders (
+
+CREATE TABLE fave_shop_orders (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	create_datetime datetime NOT NULL COMMENT 'Create date/time',
 	update_datetime datetime NOT NULL COMMENT 'Update date/time',
@@ -115,14 +128,16 @@ CREATE TABLE shop_orders (
 	status int(1) NOT NULL COMMENT 'new/confirmed/inprogress/canceled/completed',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_product_images (
+
+CREATE TABLE fave_shop_product_images (
 	id int(11) NOT NULL AUTO_INCREMENT,
 	product_id int(11) NOT NULL,
 	filename varchar(255) NOT NULL,
 	ord int(11) NOT NULL DEFAULT '0',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE shop_products (
+
+CREATE TABLE fave_shop_products (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	parent_id int(11) DEFAULT NULL,
 	user int(11) NOT NULL COMMENT 'User id',
@@ -144,7 +159,8 @@ CREATE TABLE shop_products (
 	custom2 varchar(2048) NOT NULL DEFAULT '',
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE users (
+
+CREATE TABLE fave_users (
 	id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
 	first_name varchar(64) NOT NULL DEFAULT '' COMMENT 'User first name',
 	last_name varchar(64) NOT NULL DEFAULT '' COMMENT 'User last name',
@@ -156,64 +172,64 @@ CREATE TABLE users (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 # Indexes
-ALTER TABLE blog_cat_post_rel ADD UNIQUE KEY post_category (post_id,category_id) USING BTREE;
-ALTER TABLE blog_cat_post_rel ADD KEY FK_blog_cat_post_rel_post_id (post_id);
-ALTER TABLE blog_cat_post_rel ADD KEY FK_blog_cat_post_rel_category_id (category_id);
-ALTER TABLE blog_cats ADD UNIQUE KEY alias (alias);
-ALTER TABLE blog_cats ADD KEY lft (lft), ADD KEY rgt (rgt);
-ALTER TABLE blog_cats ADD KEY FK_blog_cats_user (user);
-ALTER TABLE blog_posts ADD UNIQUE KEY alias (alias);
-ALTER TABLE blog_posts ADD KEY FK_blog_posts_user (user);
-ALTER TABLE blog_posts ADD KEY FK_blog_posts_category (category);
-ALTER TABLE notify_mail ADD KEY status (status);
-ALTER TABLE pages ADD UNIQUE KEY alias (alias);
-ALTER TABLE pages ADD KEY alias_active (alias,active) USING BTREE;
-ALTER TABLE pages ADD KEY FK_pages_user (user);
-ALTER TABLE settings ADD UNIQUE KEY name (name);
-ALTER TABLE shop_cat_product_rel ADD UNIQUE KEY product_category (product_id,category_id) USING BTREE;
-ALTER TABLE shop_cat_product_rel ADD KEY FK_shop_cat_product_rel_product_id (product_id);
-ALTER TABLE shop_cat_product_rel ADD KEY FK_shop_cat_product_rel_category_id (category_id);
-ALTER TABLE shop_cats ADD UNIQUE KEY alias (alias);
-ALTER TABLE shop_cats ADD KEY lft (lft), ADD KEY rgt (rgt);
-ALTER TABLE shop_cats ADD KEY FK_shop_cats_user (user);
-ALTER TABLE shop_filter_product_values ADD UNIQUE KEY product_filter_value (product_id,filter_value_id) USING BTREE;
-ALTER TABLE shop_filter_product_values ADD KEY FK_shop_filter_product_values_product_id (product_id);
-ALTER TABLE shop_filter_product_values ADD KEY FK_shop_filter_product_values_filter_value_id (filter_value_id);
-ALTER TABLE shop_filters ADD KEY name (name);
-ALTER TABLE shop_filters_values ADD KEY FK_shop_filters_values_filter_id (filter_id);
-ALTER TABLE shop_filters_values ADD KEY name (name);
-ALTER TABLE shop_orders ADD KEY FK_shop_orders_currency_id (currency_id);
-ALTER TABLE shop_order_products ADD UNIQUE KEY order_product (order_id,product_id) USING BTREE;
-ALTER TABLE shop_order_products ADD KEY FK_shop_order_products_order_id (order_id);
-ALTER TABLE shop_order_products ADD KEY FK_shop_order_products_product_id (product_id);
-ALTER TABLE shop_product_images ADD UNIQUE KEY product_filename (product_id,filename) USING BTREE;
-ALTER TABLE shop_product_images ADD KEY FK_shop_product_images_product_id (product_id);
-ALTER TABLE shop_products ADD UNIQUE KEY alias (alias);
-ALTER TABLE shop_products ADD KEY FK_shop_products_user (user);
-ALTER TABLE shop_products ADD KEY FK_shop_products_currency (currency);
-ALTER TABLE shop_products ADD KEY FK_shop_products_category (category);
-ALTER TABLE shop_products ADD KEY FK_shop_products_parent_id (parent_id);
-ALTER TABLE shop_products ADD KEY name (name);
-ALTER TABLE users ADD UNIQUE KEY email (email);
+ALTER TABLE fave_blog_cat_post_rel ADD UNIQUE KEY post_category (post_id,category_id) USING BTREE;
+ALTER TABLE fave_blog_cat_post_rel ADD KEY FK_blog_cat_post_rel_post_id (post_id);
+ALTER TABLE fave_blog_cat_post_rel ADD KEY FK_blog_cat_post_rel_category_id (category_id);
+ALTER TABLE fave_blog_cats ADD UNIQUE KEY alias (alias);
+ALTER TABLE fave_blog_cats ADD KEY lft (lft), ADD KEY rgt (rgt);
+ALTER TABLE fave_blog_cats ADD KEY FK_blog_cats_user (user);
+ALTER TABLE fave_blog_posts ADD UNIQUE KEY alias (alias);
+ALTER TABLE fave_blog_posts ADD KEY FK_blog_posts_user (user);
+ALTER TABLE fave_blog_posts ADD KEY FK_blog_posts_category (category);
+ALTER TABLE fave_notify_mail ADD KEY status (status);
+ALTER TABLE fave_pages ADD UNIQUE KEY alias (alias);
+ALTER TABLE fave_pages ADD KEY alias_active (alias,active) USING BTREE;
+ALTER TABLE fave_pages ADD KEY FK_pages_user (user);
+ALTER TABLE fave_settings ADD UNIQUE KEY name (name);
+ALTER TABLE fave_shop_cat_product_rel ADD UNIQUE KEY product_category (product_id,category_id) USING BTREE;
+ALTER TABLE fave_shop_cat_product_rel ADD KEY FK_shop_cat_product_rel_product_id (product_id);
+ALTER TABLE fave_shop_cat_product_rel ADD KEY FK_shop_cat_product_rel_category_id (category_id);
+ALTER TABLE fave_shop_cats ADD UNIQUE KEY alias (alias);
+ALTER TABLE fave_shop_cats ADD KEY lft (lft), ADD KEY rgt (rgt);
+ALTER TABLE fave_shop_cats ADD KEY FK_shop_cats_user (user);
+ALTER TABLE fave_shop_filter_product_values ADD UNIQUE KEY product_filter_value (product_id,filter_value_id) USING BTREE;
+ALTER TABLE fave_shop_filter_product_values ADD KEY FK_shop_filter_product_values_product_id (product_id);
+ALTER TABLE fave_shop_filter_product_values ADD KEY FK_shop_filter_product_values_filter_value_id (filter_value_id);
+ALTER TABLE fave_shop_filters ADD KEY name (name);
+ALTER TABLE fave_shop_filters_values ADD KEY FK_shop_filters_values_filter_id (filter_id);
+ALTER TABLE fave_shop_filters_values ADD KEY name (name);
+ALTER TABLE fave_shop_orders ADD KEY FK_shop_orders_currency_id (currency_id);
+ALTER TABLE fave_shop_order_products ADD UNIQUE KEY order_product (order_id,product_id) USING BTREE;
+ALTER TABLE fave_shop_order_products ADD KEY FK_shop_order_products_order_id (order_id);
+ALTER TABLE fave_shop_order_products ADD KEY FK_shop_order_products_product_id (product_id);
+ALTER TABLE fave_shop_product_images ADD UNIQUE KEY product_filename (product_id,filename) USING BTREE;
+ALTER TABLE fave_shop_product_images ADD KEY FK_shop_product_images_product_id (product_id);
+ALTER TABLE fave_shop_products ADD UNIQUE KEY alias (alias);
+ALTER TABLE fave_shop_products ADD KEY FK_shop_products_user (user);
+ALTER TABLE fave_shop_products ADD KEY FK_shop_products_currency (currency);
+ALTER TABLE fave_shop_products ADD KEY FK_shop_products_category (category);
+ALTER TABLE fave_shop_products ADD KEY FK_shop_products_parent_id (parent_id);
+ALTER TABLE fave_shop_products ADD KEY name (name);
+ALTER TABLE fave_users ADD UNIQUE KEY email (email);
 
 # References
-ALTER TABLE blog_cat_post_rel ADD CONSTRAINT FK_blog_cat_post_rel_post_id FOREIGN KEY (post_id) REFERENCES blog_posts (id) ON DELETE RESTRICT;
-ALTER TABLE blog_cat_post_rel ADD CONSTRAINT FK_blog_cat_post_rel_category_id FOREIGN KEY (category_id) REFERENCES blog_cats (id) ON DELETE RESTRICT;
-ALTER TABLE blog_cats ADD CONSTRAINT FK_blog_cats_user FOREIGN KEY (user) REFERENCES users (id) ON DELETE RESTRICT;
-ALTER TABLE blog_posts ADD CONSTRAINT FK_blog_posts_user FOREIGN KEY (user) REFERENCES users (id) ON DELETE RESTRICT;
-ALTER TABLE blog_posts ADD CONSTRAINT FK_blog_posts_category FOREIGN KEY (category) REFERENCES blog_cats (id) ON DELETE RESTRICT;
-ALTER TABLE pages ADD CONSTRAINT FK_pages_user FOREIGN KEY (user) REFERENCES users (id) ON DELETE RESTRICT;
-ALTER TABLE shop_cat_product_rel ADD CONSTRAINT FK_shop_cat_product_rel_product_id FOREIGN KEY (product_id) REFERENCES shop_products (id) ON DELETE RESTRICT;
-ALTER TABLE shop_cat_product_rel ADD CONSTRAINT FK_shop_cat_product_rel_category_id FOREIGN KEY (category_id) REFERENCES shop_cats (id) ON DELETE RESTRICT;
-ALTER TABLE shop_cats ADD CONSTRAINT FK_shop_cats_user FOREIGN KEY (user) REFERENCES users (id) ON DELETE RESTRICT;
-ALTER TABLE shop_filter_product_values ADD CONSTRAINT FK_shop_filter_product_values_product_id FOREIGN KEY (product_id) REFERENCES shop_products (id) ON DELETE RESTRICT;
-ALTER TABLE shop_filter_product_values ADD CONSTRAINT FK_shop_filter_product_values_filter_value_id FOREIGN KEY (filter_value_id) REFERENCES shop_filters_values (id) ON DELETE RESTRICT;
-ALTER TABLE shop_filters_values ADD CONSTRAINT FK_shop_filters_values_filter_id FOREIGN KEY (filter_id) REFERENCES shop_filters (id) ON DELETE RESTRICT;
-ALTER TABLE shop_orders ADD CONSTRAINT FK_shop_orders_currency_id FOREIGN KEY (currency_id) REFERENCES shop_currencies (id) ON DELETE RESTRICT;
-ALTER TABLE shop_order_products ADD CONSTRAINT FK_shop_order_products_order_id FOREIGN KEY (order_id) REFERENCES shop_orders (id) ON DELETE RESTRICT;
-ALTER TABLE shop_order_products ADD CONSTRAINT FK_shop_order_products_product_id FOREIGN KEY (product_id) REFERENCES shop_products (id) ON DELETE RESTRICT;
-ALTER TABLE shop_product_images ADD CONSTRAINT FK_shop_product_images_product_id FOREIGN KEY (product_id) REFERENCES shop_products (id) ON DELETE RESTRICT;
-ALTER TABLE shop_products ADD CONSTRAINT FK_shop_products_user FOREIGN KEY (user) REFERENCES users (id) ON DELETE RESTRICT;
-ALTER TABLE shop_products ADD CONSTRAINT FK_shop_products_currency FOREIGN KEY (currency) REFERENCES shop_currencies (id) ON DELETE RESTRICT;
-ALTER TABLE shop_products ADD CONSTRAINT FK_shop_products_category FOREIGN KEY (category) REFERENCES shop_cats (id) ON DELETE RESTRICT;
-ALTER TABLE shop_products ADD CONSTRAINT FK_shop_products_parent_id FOREIGN KEY (parent_id) REFERENCES shop_products (id) ON DELETE RESTRICT;
+ALTER TABLE fave_blog_cat_post_rel ADD CONSTRAINT FK_blog_cat_post_rel_post_id FOREIGN KEY (post_id) REFERENCES fave_blog_posts (id) ON DELETE RESTRICT;
+ALTER TABLE fave_blog_cat_post_rel ADD CONSTRAINT FK_blog_cat_post_rel_category_id FOREIGN KEY (category_id) REFERENCES fave_blog_cats (id) ON DELETE RESTRICT;
+ALTER TABLE fave_blog_cats ADD CONSTRAINT FK_blog_cats_user FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
+ALTER TABLE fave_blog_posts ADD CONSTRAINT FK_blog_posts_user FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
+ALTER TABLE fave_blog_posts ADD CONSTRAINT FK_blog_posts_category FOREIGN KEY (category) REFERENCES fave_blog_cats (id) ON DELETE RESTRICT;
+ALTER TABLE fave_pages ADD CONSTRAINT FK_pages_user FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_cat_product_rel ADD CONSTRAINT FK_shop_cat_product_rel_product_id FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_cat_product_rel ADD CONSTRAINT FK_shop_cat_product_rel_category_id FOREIGN KEY (category_id) REFERENCES fave_shop_cats (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_cats ADD CONSTRAINT FK_shop_cats_user FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_filter_product_values ADD CONSTRAINT FK_shop_filter_product_values_product_id FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_filter_product_values ADD CONSTRAINT FK_shop_filter_product_values_filter_value_id FOREIGN KEY (filter_value_id) REFERENCES fave_shop_filters_values (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_filters_values ADD CONSTRAINT FK_shop_filters_values_filter_id FOREIGN KEY (filter_id) REFERENCES fave_shop_filters (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_orders ADD CONSTRAINT FK_shop_orders_currency_id FOREIGN KEY (currency_id) REFERENCES fave_shop_currencies (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_order_products ADD CONSTRAINT FK_shop_order_products_order_id FOREIGN KEY (order_id) REFERENCES fave_shop_orders (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_order_products ADD CONSTRAINT FK_shop_order_products_product_id FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_product_images ADD CONSTRAINT FK_shop_product_images_product_id FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_user FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_currency FOREIGN KEY (currency) REFERENCES fave_shop_currencies (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_category FOREIGN KEY (category) REFERENCES fave_shop_cats (id) ON DELETE RESTRICT;
+ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_parent_id FOREIGN KEY (parent_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;