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';

CREATE SCHEMA IF NOT EXISTS `violet-viettel` ;
SHOW WARNINGS;
USE `violet-viettel`;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tbladmin`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tbladmin` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tbladmin` (
  `admin_id` INT NOT NULL AUTO_INCREMENT ,
  `login_name` VARCHAR(45) NOT NULL ,
  `passwd` VARCHAR(65) NOT NULL ,
  `full_name` VARCHAR(45) NOT NULL ,
  `email` VARCHAR(45) NULL ,
  `phone` VARCHAR(15) NULL ,
  `created_time` DATETIME NULL ,
  `updated_time` DATETIME NULL ,
  `author` INT NULL ,
  PRIMARY KEY (`admin_id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tbladminrole`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tbladminrole` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tbladminrole` (
  `role_id` INT NOT NULL AUTO_INCREMENT ,
  `role_name` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`role_id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tblcollaborator`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tblcollaborator` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tblcollaborator` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `full_name` VARCHAR(45) NOT NULL ,
  `login_name` VARCHAR(45) NOT NULL ,
  `cellphone` VARCHAR(15) NOT NULL ,
  `passwd` VARCHAR(65) NOT NULL ,
  `activated` TINYINT NOT NULL DEFAULT 1 ,
  `created_time` DATETIME NULL ,
  `updated_time` DATETIME NULL ,
  `author` INT NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tbluser`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tbluser` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tbluser` (
  `us_id` INT NOT NULL ,
  `cellphone` VARCHAR(15) NOT NULL ,
  `collaborator` INT NULL ,
  `acc_balanced` BIGINT NOT NULL DEFAULT 0 ,
  `expire_date` DATE NOT NULL ,
  `created_time` DATETIME NOT NULL ,
  `updated_time` DATETIME NULL ,
  PRIMARY KEY (`us_id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tblsmstemplate`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tblsmstemplate` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tblsmstemplate` (
  `sms_id` INT NOT NULL AUTO_INCREMENT ,
  `sms_content` VARCHAR(255) NOT NULL ,
  `sms_reply` VARCHAR(255) NULL ,
  `reponse_url` VARCHAR(255) NULL ,
  PRIMARY KEY (`sms_id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tblwebservice`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tblwebservice` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tblwebservice` (
  `service_id` INT NOT NULL AUTO_INCREMENT ,
  `service_name` VARCHAR(45) NOT NULL ,
  `address` VARCHAR(255) NULL ,
  `uri` VARCHAR(255) NULL ,
  PRIMARY KEY (`service_id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tblsmslog`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tblsmslog` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tblsmslog` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `sender` VARCHAR(255) NOT NULL ,
  `us_id` INT NULL ,
  `mobody` VARCHAR(255) NULL ,
  `mtbody` VARCHAR(255) NULL ,
  `created_time` DATETIME NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tbluserpaylog`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tbluserpaylog` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tbluserpaylog` (
  `id` BIGINT NOT NULL AUTO_INCREMENT ,
  `us_id` INT NOT NULL ,
  `pay_type` TINYINT NOT NULL DEFAULT 1 COMMENT '0:promotion;1:SMS;2:card' ,
  `pay_time` DATETIME NOT NULL ,
  `pay_value` INT NOT NULL DEFAULT 0 ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `violet-viettel`.`tblcardlog`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `violet-viettel`.`tblcardlog` ;

SHOW WARNINGS;
CREATE  TABLE IF NOT EXISTS `violet-viettel`.`tblcardlog` (
  `id` INT NOT NULL ,
  `sender` VARCHAR(255) NULL ,
  `us_id` INT NULL ,
  `pin_code` VARCHAR(45) NULL ,
  `serial_num` VARCHAR(45) NULL ,
  `card_value` INT NULL ,
  `created_time` DATETIME NOT NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;

SHOW WARNINGS;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
