Browse files

database beta

  • Loading branch information...
1 parent 120db6d commit fa436485ed111c2a80e88a8c90e2498488ac1be6 @tegila tegila committed Jul 28, 2010
Showing with 147 additions and 100 deletions.
  1. +147 −100 resources/db/mysql/create-database.sql
View
247 resources/db/mysql/create-database.sql
@@ -1,31 +1,92 @@
-SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
-SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
-SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
-
DROP SCHEMA IF EXISTS `cproject` ;
CREATE SCHEMA IF NOT EXISTS `cproject` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
-USE `cproject`;
+USE `cproject` ;
-- -----------------------------------------------------
--- Table `cproject`.`auth_group`
+-- Table `cproject`.`app_content_type`
-- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `cproject`.`auth_group` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `name` VARCHAR(80) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+CREATE TABLE IF NOT EXISTS `cproject`.`app_content_type` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `name` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `app_label` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `model` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
-- -----------------------------------------------------
--- Table `cproject`.`app_content_type`
+-- Table `cproject`.`auth_user`
-- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `cproject`.`app_content_type` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `name` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `app_label` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `model` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+CREATE TABLE IF NOT EXISTS `cproject`.`auth_user` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `username` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `first_name` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `last_name` VARCHAR(80) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `email` VARCHAR(75) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `password` VARCHAR(128) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `is_staff` TINYINT(4) NOT NULL ,
+ `is_active` TINYINT(4) NOT NULL COMMENT ' ' ,
+ `is_superuser` TINYINT(4) NOT NULL ,
+ `last_login` DATETIME NOT NULL ,
+ `date_joined` DATETIME NOT NULL ,
+ PRIMARY KEY (`id`) )
+ENGINE = InnoDB
+AUTO_INCREMENT = 2
+DEFAULT CHARACTER SET = utf8
+COLLATE = utf8_unicode_ci;
+
+
+-- -----------------------------------------------------
+-- Table `cproject`.`app_log`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `cproject`.`app_log` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `auth_user_id` INT(11) NOT NULL ,
+ `app_content_type_id` INT(11) NULL DEFAULT NULL ,
+ `action_time` DATETIME NOT NULL ,
+ `object_id` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
+ `object_repr` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `action_flag` SMALLINT(5) UNSIGNED NOT NULL ,
+ `change_message` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ PRIMARY KEY (`id`) ,
+ INDEX `fk_app_log_auth_user1` (`auth_user_id` ASC) ,
+ INDEX `fk_app_log_app_content_type1` (`app_content_type_id` ASC) ,
+ CONSTRAINT `fk_app_log_app_content_type1`
+ FOREIGN KEY (`app_content_type_id` )
+ REFERENCES `cproject`.`app_content_type` (`id` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_app_log_auth_user1`
+ FOREIGN KEY (`auth_user_id` )
+ REFERENCES `cproject`.`auth_user` (`id` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8
+COLLATE = utf8_unicode_ci;
+
+
+-- -----------------------------------------------------
+-- Table `cproject`.`app_session`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `cproject`.`app_session` (
+ `session_key` VARCHAR(40) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `session_data` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
+ `expire_data` DATETIME NOT NULL ,
+ PRIMARY KEY (`session_key`) )
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8
+COLLATE = utf8_unicode_ci;
+
+
+-- -----------------------------------------------------
+-- Table `cproject`.`auth_group`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `cproject`.`auth_group` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `name` VARCHAR(80) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
@@ -36,8 +97,8 @@ COLLATE = utf8_unicode_ci;
-- Table `cproject`.`auth_permission`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cproject`.`auth_permission` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `app_content_type_id` INT NOT NULL ,
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `app_content_type_id` INT(11) NOT NULL ,
`name` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
`codename` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
PRIMARY KEY (`id`) ,
@@ -56,141 +117,127 @@ COLLATE = utf8_unicode_ci;
-- Table `cproject`.`auth_group_permissions`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cproject`.`auth_group_permissions` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `auth_permission_id` INT NOT NULL ,
- `auth_group_id` INT NOT NULL ,
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `auth_permission_id` INT(11) NOT NULL ,
+ `auth_group_id` INT(11) NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_auth_group_permissions_auth_permission1` (`auth_permission_id` ASC) ,
INDEX `fk_auth_group_permissions_auth_group1` (`auth_group_id` ASC) ,
- CONSTRAINT `fk_auth_group_permissions_auth_permission1`
- FOREIGN KEY (`auth_permission_id` )
- REFERENCES `cproject`.`auth_permission` (`id` )
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
CONSTRAINT `fk_auth_group_permissions_auth_group1`
FOREIGN KEY (`auth_group_id` )
REFERENCES `cproject`.`auth_group` (`id` )
ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_auth_group_permissions_auth_permission1`
+ FOREIGN KEY (`auth_permission_id` )
+ REFERENCES `cproject`.`auth_permission` (`id` )
+ ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
-COLLATE = utf8_unicode_ci
-PACK_KEYS = DEFAULT;
-
-
--- -----------------------------------------------------
--- Table `cproject`.`auth_user`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `cproject`.`auth_user` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `username` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `first_name` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `last_name` VARCHAR(80) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `email` VARCHAR(75) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `password` VARCHAR(128) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `is_staff` TINYINT NOT NULL ,
- `is_active` TINYINT NOT NULL COMMENT ' ' ,
- `is_superuser` TINYINT NOT NULL ,
- `last_login` DATETIME NULL ,
- `date_joined` DATETIME NULL ,
- PRIMARY KEY (`id`) )
-ENGINE = InnoDB
-DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
-INSERT INTO `cproject`.`auth_user` (username,first_name,last_name,email,password,is_staff,is_active,is_superuser) VALUES('admin', 'Administrator', 'Empty', 'cproject@cenobites.com.br', '1q2w3e', 1, 1, 1);
-- -----------------------------------------------------
-- Table `cproject`.`auth_user_groups`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cproject`.`auth_user_groups` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `auth_user_id` INT NOT NULL ,
- `auth_group_id` INT NOT NULL ,
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `auth_user_id` INT(11) NOT NULL ,
+ `auth_group_id` INT(11) NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_auth_user_groups_auth_user1` (`auth_user_id` ASC) ,
INDEX `fk_auth_user_groups_auth_group1` (`auth_group_id` ASC) ,
- CONSTRAINT `fk_auth_user_groups_auth_user1`
- FOREIGN KEY (`auth_user_id` )
- REFERENCES `cproject`.`auth_user` (`id` )
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
CONSTRAINT `fk_auth_user_groups_auth_group1`
FOREIGN KEY (`auth_group_id` )
REFERENCES `cproject`.`auth_group` (`id` )
ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_auth_user_groups_auth_user1`
+ FOREIGN KEY (`auth_user_id` )
+ REFERENCES `cproject`.`auth_user` (`id` )
+ ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
-- -----------------------------------------------------
--- Table `cproject`.`app_session`
+-- Table `cproject`.`auth_user_user_permissions`
-- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `cproject`.`app_session` (
- `session_key` VARCHAR(40) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `session_data` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `expire_data` DATETIME NOT NULL ,
- PRIMARY KEY (`session_key`) )
+CREATE TABLE IF NOT EXISTS `cproject`.`auth_user_user_permissions` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT ,
+ `auth_user_id` INT(11) NOT NULL ,
+ `auth_permission_id` INT(11) NOT NULL ,
+ PRIMARY KEY (`id`) ,
+ INDEX `fk_auth_user_user_permissions_auth_user1` (`auth_user_id` ASC) ,
+ INDEX `fk_auth_user_user_permissions_auth_permission1` (`auth_permission_id` ASC) ,
+ CONSTRAINT `fk_auth_user_user_permissions_auth_permission1`
+ FOREIGN KEY (`auth_permission_id` )
+ REFERENCES `cproject`.`auth_permission` (`id` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_auth_user_user_permissions_auth_user1`
+ FOREIGN KEY (`auth_user_id` )
+ REFERENCES `cproject`.`auth_user` (`id` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
-- -----------------------------------------------------
--- Table `cproject`.`app_log`
+-- Table `cproject`.`atos`
-- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `cproject`.`app_log` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `auth_user_id` INT NOT NULL ,
- `app_content_type_id` INT NULL ,
- `action_time` DATETIME NOT NULL ,
- `object_id` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL ,
- `object_repr` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- `action_flag` SMALLINT(5) UNSIGNED NOT NULL ,
- `change_message` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
- PRIMARY KEY (`id`) ,
- INDEX `fk_app_log_auth_user1` (`auth_user_id` ASC) ,
- INDEX `fk_app_log_app_content_type1` (`app_content_type_id` ASC) ,
- CONSTRAINT `fk_app_log_auth_user1`
+CREATE TABLE IF NOT EXISTS `cproject`.`atos` (
+ `id` INT NOT NULL ,
+ `nome` VARCHAR(45) NULL ,
+ `valor` DECIMAL NULL ,
+ PRIMARY KEY (`id`) )
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `cproject`.`cupom`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `cproject`.`cupom` (
+ `id` INT NOT NULL ,
+ `valor` VARCHAR(45) NULL ,
+ `datetime` TIMESTAMP NULL DEFAULT now() ,
+ `auth_user_id` INT(11) NOT NULL ,
+ PRIMARY KEY (`id`, `auth_user_id`) ,
+ INDEX `fk_cupom_auth_user1` (`auth_user_id` ASC) ,
+ CONSTRAINT `fk_cupom_auth_user1`
FOREIGN KEY (`auth_user_id` )
REFERENCES `cproject`.`auth_user` (`id` )
ON DELETE NO ACTION
- ON UPDATE NO ACTION,
- CONSTRAINT `fk_app_log_app_content_type1`
- FOREIGN KEY (`app_content_type_id` )
- REFERENCES `cproject`.`app_content_type` (`id` )
- ON DELETE NO ACTION
ON UPDATE NO ACTION)
-ENGINE = InnoDB
-DEFAULT CHARACTER SET = utf8
-COLLATE = utf8_unicode_ci;
+ENGINE = InnoDB;
-- -----------------------------------------------------
--- Table `cproject`.`auth_user_user_permissions`
+-- Table `cproject`.`atos_cupom`
-- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `cproject`.`auth_user_user_permissions` (
- `id` INT NOT NULL AUTO_INCREMENT ,
- `auth_user_id` INT NOT NULL ,
- `auth_permission_id` INT NOT NULL ,
+CREATE TABLE IF NOT EXISTS `cproject`.`atos_cupom` (
+ `id` INT NOT NULL ,
+ `atos_id` INT NOT NULL ,
+ `cupom_id` INT NOT NULL ,
PRIMARY KEY (`id`) ,
- INDEX `fk_auth_user_user_permissions_auth_user1` (`auth_user_id` ASC) ,
- INDEX `fk_auth_user_user_permissions_auth_permission1` (`auth_permission_id` ASC) ,
- CONSTRAINT `fk_auth_user_user_permissions_auth_user1`
- FOREIGN KEY (`auth_user_id` )
- REFERENCES `cproject`.`auth_user` (`id` )
+ INDEX `fk_cupom_atos_atos1` (`atos_id` ASC) ,
+ INDEX `fk_cupom_atos_cupom1` (`cupom_id` ASC) ,
+ CONSTRAINT `fk_cupom_atos_atos1`
+ FOREIGN KEY (`atos_id` )
+ REFERENCES `cproject`.`atos` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
- CONSTRAINT `fk_auth_user_user_permissions_auth_permission1`
- FOREIGN KEY (`auth_permission_id` )
- REFERENCES `cproject`.`auth_permission` (`id` )
+ CONSTRAINT `fk_cupom_atos_cupom1`
+ FOREIGN KEY (`cupom_id` )
+ REFERENCES `cproject`.`cupom` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
-ENGINE = InnoDB
-DEFAULT CHARACTER SET = utf8
-COLLATE = utf8_unicode_ci;
+ENGINE = InnoDB;

0 comments on commit fa43648

Please sign in to comment.