CREATE TABLE generic_product (id BIGINT AUTO_INCREMENT, parent_id BIGINT, equipment_id BIGINT NOT NULL, type_note VARCHAR(255), balance DOUBLE, gear VARCHAR(255), diameter_disc DOUBLE, diameter DOUBLE, diameter_str VARCHAR(255), board VARCHAR(255), cutting_width DOUBLE, length DOUBLE, length_fracture DOUBLE, application VARCHAR(255), cooling VARCHAR(255), material VARCHAR(255), diameter_in DOUBLE, diameter_out DOUBLE, width DOUBLE, line_width DOUBLE, whorl VARCHAR(255), extensity VARCHAR(255), profile VARCHAR(255), height DOUBLE, length_str VARCHAR(255), tonnage_str VARCHAR(255), tonnage DOUBLE, tonnage_couple DOUBLE, min_height DOUBLE, max_height DOUBLE, gap DOUBLE, compression DOUBLE, medium VARCHAR(255), gasket VARCHAR(255), uplift DOUBLE, uplift_str VARCHAR(255), year BIGINT, price DOUBLE, producer VARCHAR(255), tonnage_car DOUBLE, width_prong_car DOUBLE, weight_prong_car DOUBLE, length_prong_car DOUBLE, width_mesh DOUBLE, size DOUBLE, moto_hours DOUBLE, operative_height DOUBLE, dipper_size VARCHAR(100), wheel_diameter DOUBLE, desk_size VARCHAR(100), desk_iso BIGINT, loading_area VARCHAR(100), drift_width DOUBLE, length_extended_prong_car DOUBLE, weight DOUBLE, extra_price DOUBLE, extra_price_note LONGTEXT, modifications VARCHAR(255), snow_capacity DOUBLE, water_capacity DOUBLE, cut_depth DOUBLE, code VARCHAR(255), stock BIGINT DEFAULT 0, INDEX equipment_id_idx (equipment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE page_version (id BIGINT, parent_id BIGINT, in_menu TINYINT(1) DEFAULT '0' NOT NULL, title VARCHAR(255) NOT NULL, introduction LONGTEXT, body LONGTEXT, permission VARCHAR(255), priority BIGINT NOT NULL, description LONGTEXT, meta_kw VARCHAR(255), created_at DATETIME, updated_at DATETIME, slug VARCHAR(255), version BIGINT, PRIMARY KEY(id, version)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE page (id BIGINT AUTO_INCREMENT, parent_id BIGINT, in_menu TINYINT(1) DEFAULT '0' NOT NULL, title VARCHAR(255) NOT NULL, introduction LONGTEXT, body LONGTEXT, permission VARCHAR(255), priority BIGINT NOT NULL, description LONGTEXT, meta_kw VARCHAR(255), created_at DATETIME, updated_at DATETIME, slug VARCHAR(255), version BIGINT, UNIQUE INDEX sluggable_idx (slug), INDEX parent_id_idx (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE file (id BIGINT AUTO_INCREMENT, product_id BIGINT NOT NULL, name VARCHAR(255) NOT NULL, filename VARCHAR(255) NOT NULL, size BIGINT NOT NULL, created_at DATETIME, updated_at DATETIME, INDEX product_id_idx (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE product_version (id BIGINT, parent_id BIGINT, equipment_id BIGINT NOT NULL, type_note VARCHAR(255), balance DOUBLE, gear VARCHAR(255), diameter_disc DOUBLE, diameter DOUBLE, diameter_str VARCHAR(255), board VARCHAR(255), cutting_width DOUBLE, length DOUBLE, length_fracture DOUBLE, application VARCHAR(255), cooling VARCHAR(255), material VARCHAR(255), diameter_in DOUBLE, diameter_out DOUBLE, width DOUBLE, line_width DOUBLE, whorl VARCHAR(255), extensity VARCHAR(255), profile VARCHAR(255), height DOUBLE, length_str VARCHAR(255), tonnage_str VARCHAR(255), tonnage DOUBLE, tonnage_couple DOUBLE, min_height DOUBLE, max_height DOUBLE, gap DOUBLE, compression DOUBLE, medium VARCHAR(255), gasket VARCHAR(255), uplift DOUBLE, uplift_str VARCHAR(255), year BIGINT, price DOUBLE, producer VARCHAR(255), tonnage_car DOUBLE, width_prong_car DOUBLE, weight_prong_car DOUBLE, length_prong_car DOUBLE, width_mesh DOUBLE, size DOUBLE, moto_hours DOUBLE, operative_height DOUBLE, dipper_size VARCHAR(100), wheel_diameter DOUBLE, desk_size VARCHAR(100), desk_iso BIGINT, loading_area VARCHAR(100), drift_width DOUBLE, length_extended_prong_car DOUBLE, weight DOUBLE, extra_price DOUBLE, extra_price_note LONGTEXT, modifications VARCHAR(255), snow_capacity DOUBLE, water_capacity DOUBLE, cut_depth DOUBLE, code VARCHAR(255), stock BIGINT DEFAULT 0, name VARCHAR(255) NOT NULL, description LONGTEXT, meta_desc VARCHAR(255), meta_kw VARCHAR(255), created_at DATETIME, updated_at DATETIME, slug VARCHAR(255), version BIGINT, PRIMARY KEY(id, version)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE product (id BIGINT AUTO_INCREMENT, parent_id BIGINT, equipment_id BIGINT NOT NULL, type_note VARCHAR(255), balance DOUBLE, gear VARCHAR(255), diameter_disc DOUBLE, diameter DOUBLE, diameter_str VARCHAR(255), board VARCHAR(255), cutting_width DOUBLE, length DOUBLE, length_fracture DOUBLE, application VARCHAR(255), cooling VARCHAR(255), material VARCHAR(255), diameter_in DOUBLE, diameter_out DOUBLE, width DOUBLE, line_width DOUBLE, whorl VARCHAR(255), extensity VARCHAR(255), profile VARCHAR(255), height DOUBLE, length_str VARCHAR(255), tonnage_str VARCHAR(255), tonnage DOUBLE, tonnage_couple DOUBLE, min_height DOUBLE, max_height DOUBLE, gap DOUBLE, compression DOUBLE, medium VARCHAR(255), gasket VARCHAR(255), uplift DOUBLE, uplift_str VARCHAR(255), year BIGINT, price DOUBLE, producer VARCHAR(255), tonnage_car DOUBLE, width_prong_car DOUBLE, weight_prong_car DOUBLE, length_prong_car DOUBLE, width_mesh DOUBLE, size DOUBLE, moto_hours DOUBLE, operative_height DOUBLE, dipper_size VARCHAR(100), wheel_diameter DOUBLE, desk_size VARCHAR(100), desk_iso BIGINT, loading_area VARCHAR(100), drift_width DOUBLE, length_extended_prong_car DOUBLE, weight DOUBLE, extra_price DOUBLE, extra_price_note LONGTEXT, modifications VARCHAR(255), snow_capacity DOUBLE, water_capacity DOUBLE, cut_depth DOUBLE, code VARCHAR(255), stock BIGINT DEFAULT 0, name VARCHAR(255) NOT NULL, description LONGTEXT, meta_desc VARCHAR(255), meta_kw VARCHAR(255), created_at DATETIME, updated_at DATETIME, slug VARCHAR(255), version BIGINT, UNIQUE INDEX sluggable_idx (slug), INDEX equipment_id_idx (equipment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE image (id BIGINT AUTO_INCREMENT, product_id BIGINT NOT NULL, filename VARCHAR(255) NOT NULL, main TINYINT(1) DEFAULT '0' NOT NULL, created_at DATETIME, updated_at DATETIME, INDEX product_id_idx (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE sf_guard_user_group (user_id INT, group_id INT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(user_id, group_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_group (id INT AUTO_INCREMENT, name VARCHAR(255) UNIQUE, description TEXT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_user (id INT AUTO_INCREMENT, username VARCHAR(128) NOT NULL UNIQUE, algorithm VARCHAR(128) DEFAULT 'sha1' NOT NULL, salt VARCHAR(128), password VARCHAR(128), is_active TINYINT(1) DEFAULT '1', is_super_admin TINYINT(1) DEFAULT '0', last_login DATETIME, created_at DATETIME, updated_at DATETIME, INDEX is_active_idx_idx (is_active), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_group_permission (group_id INT, permission_id INT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(group_id, permission_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_remember_key (id INT AUTO_INCREMENT, user_id INT, remember_key VARCHAR(32), ip_address VARCHAR(50), created_at DATETIME, updated_at DATETIME, INDEX user_id_idx (user_id), PRIMARY KEY(id, ip_address)) ENGINE = INNODB;
CREATE TABLE sf_guard_user_permission (user_id INT, permission_id INT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(user_id, permission_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_permission (id INT AUTO_INCREMENT, name VARCHAR(255) UNIQUE, description TEXT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE request_product (id BIGINT AUTO_INCREMENT, person_company VARCHAR(255) NOT NULL, person_name VARCHAR(255) NOT NULL, person_email VARCHAR(255), person_phone VARCHAR(255), person_note LONGTEXT, equipment_id BIGINT, communication_id BIGINT, product_id BIGINT, status BIGINT, created_at DATETIME, updated_at DATETIME, product_version BIGINT, INDEX equipment_id_idx (equipment_id), INDEX communication_id_idx (communication_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE request (id BIGINT AUTO_INCREMENT, parent_id BIGINT, equipment_id BIGINT NOT NULL, type_note VARCHAR(255), balance DOUBLE, gear VARCHAR(255), diameter_disc DOUBLE, diameter DOUBLE, diameter_str VARCHAR(255), board VARCHAR(255), cutting_width DOUBLE, length DOUBLE, length_fracture DOUBLE, application VARCHAR(255), cooling VARCHAR(255), material VARCHAR(255), diameter_in DOUBLE, diameter_out DOUBLE, width DOUBLE, line_width DOUBLE, whorl VARCHAR(255), extensity VARCHAR(255), profile VARCHAR(255), height DOUBLE, length_str VARCHAR(255), tonnage_str VARCHAR(255), tonnage DOUBLE, tonnage_couple DOUBLE, min_height DOUBLE, max_height DOUBLE, gap DOUBLE, compression DOUBLE, medium VARCHAR(255), gasket VARCHAR(255), uplift DOUBLE, uplift_str VARCHAR(255), year BIGINT, price DOUBLE, producer VARCHAR(255), tonnage_car DOUBLE, width_prong_car DOUBLE, weight_prong_car DOUBLE, length_prong_car DOUBLE, width_mesh DOUBLE, size DOUBLE, moto_hours DOUBLE, operative_height DOUBLE, dipper_size VARCHAR(100), wheel_diameter DOUBLE, desk_size VARCHAR(100), desk_iso BIGINT, loading_area VARCHAR(100), drift_width DOUBLE, length_extended_prong_car DOUBLE, weight DOUBLE, extra_price DOUBLE, extra_price_note LONGTEXT, modifications VARCHAR(255), snow_capacity DOUBLE, water_capacity DOUBLE, cut_depth DOUBLE, code VARCHAR(255), stock BIGINT DEFAULT 0, person_company VARCHAR(255) NOT NULL, person_name VARCHAR(255) NOT NULL, person_place VARCHAR(255) NOT NULL, person_email VARCHAR(255), person_phone VARCHAR(255), person_note LONGTEXT, communication_id BIGINT, status BIGINT, created_at DATETIME, updated_at DATETIME, INDEX equipment_id_idx (equipment_id), INDEX communication_id_idx (communication_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE communication (id BIGINT AUTO_INCREMENT, hash VARCHAR(20) NOT NULL, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE indent_item (id BIGINT AUTO_INCREMENT, product_id BIGINT NOT NULL, indent_id BIGINT NOT NULL, count BIGINT NOT NULL, product_version BIGINT, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE form (id BIGINT AUTO_INCREMENT, mail VARCHAR(255), name_form VARCHAR(255), result LONGTEXT, form TEXT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE communication_message (id BIGINT AUTO_INCREMENT, text LONGTEXT, typeofmessage BIGINT, communication_id BIGINT, created_at DATETIME, updated_at DATETIME, INDEX communication_id_idx (communication_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE indent (id BIGINT AUTO_INCREMENT, tel VARCHAR(255) NOT NULL, mail VARCHAR(255) NOT NULL, delivery_first_name VARCHAR(255) NOT NULL, delivery_last_name VARCHAR(255) NOT NULL, delivery_company VARCHAR(255), delivery_street VARCHAR(255) NOT NULL, delivery_city VARCHAR(255) NOT NULL, delivery_zip VARCHAR(255) NOT NULL, delivery_country VARCHAR(255) NOT NULL, delivery_ic VARCHAR(255), delivery_dic VARCHAR(255), invoice_first_name VARCHAR(255) NOT NULL, invoice_last_name VARCHAR(255) NOT NULL, invoice_company VARCHAR(255), invoice_street VARCHAR(255) NOT NULL, invoice_city VARCHAR(255) NOT NULL, invoice_zip VARCHAR(255) NOT NULL, invoice_country VARCHAR(255) NOT NULL, invoice_ic VARCHAR(255), invoice_dic VARCHAR(255), shipping VARCHAR(255), shipping_price DECIMAL(18,2) DEFAULT 0 NOT NULL, payment VARCHAR(255), payment_price DECIMAL(18,2) DEFAULT 0 NOT NULL, pack VARCHAR(255), pack_price DECIMAL(18,2) DEFAULT 0 NOT NULL, pack_arra DECIMAL(18,2) DEFAULT 0 NOT NULL, note LONGTEXT, total_price DECIMAL(18,2), status_indent VARCHAR(255) DEFAULT 'inserted', communication_id BIGINT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE equipment_version (id BIGINT, parent_id BIGINT, name VARCHAR(255) NOT NULL, description LONGTEXT, main TINYINT(1) DEFAULT '0' NOT NULL, priority BIGINT DEFAULT 0 NOT NULL, permission VARCHAR(255), request_emails LONGTEXT, indent_emails LONGTEXT, meta_desc VARCHAR(255), meta_kw VARCHAR(255), created_at DATETIME, updated_at DATETIME, slug VARCHAR(255), version BIGINT, PRIMARY KEY(id, version)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE equipment (id BIGINT AUTO_INCREMENT, parent_id BIGINT, name VARCHAR(255) NOT NULL, description LONGTEXT, main TINYINT(1) DEFAULT '0' NOT NULL, priority BIGINT DEFAULT 0 NOT NULL, permission VARCHAR(255), request_emails LONGTEXT, indent_emails LONGTEXT, meta_desc VARCHAR(255), meta_kw VARCHAR(255), created_at DATETIME, updated_at DATETIME, slug VARCHAR(255), version BIGINT, UNIQUE INDEX sluggable_idx (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
ALTER TABLE generic_product ADD FOREIGN KEY (equipment_id) REFERENCES equipment(id) ON DELETE CASCADE;
ALTER TABLE page_version ADD FOREIGN KEY (id) REFERENCES page(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE page ADD FOREIGN KEY (parent_id) REFERENCES page(id) ON DELETE CASCADE;
ALTER TABLE file ADD FOREIGN KEY (product_id) REFERENCES product(id) ON DELETE CASCADE;
ALTER TABLE product_version ADD FOREIGN KEY (id) REFERENCES product(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE product ADD FOREIGN KEY (equipment_id) REFERENCES equipment(id) ON DELETE CASCADE;
ALTER TABLE image ADD FOREIGN KEY (product_id) REFERENCES product(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_group ADD FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_group ADD FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_group_permission ADD FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_group_permission ADD FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_remember_key ADD FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_permission ADD FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_permission ADD FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE;
ALTER TABLE request_product ADD FOREIGN KEY (equipment_id) REFERENCES equipment(id) ON DELETE CASCADE;
ALTER TABLE request_product ADD FOREIGN KEY (communication_id) REFERENCES communication(id) ON DELETE CASCADE;
ALTER TABLE request ADD FOREIGN KEY (equipment_id) REFERENCES equipment(id) ON DELETE CASCADE;
ALTER TABLE request ADD FOREIGN KEY (communication_id) REFERENCES communication(id) ON DELETE CASCADE;
ALTER TABLE communication_message ADD FOREIGN KEY (communication_id) REFERENCES communication(id) ON DELETE CASCADE;
ALTER TABLE equipment_version ADD FOREIGN KEY (id) REFERENCES equipment(id) ON UPDATE CASCADE ON DELETE CASCADE;
