-- Adminer 4.3.1 MySQL dump

SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

CREATE TABLE `coin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(10) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `coin` (`id`, `code`, `name`, `description`, `status`) VALUES
(1,	'USD',	'Dolares',	'Dolares',	1),
(2,	'BTC',	'Bitcoin',	'Bitcoin',	1);

CREATE TABLE `group` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `description` text,
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `group` (`id`, `name`, `description`, `status`) VALUES
(1,	'Grupo 1',	'Grupo 1',	1),
(2,	'Grupo 2',	'Grupo 2',	1);

CREATE TABLE `group_admin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `description` text,
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `group_admin` (`id`, `name`, `description`, `status`) VALUES
(1,	'Super Administrador',	'Posee todos los permisos',	1);

CREATE TABLE `investment_plans` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_admin_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `description_rules` text NOT NULL,
  `investment_time_day` int(11) NOT NULL DEFAULT '1' COMMENT 'time in the money will be used for the investment',
  `profit_rate_min` decimal(12,2) NOT NULL DEFAULT '0.00',
  `profit_rate_max` decimal(12,2) NOT NULL DEFAULT '0.00',
  `amount_investment_min` decimal(12,2) NOT NULL DEFAULT '0.00',
  `amount_investment_max` decimal(12,2) NOT NULL DEFAULT '0.00',
  `coin_id` int(11) NOT NULL,
  `date_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `date_update` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_published` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_unpublished` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `status` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_admin_id` (`user_admin_id`),
  KEY `coin_id` (`coin_id`),
  CONSTRAINT `investment_plans_ibfk_1` FOREIGN KEY (`user_admin_id`) REFERENCES `user_admin` (`id`),
  CONSTRAINT `investment_plans_ibfk_2` FOREIGN KEY (`coin_id`) REFERENCES `coin` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `investment_plans` (`id`, `user_admin_id`, `name`, `description`, `description_rules`, `investment_time_day`, `profit_rate_min`, `profit_rate_max`, `amount_investment_min`, `amount_investment_max`, `coin_id`, `date_create`, `date_update`, `date_published`, `date_unpublished`, `status`) VALUES
(1,	1,	'Inicial',	'Inicio',	'21 días - 10.5% (0.5% diario)',	1,	0.50,	0.50,	100.00,	500.00,	1,	'2018-01-29 10:54:04',	'2018-01-29 10:54:04',	'2018-01-29 10:54:04',	'2018-01-29 10:54:04',	1);

CREATE TABLE `investment_plans_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_user` int(11) NOT NULL,
  `id_operation` int(11) NOT NULL,
  `investment_plans_id` int(11) NOT NULL,
  `coin_id` int(11) NOT NULL,
  `date_create` datetime NOT NULL,
  `date_update` datetime NOT NULL,
  `date_init` datetime NOT NULL,
  `date_end` datetime NOT NULL,
  `investment_time_day` int(11) NOT NULL DEFAULT '1',
  `profit_rate_min` decimal(12,2) NOT NULL DEFAULT '0.00',
  `profit_rate_max` decimal(12,2) NOT NULL DEFAULT '0.00',
  `amount_investment_min` decimal(12,2) NOT NULL DEFAULT '0.00',
  `amount_investment_max` decimal(12,2) NOT NULL DEFAULT '0.00',
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `id_user` (`id_user`),
  KEY `investment_plans_id` (`investment_plans_id`),
  KEY `coin_id` (`coin_id`),
  KEY `id_operation` (`id_operation`),
  CONSTRAINT `investment_plans_user_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id`),
  CONSTRAINT `investment_plans_user_ibfk_2` FOREIGN KEY (`investment_plans_id`) REFERENCES `investment_plans` (`id`),
  CONSTRAINT `investment_plans_user_ibfk_3` FOREIGN KEY (`coin_id`) REFERENCES `coin` (`id`),
  CONSTRAINT `investment_plans_user_ibfk_4` FOREIGN KEY (`id_operation`) REFERENCES `operation` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `investment_plans_user` (`id`, `id_user`, `id_operation`, `investment_plans_id`, `coin_id`, `date_create`, `date_update`, `date_init`, `date_end`, `investment_time_day`, `profit_rate_min`, `profit_rate_max`, `amount_investment_min`, `amount_investment_max`, `status`) VALUES
(3,	1,	1,	1,	1,	'2018-01-29 06:56:51',	'2018-01-29 06:56:51',	'2018-01-29 06:56:51',	'2018-01-29 06:56:51',	1,	0.00,	0.00,	0.00,	0.00,	1);

