-- Скрипт сгенерирован Devart dbForge Studio for MySQL, Версия 6.1.166.0 -- Домашняя страница продукта: http://www.devart.com/ru/dbforge/mysql/studio -- Дата скрипта: 01.04.2014 16:06:56 -- Версия сервера: 5.5.33a-MariaDB -- Версия клиента: 4.1 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; SET NAMES 'utf8'; CREATE TABLE user ( id INT(11) NOT NULL AUTO_INCREMENT, login VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, email VARCHAR(50) NOT NULL, contacts VARCHAR(255) DEFAULT NULL, PRIMARY KEY (id), UNIQUE INDEX email (email), UNIQUE INDEX login (login) ) ENGINE = INNODB AUTO_INCREMENT = 19 AVG_ROW_LENGTH = 5461 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE forgot ( id INT(11) NOT NULL AUTO_INCREMENT, id_user INT(11) NOT NULL, secret VARCHAR(255) NOT NULL, ip VARCHAR(255) NOT NULL, status ENUM('new','done') NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_forgot_user_id FOREIGN KEY (id_user) REFERENCES user(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 4 AVG_ROW_LENGTH = 8192 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE shop ( id INT(11) NOT NULL AUTO_INCREMENT, id_user INT(11) NOT NULL, domain VARCHAR(255) NOT NULL, date DATETIME NOT NULL, status ENUM('Работает','Заблокирован') NOT NULL, catalog_position INT(11) NOT NULL, PRIMARY KEY (id), UNIQUE INDEX catalog_position (catalog_position), UNIQUE INDEX domain (domain), CONSTRAINT FK_shop_user_id FOREIGN KEY (id_user) REFERENCES user(id) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE = INNODB AUTO_INCREMENT = 5 AVG_ROW_LENGTH = 16384 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE shop_payments ( id INT(11) NOT NULL AUTO_INCREMENT, id_user INT(11) NOT NULL, count VARCHAR(255) NOT NULL, sum DECIMAL(19, 2) NOT NULL, paymethod ENUM('wmz','wmr','qiwi') NOT NULL, type ENUM('Регистрация','Продление','Подъём в каталоге') NOT NULL, status ENUM('Не оплачен','Оплачен') NOT NULL, domain VARCHAR(255) NOT NULL, timestamp TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), CONSTRAINT FK_shop_payments_user_id FOREIGN KEY (id_user) REFERENCES user(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 23 AVG_ROW_LENGTH = 5461 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE ban ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, ip VARCHAR(255) NOT NULL, comment VARCHAR(255) NOT NULL DEFAULT '-', PRIMARY KEY (id), CONSTRAINT FK_ban_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 1 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE discounts ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, percent INT(11) NOT NULL, count INT(11) NOT NULL, comment VARCHAR(255) DEFAULT NULL, items TEXT NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_discounts_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 2 AVG_ROW_LENGTH = 16384 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE goods ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, name VARCHAR(50) NOT NULL, cost_rub DECIMAL(19, 2) NOT NULL, cost_usd DECIMAL(19, 2) NOT NULL, min_count INT(11) NOT NULL, description TEXT DEFAULT NULL, ico VARCHAR(255) DEFAULT NULL, `position` INT(11) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_goods_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 6 AVG_ROW_LENGTH = 8192 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE payment_qiwi ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, login VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_payment_qiwi_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 8 AVG_ROW_LENGTH = 8192 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE payment_webmoney ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, wmid VARCHAR(255) NOT NULL, wmr VARCHAR(255) NOT NULL, wmz VARCHAR(255) NOT NULL, key_pass VARCHAR(255) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_payment_webmoney_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 3 AVG_ROW_LENGTH = 16384 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE payment_yandex ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, login VARCHAR(255) NOT NULL, token TEXT NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_payment_yandex_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 6 AVG_ROW_LENGTH = 16384 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE separators ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, name VARCHAR(50) NOT NULL, `position` INT(11) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_separators_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 2 AVG_ROW_LENGTH = 16384 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE template ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, meta_title TEXT DEFAULT NULL, meta_description TEXT DEFAULT NULL, meta_keywords TEXT DEFAULT NULL, meta_favicon TEXT DEFAULT NULL, texts_above TEXT DEFAULT NULL, texts_below TEXT DEFAULT NULL, texts_scripts TEXT DEFAULT NULL, template ENUM('deer','light') NOT NULL DEFAULT 'deer', PRIMARY KEY (id), CONSTRAINT FK_template_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 5 AVG_ROW_LENGTH = 16384 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE orders ( id INT(11) NOT NULL AUTO_INCREMENT, id_shop INT(11) NOT NULL, id_goods INT(11) NOT NULL, date DATETIME NOT NULL, sum DECIMAL(19, 2) NOT NULL, count INT(11) NOT NULL, method ENUM('wmr','wmz','yandex','qiwi') NOT NULL, email VARCHAR(50) NOT NULL, icq VARCHAR(255) DEFAULT NULL, status ENUM('Не оплачен','Оплачен') NOT NULL DEFAULT 'Не оплачен', secret VARCHAR(255) NOT NULL, coupon VARCHAR(255) DEFAULT NULL, purse VARCHAR(255) DEFAULT NULL, ip VARCHAR(255) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_orders_goods_id FOREIGN KEY (id_goods) REFERENCES goods(id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FK_orders_shop_id FOREIGN KEY (id_shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 8 AVG_ROW_LENGTH = 2730 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE goods_object ( id INT(11) NOT NULL AUTO_INCREMENT, id_goods INT(11) NOT NULL, id_orders INT(11) DEFAULT NULL, text VARCHAR(255) NOT NULL, PRIMARY KEY (id), CONSTRAINT FK_goods_object_goods_id FOREIGN KEY (id_goods) REFERENCES goods(id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FK_goods_object_orders_id FOREIGN KEY (id_orders) REFERENCES orders(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 11 AVG_ROW_LENGTH = 1638 CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE orders_return ( id INT(11) NOT NULL AUTO_INCREMENT, id_orders INT(11) NOT NULL, obj_all INT(11) NOT NULL, obj_given INT(11) NOT NULL, obj_notgiven INT(11) NOT NULL, sum_return DECIMAL(19, 2) NOT NULL, sum_type ENUM('wmr','wmz','yandex','qiwi') NOT NULL, status ENUM('Не обработано','Обработано') NOT NULL DEFAULT 'Не обработано', PRIMARY KEY (id), CONSTRAINT FK_orders_return_orders_id FOREIGN KEY (id_orders) REFERENCES orders(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = INNODB AUTO_INCREMENT = 1 CHARACTER SET utf8 COLLATE utf8_general_ci; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;