Built motion from commit 67e5df37.|2.0.66
[motion2.git] / server / config / seedDB / jscriptyProjects.js
1 'use strict';
2
3 var fs = require('fs');
4 var path = require('path');
5
6 var db = require('../../mysqldb').db;
7 var logger = require('../logger')('app');
8
9 var getJson = function(filename) {
10     return fs.readFileSync(path.join(__dirname, 'jscripty', filename + '.json'), {
11         encoding: 'utf-8'
12     });
13 };
14
15 var jscriptyProjects = [{
16     id: 1,
17     name: 'CustomerSatisfaction',
18     description: 'Customer Satisfaction auto generated',
19     formData: getJson('customerSatisfation')
20 }];
21
22 exports.create = function() {
23     return db.JscriptyProject
24         .bulkCreate(jscriptyProjects, {
25             ignoreDuplicates: true,
26             individualHooks: true
27         })
28         .then(function() {
29             logger.info('Jscripty Projects have been created');
30         })
31         .catch(function(err) {
32             logger.error('Can\'t create Jscripty Projects');
33         });
34 };