1

Updating database

This commit is contained in:
Alex Yatskov 2015-03-02 16:23:52 +09:00
parent f9e44e044f
commit b3b5f72a2e
3 changed files with 52 additions and 4 deletions

View File

@ -22,6 +22,7 @@
*/ */
var mysql = require('mysql'); var mysql = require('mysql');
var uuid = require('node-uuid');
var data = require('./data.json'); var data = require('./data.json');
var conn = mysql.createConnection({ 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 // Cleanup
// //

View File

@ -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 -- 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_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!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' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!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` -- Table structure for table `reviews`
-- --
@ -57,4 +81,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!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

View File

@ -13,6 +13,7 @@
"mysql": "^2.5.0", "mysql": "^2.5.0",
"underscore": "~1.6.0", "underscore": "~1.6.0",
"node-geocoder": "~2.11.0", "node-geocoder": "~2.11.0",
"geolib": "~2.0.14" "geolib": "~2.0.14",
"node-uuid": "~1.4.2"
} }
} }