Last active
August 29, 2015 14:27
-
-
Save pedrokoblitz/1f8dde893fbe1b48efa6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SYS | |
DROP TABLE IF EXISTS `types`; | |
CREATE TABLE `types` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`item_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, | |
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`name`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
INSERT INTO `types` (item_name, name) VALUES | |
("image", "resource"), | |
("document", "resource"), | |
("url", "resource"), | |
("embed", "resource"), | |
("work", "content"), | |
("book", "content"), | |
("page", "content"), | |
("article", "content"), | |
("album", "collection"), | |
("folder", "collection"), | |
("menu", "collection"), | |
("category", "term"), | |
("tag", "term"), | |
("vote", "term") | |
("pagseguro", "payment"), | |
("boleto", "payment"), | |
("credito", "payment"), | |
("encomenda", "shipment"), | |
("sedex", "shipment"), | |
("sedex10", "shipment"), | |
("residence", "place"), | |
("public", "place"), | |
("business", "place"), | |
("apartment", "estate"), | |
("house", "estate"), | |
("office", "estate"), | |
("client", "project"), | |
("personal", "project"), | |
("feature", "ticket"), | |
("emergency", "ticket"), | |
("support", "ticket"); | |
DROP TABLE IF EXISTS `metadata`; | |
CREATE TABLE `metadata` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`item_name` enum('content', 'resource') COLLATE utf8_unicode_ci NOT NULL, | |
`item_id` int(10) unsigned NOT NULL, | |
`key` varchar(64) COLLATE utf8_unicode_ci NOT NULL, | |
`value` TINYBLOB NOT NULL, | |
`order` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`item_name`, `item_id`, `key`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `attachments`; | |
CREATE TABLE `attachments` ( | |
`group_name` enum('content', 'collection') COLLATE utf8_unicode_ci NOT NULL, | |
`group_id` int(10) unsigned NOT NULL, | |
`item_name` enum('content', 'collection', 'resource', 'term') COLLATE utf8_unicode_ci NOT NULL, | |
`item_id` int(10) unsigned NOT NULL, | |
`order` int(10) unsigned NOT NULL, | |
UNIQUE(`group_name`, `group_id`, `item_name`, `item_id`), | |
UNIQUE(`group_name`, `group_id`, `order`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `config`; | |
CREATE TABLE `config` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`key` varchar(60) COLLATE utf8_unicode_ci NOT NULL, | |
`value` BLOB NOT NULL, | |
`format` tinyint(1) unsigned NOT NULL DEFAULT 1, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = active, 1 = autoload, 2 = package specific, 3 = ... | |
`created` datetime NOT NULL, | |
`modified` datetime NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`key`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `log`; | |
CREATE TABLE `log` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`user_id` int(10) unsigned NOT NULL, | |
`group_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, | |
`group_id` int(10) unsigned NOT NULL, | |
`action` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`item_name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`item_id` int(10) unsigned DEFAULT NULL, | |
`nonce` varchar(64) COLLATE utf8_unicode_ci NOT NULL, | |
`created` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END SYS | |
-- BEGIN USERS | |
DROP TABLE IF EXISTS `users`; | |
CREATE TABLE `users` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`username` varchar(60) COLLATE utf8_unicode_ci NOT NULL, | |
`email` varchar(60) COLLATE utf8_unicode_ci NOT NULL, | |
`first_name` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`middle_name` varchar(120) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`last_name` varchar(120) COLLATE utf8_unicode_ci DEFAULT NOT NULL, | |
`password` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = inactive, 1 = active | |
`created` datetime NOT NULL, | |
`modified` datetime NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`username`), | |
UNIQUE(`email`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `ownership`; | |
CREATE TABLE `ownership` ( | |
`user_id` int(10) unsigned NOT NULL, | |
`item_name` enum('content', 'collection', 'resource', 'project', 'store') COLLATE utf8_unicode_ci NOT NULL, | |
`item_id` int(10) unsigned NOT NULL, | |
UNIQUE(`item_name`, `item_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `collaborations`; | |
CREATE TABLE `collaborations` ( | |
`user_id` int(10) unsigned NOT NULL, | |
`item_name` enum('content', 'collection', 'project', 'store') COLLATE utf8_unicode_ci NOT NULL, | |
`item_id` int(10) unsigned NOT NULL, | |
UNIQUE(`user_id`, `item_name`, `item_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `user_contacts`; | |
CREATE TABLE `user_contacts` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`user_id` int(10) unsigned NOT NULL, | |
`type` enum('primary_phone', 'secondary_phone', 'cell_phone', 'fax', 'email') COLLATE utf8_unicode_ci NOT NULL, | |
`value` varchar(60) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`value`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `user_facebook_info`; | |
CREATE TABLE `user_facebook_info` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`user_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `user_identifications`; | |
CREATE TABLE `user_identifications` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`user_id` int(10) unsigned NOT NULL, | |
`type` enum('cpf', 'dnh', 'rg', 'cnpj', 'inscricao') COLLATE utf8_unicode_ci NOT NULL, | |
`value` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`value`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `roles`; | |
CREATE TABLE `roles` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`name`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `users_roles`; | |
CREATE TABLE `users_roles` ( | |
`user_id` int(10) unsigned NOT NULL, | |
`role_id` int(10) unsigned NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `tokens`; | |
CREATE TABLE `tokens` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`user_id` int(10) unsigned NOT NULL, | |
`ip` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0.0.0.0', | |
`token` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`type` tinyint(1) unsigned NOT NULL, | |
`created` datetime NOT NULL, | |
`used` datetime NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`token`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END USERS | |
-- USER INTERACTION | |
DROP TABLE IF EXISTS `comments`; | |
CREATE TABLE `comments` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`parent_id` int(10) unsigned NOT NULL DEFAULT 0, | |
`user_id` int(10) unsigned DEFAULT NULL, | |
`name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`email` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`url` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`comment` BLOB NOT NULL, | |
`created` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `commenting`; | |
CREATE TABLE `commenting` ( | |
`comment_id` int(10) unsigned DEFAULT NULL, | |
`user_id` int(10) unsigned DEFAULT NULL, | |
`item_name` enum('content', 'project', 'place') COLLATE utf8_unicode_ci DEFAULT NULL, | |
`item_id` int(10) unsigned DEFAULT NULL, | |
UNIQUE(`comment_id`,`user_id`,`item_name`,`item_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `folksonomy`; | |
CREATE TABLE `folksonomy` ( | |
`term_id` int(10) unsigned DEFAULT NULL, | |
`user_id` int(10) unsigned DEFAULT NULL, | |
`item_name` enum('content', 'collection', 'project', 'resource', 'place') COLLATE utf8_unicode_ci DEFAULT NULL, | |
`item_id` int(10) unsigned DEFAULT NULL, | |
UNIQUE(`term_id`,`user_id`,`item_name`,`item_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END USER INTERACTION | |
-- BEGIN CONTENT | |
DROP TABLE IF EXISTS `translations`; | |
CREATE TABLE `translations` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`language` varchar(5) COLLATE utf8_unicode_ci DEFAULT "pt-br", | |
`item_name` enum('content', 'resource', 'collection', 'term', 'block','type') COLLATE utf8_unicode_ci NOT NULL, | |
`item_id` int(10) unsigned NOT NULL, | |
`slug` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`title` varchar(120) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`subtitle` varchar(120) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`excerpt` TINYBLOB DEFAULT NULL, | |
`description` BLOB DEFAULT NULL, | |
`body` BLOB DEFAULT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE(`language`,`item_name`,`item_id`), | |
UNIQUE(`slug`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `contents`; | |
CREATE TABLE `contents` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`parent_id` int(10) unsigned NOT NULL, | |
`type_id` int(10) unsigned NOT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = trash, 1 = ... | |
`date_pub` datetime DEFAULT NULL, | |
`modified` datetime NOT NULL, | |
`created` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `resources`; | |
CREATE TABLE `resources` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`type_id` int(10) unsigned NOT NULL, | |
`url` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`filepath` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`filename` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`mimetype` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`extension` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`embed` BLOB DEFAULT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = trash, 1 = ... | |
`modified` datetime NOT NULL, | |
`created` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END CONTENT | |
-- BEGIN ATTRIBUTES | |
DROP TABLE IF EXISTS `collections`; | |
CREATE TABLE `collections` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`parent_id` int(10) unsigned NOT NULL DEFAULT 0, | |
`type_id` int(10) unsigned NOT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = trash, 1 = ... | |
`created` datetime NOT NULL, | |
`modified` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `terms`; | |
CREATE TABLE `terms` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`parent_id` int(10) unsigned NOT NULL DEFAULT 0, | |
`type_id` int(10) unsigned NOT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = trash, 1 = ... | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END ATTRIBUTES | |
-- BEGIN SITE BUILDING | |
DROP TABLE IF EXISTS `areas`; | |
CREATE TABLE `areas` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = off, 1 = on | |
PRIMARY KEY (`id`), | |
UNIQUE(`name`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `blocks`; | |
CREATE TABLE `blocks` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`area_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END SITE BUILDING | |
-- PROJECT MANAGEMENT | |
DROP TABLE IF EXISTS `projects`; | |
CREATE TABLE `projects` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`title` varchar(120) NOT NULL, | |
`description` TINYBLOB NOT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 1, -- 0 = trash, 1 = ... | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `tickets`; | |
CREATE TABLE `tickets` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`dev_id` int(10) unsigned DEFAULT NULL, | |
`project_id` int(10) unsigned NOT NULL, | |
`problem_url` varchar(120) COLLATE utf8_unicode_ci DEFAULT NULL, | |
`description` BLOB NOT NULL, | |
`activity` tinyint(1) unsigned NOT NULL DEFAULT 2, /* 0 = deleted, 1 = unassigned, 2 = open, 3 = active, 4 = closed, 5 = charged */ | |
`created` datetime NOT NULL, | |
`modified` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `ticket_time_tracking`; | |
CREATE TABLE `ticket_time_tracking` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`ticket_id` int(10) unsigned NOT NULL, | |
`start` datetime NOT NULL, | |
`stop` datetime DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `invoices`; | |
CREATE TABLE `invoices` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`project_id` int(10) unsigned NOT NULL, | |
`hours` DECIMAL(10,2) unsigned NOT NULL, | |
`rate` DECIMAL(10,2) NOT NULL, | |
`total` DECIMAL(10,2) NOT NULL, | |
`activity` DECIMAL(10,2) NOT NULL DEFAULT 1, -- 0 = deleted, 1 = active, 2 = sent, 3 = contested, 4 = paid | |
`created` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END PROJECT MANAGEMENT | |
-- CALENDAR | |
DROP TABLE IF EXISTS `calendar`; | |
CREATE TABLE `calendar` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`entry` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `events`; | |
CREATE TABLE `events` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`place_id` int(10) unsigned NOT NULL, | |
`start` datetime NOT NULL, | |
`end` datetime NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END CALENDAR | |
-- E-COMMERCE | |
DROP TABLE IF EXISTS `stores`; | |
CREATE TABLE `stores` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`seller_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `products`; | |
CREATE TABLE `products` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`store_id` int(10) unsigned NOT NULL, | |
`in_stock` int(10) unsigned NOT NULL DEFAULT 0, | |
`price` decimal(10,2) unsigned NOT NULL, | |
`weigth` decimal(10,2) unsigned DEFAULT NULL, | |
`height` decimal(10,2) unsigned DEFAULT NULL, | |
`width` decimal(10,2) unsigned DEFAULT NULL, | |
`depth` decimal(10,2) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `product_metadata`; | |
CREATE TABLE `product_metadata` ( | |
`item_id` int(10) unsigned NOT NULL, | |
`key` varchar(32) COLLATE utf8_unicode_ci NOT NULL, | |
`value` varchar(120) COLLATE utf8_unicode_ci NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `cart`; | |
CREATE TABLE `cart` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`customer_id` int(10) unsigned NOT NULL, | |
`product_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `orders`; | |
CREATE TABLE `orders` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`customer_id` int(10) unsigned NOT NULL, | |
`payment_method_id` int(10) unsigned NOT NULL, | |
`shipping_method_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `order_items`; | |
CREATE TABLE `order_items` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`store_id` int(10) unsigned NOT NULL, | |
`order_id` int(10) unsigned NOT NULL, | |
`product_id` int(10) unsigned NOT NULL, | |
`quantity` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `order_item_metadata`; | |
CREATE TABLE `order_item_metadata` ( | |
`item_id` int(10) unsigned NOT NULL, | |
`key` varchar(32) COLLATE utf8_unicode_ci NOT NULL, | |
`value` varchar(120) COLLATE utf8_unicode_ci NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `payments`; | |
CREATE TABLE `payments` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`order_id` int(10) unsigned NOT NULL, | |
`type_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `shipments`; | |
CREATE TABLE `shipments` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`order_id` int(10) unsigned NOT NULL, | |
`type_id` int(10) unsigned NOT NULL, | |
`tracking_ref` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END E-COMMERCE | |
-- GEOLOCATION | |
DROP TABLE IF EXISTS `places`; | |
CREATE TABLE `places` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`type_id` int(10) unsigned NOT NULL, | |
`address_id` int(10) unsigned DEFAULT NULL, | |
`description` BLOB NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `addresses`; | |
CREATE TABLE `addresses` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`street` varchar(64) COLLATE utf8_unicode_ci NOT NULL, | |
`number` varchar(10) COLLATE utf8_unicode_ci NOT NULL, | |
`address` varchar(64) COLLATE utf8_unicode_ci NOT NULL, | |
`district_id` int(10) unsigned DEFAULT NULL, | |
`city_id` int(10) unsigned DEFAULT NULL, | |
`coordinate_id` int(10) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `districts`; | |
CREATE TABLE `districts` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`city_id` int(10) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `cities`; | |
CREATE TABLE `cities` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`country_id` int(10) unsigned DEFAULT NULL, | |
`province_id` int(10) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `provinces`; | |
CREATE TABLE `provinces` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`code` varchar(5) COLLATE utf8_unicode_ci NOT NULL, | |
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
`region` varchar(5) COLLATE utf8_unicode_ci NOT NULL, | |
`country_id` int(10) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `countries`; | |
CREATE TABLE `countries` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`code` varchar(5) COLLATE utf8_unicode_ci NOT NULL, | |
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
DROP TABLE IF EXISTS `coordinates`; | |
CREATE TABLE `coordinates` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`lat` decimal(10,2) unsigned NOT NULL DEFAULT 0.00, | |
`lon` decimal(10,2) unsigned NOT NULL DEFAULT 0.00, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END GEOLOCATION | |
-- REAL ESTATE | |
DROP TABLE IF EXISTS `estates`; | |
CREATE TABLE `estates` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`place_id` int(10) unsigned NOT NULL, | |
`type_id` int(10) unsigned NOT NULL, | |
`area` int(10) unsigned NOT NULL DEFAULT 0, | |
`rooms` int(10) unsigned NOT NULL DEFAULT 0, | |
`suites` int(10) unsigned NOT NULL DEFAULT 0, | |
`parking_spots` int(10) unsigned NOT NULL DEFAULT 0, | |
`price` decimal(10,2) unsigned NOT NULL DEFAULT 0.00, | |
`charges` decimal(10,2) unsigned NOT NULL DEFAULT 0.00, | |
`taxes` decimal(10,2) unsigned NOT NULL DEFAULT 0.00, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- END REAL ESTATE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment