From b3b5f72a2ea9fd33b1d08c4af5449fd0a5291708 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 2 Mar 2015 16:23:52 +0900 Subject: [PATCH] Updating database --- scrape/build_db.js | 23 +++++++++++++++++++++++ scrape/hscd.sql | 30 +++++++++++++++++++++++++++--- scrape/package.json | 3 ++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/scrape/build_db.js b/scrape/build_db.js index 481c91d..feda53c 100755 --- a/scrape/build_db.js +++ b/scrape/build_db.js @@ -22,6 +22,7 @@ */ var mysql = require('mysql'); +var uuid = require('node-uuid'); var data = require('./data.json'); var conn = mysql.createConnection({ @@ -55,6 +56,28 @@ for (var i = 0, count = data.length; i < count; ++i) { } +// +// Categories +// + +conn.query('DROP TABLE IF EXISTS categories'); +conn.query('CREATE TABLE categories(description VARCHAR(200) NOT NULL, id VARCHAR(36) NOT NULL PRIMARY KEY)'); + +var categories = [ + 'I prefer quiet places', + 'I enjoy Mexican Food', + 'I drive a car' +]; + +for (var i = 0, count = categories.length; i < count; ++i) { + conn.query( + 'INSERT INTO categories(description, id) VALUES (?, ?)', [ + categories[i], + uuid.v1() + ]); +} + + // // Cleanup // diff --git a/scrape/hscd.sql b/scrape/hscd.sql index 07ce0b0..65c3170 100644 --- a/scrape/hscd.sql +++ b/scrape/hscd.sql @@ -1,8 +1,8 @@ --- MySQL dump 10.13 Distrib 5.5.40, for debian-linux-gnu (x86_64) +-- MySQL dump 10.13 Distrib 5.5.41, for debian-linux-gnu (x86_64) -- -- Host: localhost Database: hscd -- ------------------------------------------------------ --- Server version 5.5.40-0ubuntu0.14.04.1 +-- Server version 5.5.41-0ubuntu0.14.04.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -15,6 +15,30 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +-- +-- Table structure for table `categories` +-- + +DROP TABLE IF EXISTS `categories`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `categories` ( + `description` varchar(200) NOT NULL, + `id` varchar(36) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `categories` +-- + +LOCK TABLES `categories` WRITE; +/*!40000 ALTER TABLE `categories` DISABLE KEYS */; +INSERT INTO `categories` VALUES ('I prefer quiet places','b7e0d2f0-c0ac-11e4-ad9d-8d58248cbb9e'),('I enjoy Mexican Food','b7e0d2f1-c0ac-11e4-ad9d-8d58248cbb9e'),('I drive a car','b7e0d2f2-c0ac-11e4-ad9d-8d58248cbb9e'); +/*!40000 ALTER TABLE `categories` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `reviews` -- @@ -57,4 +81,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2015-01-13 15:58:36 +-- Dump completed on 2015-03-02 16:22:31 diff --git a/scrape/package.json b/scrape/package.json index 0312efd..f90cf25 100644 --- a/scrape/package.json +++ b/scrape/package.json @@ -13,6 +13,7 @@ "mysql": "^2.5.0", "underscore": "~1.6.0", "node-geocoder": "~2.11.0", - "geolib": "~2.0.14" + "geolib": "~2.0.14", + "node-uuid": "~1.4.2" } }