CREATE TABLE `migration` (
  `version` varchar(180) NOT NULL,
  `apply_time` int(11) DEFAULT NULL,
  PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `migration` (`version`, `apply_time`) VALUES
('m000000_000000_base',	1513217026);

CREATE TABLE `operation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  `date_create` datetime NOT NULL,
  `date_update` datetime NOT NULL,
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `operation_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `operation` (`id`, `user_id`, `name`, `description`, `date_create`, `date_update`, `status`) VALUES
(1,	1,	'Solicitud de nuevo plan de usuario',	'',	'2018-01-29 06:56:45',	'2018-01-29 06:56:45',	1);

CREATE TABLE `profit_percentage` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `idgroup` int(11) NOT NULL,
  `investment_plans_user_id` int(11) NOT NULL,
  `year` int(11) NOT NULL,
  `month` int(11) NOT NULL,
  `day` int(11) NOT NULL,
  `percentage` decimal(10,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `update_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `description` text,
  `status` int(11) NOT NULL DEFAULT '1',
  `iduser_admin` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idgroup_year_month` (`idgroup`,`year`,`month`),
  KEY `iduser_admin` (`iduser_admin`),
  KEY `investment_plans_user_id` (`investment_plans_user_id`),
  CONSTRAINT `profit_percentage_ibfk_1` FOREIGN KEY (`idgroup`) REFERENCES `group` (`id`),
  CONSTRAINT `profit_percentage_ibfk_2` FOREIGN KEY (`iduser_admin`) REFERENCES `user_admin` (`id`),
  CONSTRAINT `profit_percentage_ibfk_3` FOREIGN KEY (`investment_plans_user_id`) REFERENCES `investment_plans_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `profit_percentage` (`id`, `idgroup`, `investment_plans_user_id`, `year`, `month`, `day`, `percentage`, `created_at`, `update_at`, `description`, `status`, `iduser_admin`) VALUES
(1,	1,	3,	2017,	12,	1,	8.00,	'2018-01-29 10:58:55',	'2017-12-19 23:19:36',	'Ganancia del 8%',	1,	1),
(2,	1,	3,	2018,	1,	1,	8.00,	'2018-01-29 10:59:00',	'2017-12-20 06:28:57',	'',	1,	1);

CREATE TABLE `user_pount` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `iduser` int(11) NOT NULL COMMENT 'user associated',
  `coin_id` int(11) NOT NULL,
  `coin_code` varchar(10) NOT NULL,
  `idprofit_percentage` int(11) DEFAULT NULL,
  `operation_id` int(11) DEFAULT NULL,
  `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type of operation [1 = Deposit, 2 = Gain, 3 = Retirement ]',
  `credit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'increased amount',
  `debit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'decrease amount',
  `balance` decimal(12,2) NOT NULL DEFAULT '0.00',
  `rate` int(11) NOT NULL DEFAULT '0' COMMENT 'percentage of increased',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'date created',
  `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'date update',
  `approved_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'date approved by user admin',
  `executed_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'date exececuted by user admin',
  `iduser_admin` int(11) NOT NULL COMMENT 'user who approves',
  `status` int(11) NOT NULL DEFAULT '1',
  `description` varchar(500) DEFAULT NULL,
  `change_history` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `iduser_idprofit_percentage` (`iduser`,`idprofit_percentage`),
  KEY `idprofit_percentage` (`idprofit_percentage`),
  KEY `coin_id` (`coin_id`),
  KEY `coin_code` (`coin_code`),
  KEY `operation_id` (`operation_id`),
  CONSTRAINT `user_pount_ibfk_1` FOREIGN KEY (`iduser`) REFERENCES `user` (`id`),
  CONSTRAINT `user_pount_ibfk_2` FOREIGN KEY (`idprofit_percentage`) REFERENCES `profit_percentage` (`id`),
  CONSTRAINT `user_pount_ibfk_3` FOREIGN KEY (`coin_id`) REFERENCES `coin` (`id`),
  CONSTRAINT `user_pount_ibfk_4` FOREIGN KEY (`coin_code`) REFERENCES `coin` (`code`),
  CONSTRAINT `user_pount_ibfk_5` FOREIGN KEY (`operation_id`) REFERENCES `operation` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `user_pount` (`id`, `iduser`, `coin_id`, `coin_code`, `idprofit_percentage`, `operation_id`, `type`, `credit`, `debit`, `balance`, `rate`, `created_at`, `updated_at`, `approved_at`, `executed_at`, `iduser_admin`, `status`, `description`, `change_history`) VALUES
(8,	2,	1,	'USD',	NULL,	NULL,	0,	10.00,	0.00,	20.00,	0,	'2018-01-29 00:25:44',	'2017-12-17 10:37:38',	'2017-12-17 10:37:38',	'2017-12-17 10:37:38',	1,	1,	'Crear Credito',	NULL),
(9,	2,	1,	'USD',	NULL,	NULL,	0,	5.00,	0.00,	25.00,	0,	'2018-01-29 00:25:44',	'2017-12-17 10:38:57',	'2017-12-17 10:38:57',	'2017-12-17 10:38:57',	1,	1,	'Crear Credito',	NULL),
(10,	1,	1,	'USD',	NULL,	NULL,	0,	100.00,	0.00,	100.00,	0,	'2018-01-29 00:25:44',	'2017-12-17 10:39:08',	'2017-12-17 10:39:08',	'2017-12-17 10:39:08',	1,	1,	'Crear Credito',	NULL),
(11,	1,	1,	'USD',	NULL,	NULL,	0,	10.00,	0.00,	110.00,	0,	'2018-01-29 00:25:44',	'2017-12-17 10:39:51',	'2017-12-17 10:39:51',	'2017-12-17 10:39:51',	1,	1,	'Crear Credito',	NULL),
(12,	1,	1,	'USD',	NULL,	NULL,	0,	100.00,	0.00,	210.00,	0,	'2018-01-29 00:25:44',	'2017-12-17 11:04:47',	'2017-12-17 11:04:47',	'2017-12-17 11:04:47',	1,	1,	'Crear Credito',	NULL),
(13,	2,	1,	'USD',	NULL,	NULL,	0,	0.00,	10.00,	15.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:35:36',	'2017-12-19 21:35:36',	'2017-12-19 21:35:36',	1,	1,	'Crear Debito',	NULL),
(14,	1,	1,	'USD',	NULL,	NULL,	0,	0.00,	10.00,	200.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:36:33',	'2017-12-19 21:36:33',	'2017-12-19 21:36:33',	1,	1,	'Crear Debito',	NULL),
(15,	1,	1,	'USD',	NULL,	NULL,	0,	0.00,	10.00,	190.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:36:53',	'2017-12-19 21:36:53',	'2017-12-19 21:36:53',	1,	1,	'Crear Debito',	NULL),
(16,	2,	1,	'USD',	NULL,	NULL,	0,	100.00,	0.00,	115.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:37:11',	'2017-12-19 21:37:11',	'2017-12-19 21:37:11',	1,	1,	'Crear Credito',	NULL),
(17,	1,	1,	'USD',	NULL,	NULL,	0,	0.00,	10.00,	180.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:39:03',	'2017-12-19 21:39:03',	'2017-12-19 21:39:03',	1,	1,	'Crear Debito',	NULL),
(18,	2,	1,	'USD',	NULL,	NULL,	0,	10.00,	0.00,	125.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:39:38',	'2017-12-19 21:39:38',	'2017-12-19 21:39:38',	1,	1,	'Crear Credito',	NULL),
(19,	1,	1,	'USD',	NULL,	NULL,	0,	0.00,	5.00,	175.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 21:39:49',	'2017-12-19 21:39:49',	'2017-12-19 21:39:49',	1,	1,	'Crear Debito',	NULL),
(20,	1,	1,	'USD',	NULL,	NULL,	0,	10.00,	0.00,	185.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 23:31:58',	'2017-12-19 23:31:58',	'2017-12-19 23:31:58',	1,	1,	'Crear Credito',	NULL),
(21,	1,	1,	'USD',	NULL,	NULL,	0,	0.00,	5.00,	180.00,	0,	'2018-01-29 00:25:44',	'2017-12-19 23:32:15',	'2017-12-19 23:32:15',	'2017-12-19 23:32:15',	1,	1,	'Crear Debito',	NULL),
(26,	1,	1,	'USD',	1,	NULL,	0,	14.40,	0.00,	194.40,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	1,	1,	'',	NULL),
(27,	2,	1,	'USD',	1,	NULL,	0,	10.00,	0.00,	135.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	1,	1,	'',	NULL),
(28,	3,	1,	'USD',	1,	NULL,	0,	0.00,	0.00,	0.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	1,	1,	'',	NULL),
(29,	4,	1,	'USD',	1,	NULL,	0,	0.00,	0.00,	0.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	1,	1,	'',	NULL),
(30,	5,	1,	'USD',	1,	NULL,	1,	100.00,	0.00,	100.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	'2017-12-20 06:27:53',	1,	1,	'',	NULL),
(31,	1,	1,	'USD',	2,	NULL,	0,	15.55,	0.00,	209.95,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	1,	1,	'',	NULL),
(32,	2,	1,	'USD',	2,	NULL,	0,	10.80,	0.00,	145.80,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	1,	1,	'',	NULL),
(33,	3,	1,	'USD',	2,	NULL,	0,	0.00,	0.00,	0.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	1,	1,	'',	NULL),
(34,	4,	1,	'USD',	2,	NULL,	0,	0.00,	0.00,	0.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	1,	1,	'',	NULL),
(35,	5,	1,	'USD',	2,	NULL,	2,	10.00,	0.00,	110.00,	8,	'2018-01-29 00:25:44',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	'2017-12-20 06:29:34',	1,	1,	'',	NULL);

-- 2018-02-02 02:09:42
