From ebab3b60a842bcbb589d17c44d5ba694ef720c7e Mon Sep 17 00:00:00 2001 From: DC* Date: Fri, 8 Aug 2014 00:47:38 -0300 Subject: [PATCH] Changed configuration parameters' names to match sequelize nomemclature Fixed seed/initial_tasks data which created tasks in a non-sequential order (tested on Postgres) Added production-like example configuration --- config/database.json | 10 +++++----- config/production.json | 13 +++++++++++++ db/models/task.js | 4 ++-- db/seed/initial_tasks.js | 14 ++++++++------ orm.js | 2 +- 5 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 config/production.json diff --git a/config/database.json b/config/database.json index 21940e1..bd795be 100644 --- a/config/database.json +++ b/config/database.json @@ -8,10 +8,10 @@ "storage": "db/test.sqlite" }, "production": { - "username": "root", - "password": null, - "database": "database_production", - "host": "127.0.0.1", - "dialect": "mysql" + "username": "postgres", + "password": "", + "database": "hackflowy", + "host" : "localhost", + "dialect" : "postgres" } } diff --git a/config/production.json b/config/production.json new file mode 100644 index 0000000..4e7dd98 --- /dev/null +++ b/config/production.json @@ -0,0 +1,13 @@ +{ + "port": 3000, + "database": { + "username": "postgres", + "password": "", + "database": "hackflowy", + "options" : { + "dialect": "postgres", + "host" : "localhost", + "port" : "5432" + } + } +} diff --git a/db/models/task.js b/db/models/task.js index 22b4fd8..4e3eb86 100644 --- a/db/models/task.js +++ b/db/models/task.js @@ -3,9 +3,9 @@ var Sequelize = require('sequelize'); module.exports = { instance: function(orm) { task = orm.define('Tasks', { - id : {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true}, + id : {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true}, content : {type: Sequelize.TEXT, allowNull: false}, - parent : Sequelize.INTEGER, + parent : Sequelize.INTEGER, isCompleted: Sequelize.BOOLEAN, createdAt : Sequelize.DATE, updatedAt : Sequelize.DATE diff --git a/db/seed/initial_tasks.js b/db/seed/initial_tasks.js index fe14b44..d5a39a6 100644 --- a/db/seed/initial_tasks.js +++ b/db/seed/initial_tasks.js @@ -2,11 +2,13 @@ var config = require('config'), orm = require('../../orm').configure(config.get('database')), Tasks = require('../../db/models/task').instance(orm); -Tasks.create({content: 'Welcome to HackFlowy!', isCompleted: false}); -Tasks.create({content: 'An open-source WorkFlowy clone', isCompleted: false}); -Tasks.create({content: 'Built using Backbone + Socket.IO', isCompleted: false}); -Tasks.create({content: 'I pulled this together in a few hours to learn Backbone', isCompleted: false}); -Tasks.create({content: 'Feel free to try it out and hack on it', isCompleted: false}); -Tasks.create({content: 'Good Luck!', isCompleted: false}); +Tasks.bulkCreate([ + {content: 'Welcome to HackFlowy!', isCompleted: false}, + {content: 'An open-source WorkFlowy clone', isCompleted: false}, + {content: 'Built using Backbone + Socket.IO', isCompleted: false}, + {content: 'I pulled this together in a few hours to learn Backbone', isCompleted: false}, + {content: 'Feel free to try it out and hack on it', isCompleted: false}, + {content: 'Good Luck!', isCompleted: false} +]); orm.sync(); diff --git a/orm.js b/orm.js index e71ca3a..f988d00 100644 --- a/orm.js +++ b/orm.js @@ -2,6 +2,6 @@ var Sequelize = require('sequelize'); module.exports = { configure: function(db) { - return new Sequelize(db.name, db.user, db.password, db.options); + return new Sequelize(db.database, db.username, db.password, db.options); } }