-- MySQL dump 10.13  Distrib 5.7.24, for Linux (x86_64)
--
-- Host: 185.166.215.170    Database: tasks
-- ------------------------------------------------------
-- Server version	5.7.23

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `tasks`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `tasks` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_spanish_ci */;

USE `tasks`;

--
-- Temporary table structure for view `capturing_first`
--

DROP TABLE IF EXISTS `capturing_first`;
/*!50001 DROP VIEW IF EXISTS `capturing_first`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `capturing_first` AS SELECT 
 1 AS `uuid`,
 1 AS `fk_uuid_exploring`,
 1 AS `write_time`,
 1 AS `status`,
 1 AS `ad_url`,
 1 AS `row_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `capturing_last`
--

DROP TABLE IF EXISTS `capturing_last`;
/*!50001 DROP VIEW IF EXISTS `capturing_last`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `capturing_last` AS SELECT 
 1 AS `uuid`,
 1 AS `fk_uuid_exploring`,
 1 AS `write_time`,
 1 AS `status`,
 1 AS `ad_url`,
 1 AS `row_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `capturing_tasks_logs`
--

DROP TABLE IF EXISTS `capturing_tasks_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `capturing_tasks_logs` (
  `uuid` varchar(50) COLLATE latin1_spanish_ci NOT NULL,
  `fk_uuid_exploring` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
  `write_time` datetime NOT NULL,
  `status` varchar(255) COLLATE latin1_spanish_ci NOT NULL,
  `ad_url` varchar(255) COLLATE latin1_spanish_ci NOT NULL,
  `row_id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`row_id`),
  KEY `uuid_index` (`uuid`),
  KEY `write_time_index` (`write_time`)
) ENGINE=InnoDB AUTO_INCREMENT=21826 DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `exploring_first`
--

DROP TABLE IF EXISTS `exploring_first`;
/*!50001 DROP VIEW IF EXISTS `exploring_first`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `exploring_first` AS SELECT 
 1 AS `uuid`,
 1 AS `write_time`,
 1 AS `status`,
 1 AS `row_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `exploring_last`
--

DROP TABLE IF EXISTS `exploring_last`;
/*!50001 DROP VIEW IF EXISTS `exploring_last`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `exploring_last` AS SELECT 
 1 AS `uuid`,
 1 AS `write_time`,
 1 AS `status`,
 1 AS `row_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `exploring_tasks_logs`
--

DROP TABLE IF EXISTS `exploring_tasks_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `exploring_tasks_logs` (
  `uuid` varchar(50) COLLATE latin1_spanish_ci NOT NULL,
  `write_time` datetime NOT NULL,
  `status` varchar(255) COLLATE latin1_spanish_ci NOT NULL,
  `row_id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`row_id`),
  KEY `uuid_index` (`uuid`),
  KEY `write_time_index` (`write_time`)
) ENGINE=InnoDB AUTO_INCREMENT=597 DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Current Database: `anuncios`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `anuncios` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `anuncios`;

--
-- Temporary table structure for view `alquiler_altacalidad`
--

DROP TABLE IF EXISTS `alquiler_altacalidad`;
/*!50001 DROP VIEW IF EXISTS `alquiler_altacalidad`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `alquiler_altacalidad` AS SELECT 
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `capturas`
--

DROP TABLE IF EXISTS `capturas`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `capturas` (
  `fecha_captura` datetime NOT NULL,
  `referencia` int(11) NOT NULL,
  `precio` int(11) NOT NULL,
  `m2` decimal(8,2) DEFAULT NULL,
  `tamano_categorico` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `tipo_anuncio` int(11) NOT NULL,
  `calle` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
  `barrio` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
  `distrito` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ciudad` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
  `latitud` decimal(20,10) DEFAULT NULL,
  `longitud` decimal(20,10) DEFAULT NULL,
  `cubierta` int(11) DEFAULT NULL,
  `puerta_auto` int(11) DEFAULT NULL,
  `ascensor` int(11) DEFAULT NULL,
  `alarma` int(11) DEFAULT NULL,
  `circuito` int(11) DEFAULT NULL,
  `personal` int(11) DEFAULT NULL,
  `telefono` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `precision` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  KEY `idx_capturas_fecha_captura` (`fecha_captura`),
  KEY `idx_capturas_referencia` (`referencia`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `capturas_sin_ref_null`
--

DROP TABLE IF EXISTS `capturas_sin_ref_null`;
/*!50001 DROP VIEW IF EXISTS `capturas_sin_ref_null`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `capturas_sin_ref_null` AS SELECT 
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `dias_de_vida`
--

DROP TABLE IF EXISTS `dias_de_vida`;
/*!50001 DROP VIEW IF EXISTS `dias_de_vida`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `dias_de_vida` AS SELECT 
 1 AS `referencia`,
 1 AS `dias`,
 1 AS `primer_dia`,
 1 AS `ultimo_dia`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `nacimientos_defunciones_mensuales`
--

DROP TABLE IF EXISTS `nacimientos_defunciones_mensuales`;
/*!50001 DROP VIEW IF EXISTS `nacimientos_defunciones_mensuales`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `nacimientos_defunciones_mensuales` AS SELECT 
 1 AS `año`,
 1 AS `mes`,
 1 AS `nacimientos`,
 1 AS `defunciones`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `primera_captura_full`
--

DROP TABLE IF EXISTS `primera_captura_full`;
/*!50001 DROP VIEW IF EXISTS `primera_captura_full`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `primera_captura_full` AS SELECT 
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `simulaciones`
--

DROP TABLE IF EXISTS `simulaciones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `simulaciones` (
  `referencia` int(11) NOT NULL,
  `escenario` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
  `meses` int(11) NOT NULL,
  `precio_compra` int(11) DEFAULT NULL,
  `precio_venta` decimal(16,4) DEFAULT NULL,
  `precio_alquiler_mensual` decimal(16,4) DEFAULT NULL,
  `porcen_itp` decimal(16,4) DEFAULT NULL,
  `porcen_gastos_compra` decimal(16,4) DEFAULT NULL,
  `comunidad_anual` decimal(16,4) DEFAULT NULL,
  `ibi_anual` decimal(16,4) DEFAULT NULL,
  `porcen_impuesto_venta` decimal(16,4) DEFAULT NULL,
  `anos` int(11) DEFAULT NULL,
  `ingresos_venta` decimal(16,4) DEFAULT NULL,
  `ingresos_alquiler` decimal(16,4) DEFAULT NULL,
  `coste_compra` decimal(16,4) DEFAULT NULL,
  `coste_propiedad` decimal(16,4) DEFAULT NULL,
  `beneficio_venta` decimal(16,4) DEFAULT NULL,
  `beneficio_alquiler` decimal(16,4) DEFAULT NULL,
  `impuestos_venta` decimal(16,4) DEFAULT NULL,
  `beneficio_neto` decimal(16,4) DEFAULT NULL,
  `rentabilidad` decimal(16,4) DEFAULT NULL,
  `tae` decimal(16,4) DEFAULT NULL,
  `beneficio_bruto` decimal(16,4) DEFAULT NULL,
  `exito_alquiler` decimal(16,4) DEFAULT NULL,
  PRIMARY KEY (`referencia`,`escenario`,`meses`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `ultima_captura`
--

DROP TABLE IF EXISTS `ultima_captura`;
/*!50001 DROP VIEW IF EXISTS `ultima_captura`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `ultima_captura` AS SELECT 
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `ultima_captura_full`
--

DROP TABLE IF EXISTS `ultima_captura_full`;
/*!50001 DROP VIEW IF EXISTS `ultima_captura_full`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `ultima_captura_full` AS SELECT 
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `valoraciones`
--

DROP TABLE IF EXISTS `valoraciones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `valoraciones` (
  `fecha_captura` datetime NOT NULL,
  `referencia` int(11) NOT NULL,
  `precio` int(11) NOT NULL,
  `tamano_categorico` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tipo_anuncio` int(11) NOT NULL,
  `calle` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `barrio` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `distrito` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ciudad` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `latitud` decimal(20,10) DEFAULT NULL,
  `longitud` decimal(20,10) DEFAULT NULL,
  `cubierta` int(11) DEFAULT NULL,
  `puerta_auto` int(11) DEFAULT NULL,
  `ascensor` int(11) DEFAULT NULL,
  `alarma` int(11) DEFAULT NULL,
  `circuito` int(11) DEFAULT NULL,
  `personal` int(11) DEFAULT NULL,
  `telefono` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `precision` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `venta_valor_knn_corto` double DEFAULT NULL,
  `venta_valor_knn_largo` double DEFAULT NULL,
  `venta_valor_knn_custom` double DEFAULT NULL,
  `venta_dist_knn_corto` double DEFAULT NULL,
  `venta_dist_knn_largo` double DEFAULT NULL,
  `venta_dist_knn_custom` double DEFAULT NULL,
  `venta_valor_rf` double DEFAULT NULL,
  `alquiler_valor_knn_corto` double DEFAULT NULL,
  `alquiler_valor_knn_largo` double DEFAULT NULL,
  `alquiler_valor_knn_custom` double DEFAULT NULL,
  `alquiler_valor_rf` double DEFAULT NULL,
  PRIMARY KEY (`referencia`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `vecinos`
--

DROP TABLE IF EXISTS `vecinos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `vecinos` (
  `referencia` int(11) NOT NULL,
  `referencia_vecino` int(11) NOT NULL,
  `ranking` int(11) NOT NULL,
  PRIMARY KEY (`referencia`,`referencia_vecino`),
  KEY `idx_vecinos_referencia_vecino` (`referencia_vecino`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `vecinos_con_datos`
--

DROP TABLE IF EXISTS `vecinos_con_datos`;
/*!50001 DROP VIEW IF EXISTS `vecinos_con_datos`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vecinos_con_datos` AS SELECT 
 1 AS `referencia_central`,
 1 AS `ranking`,
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `venta_altacalidad`
--

DROP TABLE IF EXISTS `venta_altacalidad`;
/*!50001 DROP VIEW IF EXISTS `venta_altacalidad`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `venta_altacalidad` AS SELECT 
 1 AS `fecha_captura`,
 1 AS `referencia`,
 1 AS `precio`,
 1 AS `tamano_categorico`,
 1 AS `tipo_anuncio`,
 1 AS `calle`,
 1 AS `barrio`,
 1 AS `distrito`,
 1 AS `ciudad`,
 1 AS `latitud`,
 1 AS `longitud`,
 1 AS `cubierta`,
 1 AS `puerta_auto`,
 1 AS `ascensor`,
 1 AS `alarma`,
 1 AS `circuito`,
 1 AS `personal`,
 1 AS `telefono`,
 1 AS `precision`*/;
SET character_set_client = @saved_cs_client;

--
-- Current Database: `tasks`
--

USE `tasks`;

--
-- Final view structure for view `capturing_first`
--

/*!50001 DROP VIEW IF EXISTS `capturing_first`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`drogon`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `capturing_first` AS (select `t1`.`uuid` AS `uuid`,`t1`.`fk_uuid_exploring` AS `fk_uuid_exploring`,`t1`.`write_time` AS `write_time`,`t1`.`status` AS `status`,`t1`.`ad_url` AS `ad_url`,`t1`.`row_id` AS `row_id` from `capturing_tasks_logs` `t1` where (`t1`.`row_id` = (select min(`t2`.`row_id`) from `capturing_tasks_logs` `t2` where (`t1`.`uuid` = `t2`.`uuid`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `capturing_last`
--

/*!50001 DROP VIEW IF EXISTS `capturing_last`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`drogon`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `capturing_last` AS (select `t1`.`uuid` AS `uuid`,`t1`.`fk_uuid_exploring` AS `fk_uuid_exploring`,`t1`.`write_time` AS `write_time`,`t1`.`status` AS `status`,`t1`.`ad_url` AS `ad_url`,`t1`.`row_id` AS `row_id` from `capturing_tasks_logs` `t1` where (`t1`.`row_id` = (select max(`t2`.`row_id`) from `capturing_tasks_logs` `t2` where (`t1`.`uuid` = `t2`.`uuid`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `exploring_first`
--

/*!50001 DROP VIEW IF EXISTS `exploring_first`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`drogon`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `exploring_first` AS (select `t1`.`uuid` AS `uuid`,`t1`.`write_time` AS `write_time`,`t1`.`status` AS `status`,`t1`.`row_id` AS `row_id` from `exploring_tasks_logs` `t1` where (`t1`.`row_id` = (select min(`t2`.`row_id`) from `exploring_tasks_logs` `t2` where (`t1`.`uuid` = `t2`.`uuid`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `exploring_last`
--

/*!50001 DROP VIEW IF EXISTS `exploring_last`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`drogon`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `exploring_last` AS (select `t1`.`uuid` AS `uuid`,`t1`.`write_time` AS `write_time`,`t1`.`status` AS `status`,`t1`.`row_id` AS `row_id` from `exploring_tasks_logs` `t1` where (`t1`.`row_id` = (select max(`t2`.`row_id`) from `exploring_tasks_logs` `t2` where (`t1`.`uuid` = `t2`.`uuid`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Current Database: `anuncios`
--

USE `anuncios`;

--
-- Final view structure for view `alquiler_altacalidad`
--

/*!50001 DROP VIEW IF EXISTS `alquiler_altacalidad`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `alquiler_altacalidad` AS (select `ultima_captura`.`fecha_captura` AS `fecha_captura`,`ultima_captura`.`referencia` AS `referencia`,`ultima_captura`.`precio` AS `precio`,`ultima_captura`.`tamano_categorico` AS `tamano_categorico`,`ultima_captura`.`tipo_anuncio` AS `tipo_anuncio`,`ultima_captura`.`calle` AS `calle`,`ultima_captura`.`barrio` AS `barrio`,`ultima_captura`.`distrito` AS `distrito`,`ultima_captura`.`ciudad` AS `ciudad`,`ultima_captura`.`latitud` AS `latitud`,`ultima_captura`.`longitud` AS `longitud`,`ultima_captura`.`cubierta` AS `cubierta`,`ultima_captura`.`puerta_auto` AS `puerta_auto`,`ultima_captura`.`ascensor` AS `ascensor`,`ultima_captura`.`alarma` AS `alarma`,`ultima_captura`.`circuito` AS `circuito`,`ultima_captura`.`personal` AS `personal`,`ultima_captura`.`telefono` AS `telefono`,`ultima_captura`.`precision` AS `precision` from `ultima_captura` where ((`ultima_captura`.`precision` = 'ROOFTOP') and (`ultima_captura`.`tamano_categorico` <> '2 coches o más') and (`ultima_captura`.`tamano_categorico` <> '') and (`ultima_captura`.`tipo_anuncio` = 2))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `capturas_sin_ref_null`
--

/*!50001 DROP VIEW IF EXISTS `capturas_sin_ref_null`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `capturas_sin_ref_null` AS (select `capturas`.`fecha_captura` AS `fecha_captura`,`capturas`.`referencia` AS `referencia`,`capturas`.`precio` AS `precio`,`capturas`.`tamano_categorico` AS `tamano_categorico`,`capturas`.`tipo_anuncio` AS `tipo_anuncio`,`capturas`.`calle` AS `calle`,`capturas`.`barrio` AS `barrio`,`capturas`.`distrito` AS `distrito`,`capturas`.`ciudad` AS `ciudad`,`capturas`.`latitud` AS `latitud`,`capturas`.`longitud` AS `longitud`,`capturas`.`cubierta` AS `cubierta`,`capturas`.`puerta_auto` AS `puerta_auto`,`capturas`.`ascensor` AS `ascensor`,`capturas`.`alarma` AS `alarma`,`capturas`.`circuito` AS `circuito`,`capturas`.`personal` AS `personal`,`capturas`.`telefono` AS `telefono`,`capturas`.`precision` AS `precision` from `capturas` where (`capturas`.`referencia` <> 0)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `dias_de_vida`
--

/*!50001 DROP VIEW IF EXISTS `dias_de_vida`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `dias_de_vida` AS (select `p`.`referencia` AS `referencia`,(`u`.`fecha_captura` - `p`.`fecha_captura`) AS `dias`,`p`.`fecha_captura` AS `primer_dia`,`u`.`fecha_captura` AS `ultimo_dia` from (`primera_captura_full` `p` join `ultima_captura_full` `u` on((`p`.`referencia` = `u`.`referencia`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `nacimientos_defunciones_mensuales`
--

/*!50001 DROP VIEW IF EXISTS `nacimientos_defunciones_mensuales`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `nacimientos_defunciones_mensuales` AS (select `nacimientos_mes`.`año` AS `año`,`nacimientos_mes`.`mes` AS `mes`,`nacimientos_mes`.`nacimientos` AS `nacimientos`,`defunciones_mes`.`defunciones` AS `defunciones` from (((select year(`nacimientos`.`fecha_nacimiento`) AS `año`,month(`nacimientos`.`fecha_nacimiento`) AS `mes`,count(`nacimientos`.`referencia`) AS `nacimientos` from (select `capturas_sin_ref_null`.`referencia` AS `referencia`,min(`capturas_sin_ref_null`.`fecha_captura`) AS `fecha_nacimiento` from `anuncios`.`capturas_sin_ref_null` group by `capturas_sin_ref_null`.`referencia`) `nacimientos` group by `año`,`mes` order by `año`,`mes`)) `nacimientos_mes` join (select year(`defunciones`.`fecha_defuncion`) AS `año`,month(`defunciones`.`fecha_defuncion`) AS `mes`,count(`defunciones`.`referencia`) AS `defunciones` from (select `capturas_sin_ref_null`.`referencia` AS `referencia`,max(`capturas_sin_ref_null`.`fecha_captura`) AS `fecha_defuncion` from `anuncios`.`capturas_sin_ref_null` group by `capturas_sin_ref_null`.`referencia`) `defunciones` group by `año`,`mes` order by `año`,`mes`) `defunciones_mes` on(((`nacimientos_mes`.`año` = `defunciones_mes`.`año`) and (`nacimientos_mes`.`mes` = `defunciones_mes`.`mes`))))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `primera_captura_full`
--

/*!50001 DROP VIEW IF EXISTS `primera_captura_full`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `primera_captura_full` AS (select `t1`.`fecha_captura` AS `fecha_captura`,`t1`.`referencia` AS `referencia`,`t1`.`precio` AS `precio`,`t1`.`tamano_categorico` AS `tamano_categorico`,`t1`.`tipo_anuncio` AS `tipo_anuncio`,`t1`.`calle` AS `calle`,`t1`.`barrio` AS `barrio`,`t1`.`distrito` AS `distrito`,`t1`.`ciudad` AS `ciudad`,`t1`.`latitud` AS `latitud`,`t1`.`longitud` AS `longitud`,`t1`.`cubierta` AS `cubierta`,`t1`.`puerta_auto` AS `puerta_auto`,`t1`.`ascensor` AS `ascensor`,`t1`.`alarma` AS `alarma`,`t1`.`circuito` AS `circuito`,`t1`.`personal` AS `personal`,`t1`.`telefono` AS `telefono`,`t1`.`precision` AS `precision` from `capturas` `t1` where (`t1`.`fecha_captura` = (select min(`t2`.`fecha_captura`) from `capturas` `t2` where (`t1`.`referencia` = `t2`.`referencia`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `ultima_captura`
--

/*!50001 DROP VIEW IF EXISTS `ultima_captura`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ultima_captura` AS (select `t1`.`fecha_captura` AS `fecha_captura`,`t1`.`referencia` AS `referencia`,`t1`.`precio` AS `precio`,`t1`.`tamano_categorico` AS `tamano_categorico`,`t1`.`tipo_anuncio` AS `tipo_anuncio`,`t1`.`calle` AS `calle`,`t1`.`barrio` AS `barrio`,`t1`.`distrito` AS `distrito`,`t1`.`ciudad` AS `ciudad`,`t1`.`latitud` AS `latitud`,`t1`.`longitud` AS `longitud`,`t1`.`cubierta` AS `cubierta`,`t1`.`puerta_auto` AS `puerta_auto`,`t1`.`ascensor` AS `ascensor`,`t1`.`alarma` AS `alarma`,`t1`.`circuito` AS `circuito`,`t1`.`personal` AS `personal`,`t1`.`telefono` AS `telefono`,`t1`.`precision` AS `precision` from `capturas` `t1` where ((`t1`.`fecha_captura` = (select max(`t2`.`fecha_captura`) from `capturas` `t2` where (`t1`.`referencia` = `t2`.`referencia`))) and (`t1`.`fecha_captura` > (now() - interval 90 day)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `ultima_captura_full`
--

/*!50001 DROP VIEW IF EXISTS `ultima_captura_full`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ultima_captura_full` AS (select `t1`.`fecha_captura` AS `fecha_captura`,`t1`.`referencia` AS `referencia`,`t1`.`precio` AS `precio`,`t1`.`tamano_categorico` AS `tamano_categorico`,`t1`.`tipo_anuncio` AS `tipo_anuncio`,`t1`.`calle` AS `calle`,`t1`.`barrio` AS `barrio`,`t1`.`distrito` AS `distrito`,`t1`.`ciudad` AS `ciudad`,`t1`.`latitud` AS `latitud`,`t1`.`longitud` AS `longitud`,`t1`.`cubierta` AS `cubierta`,`t1`.`puerta_auto` AS `puerta_auto`,`t1`.`ascensor` AS `ascensor`,`t1`.`alarma` AS `alarma`,`t1`.`circuito` AS `circuito`,`t1`.`personal` AS `personal`,`t1`.`telefono` AS `telefono`,`t1`.`precision` AS `precision` from `capturas` `t1` where (`t1`.`fecha_captura` = (select max(`t2`.`fecha_captura`) from `capturas` `t2` where (`t1`.`referencia` = `t2`.`referencia`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vecinos_con_datos`
--

/*!50001 DROP VIEW IF EXISTS `vecinos_con_datos`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vecinos_con_datos` AS (select `v`.`referencia` AS `referencia_central`,`v`.`ranking` AS `ranking`,`c`.`fecha_captura` AS `fecha_captura`,`c`.`referencia` AS `referencia`,`c`.`precio` AS `precio`,`c`.`tamano_categorico` AS `tamano_categorico`,`c`.`tipo_anuncio` AS `tipo_anuncio`,`c`.`calle` AS `calle`,`c`.`barrio` AS `barrio`,`c`.`distrito` AS `distrito`,`c`.`ciudad` AS `ciudad`,`c`.`latitud` AS `latitud`,`c`.`longitud` AS `longitud`,`c`.`cubierta` AS `cubierta`,`c`.`puerta_auto` AS `puerta_auto`,`c`.`ascensor` AS `ascensor`,`c`.`alarma` AS `alarma`,`c`.`circuito` AS `circuito`,`c`.`personal` AS `personal`,`c`.`telefono` AS `telefono`,`c`.`precision` AS `precision` from (`vecinos` `v` join `ultima_captura_full` `c` on((`v`.`referencia_vecino` = `c`.`referencia`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `venta_altacalidad`
--

/*!50001 DROP VIEW IF EXISTS `venta_altacalidad`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `venta_altacalidad` AS (select `ultima_captura`.`fecha_captura` AS `fecha_captura`,`ultima_captura`.`referencia` AS `referencia`,`ultima_captura`.`precio` AS `precio`,`ultima_captura`.`tamano_categorico` AS `tamano_categorico`,`ultima_captura`.`tipo_anuncio` AS `tipo_anuncio`,`ultima_captura`.`calle` AS `calle`,`ultima_captura`.`barrio` AS `barrio`,`ultima_captura`.`distrito` AS `distrito`,`ultima_captura`.`ciudad` AS `ciudad`,`ultima_captura`.`latitud` AS `latitud`,`ultima_captura`.`longitud` AS `longitud`,`ultima_captura`.`cubierta` AS `cubierta`,`ultima_captura`.`puerta_auto` AS `puerta_auto`,`ultima_captura`.`ascensor` AS `ascensor`,`ultima_captura`.`alarma` AS `alarma`,`ultima_captura`.`circuito` AS `circuito`,`ultima_captura`.`personal` AS `personal`,`ultima_captura`.`telefono` AS `telefono`,`ultima_captura`.`precision` AS `precision` from `ultima_captura` where ((`ultima_captura`.`precision` = 'ROOFTOP') and (`ultima_captura`.`tamano_categorico` <> '2 coches o más') and (`ultima_captura`.`tamano_categorico` <> '') and (`ultima_captura`.`tipo_anuncio` = 1))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2018-10-28 19:47:03
