var models = require('./models'),
    fs = require('fs'),
    async = require('async');

var User = models.User,
    Item = models.Item,
    Pin = models.Pin,
    Follow = models.Follow;

module.exports = function(){
    async.series([
        function(cb){
            User.create({username: 'admin', avatar_url: 'admin.jpg'}, function(){
                User.create({username: 'Andrew', avatar_url: 'https://github.com/identicons/jasonlong.png'});
                User.create({username: 'Sergey', avatar_url: 'https://avatars0.githubusercontent.com/u/4436860?v=3&s=96'});
                User.create({username: 'Thomas', avatar_url: 'https://avatars0.githubusercontent.com/u/125464?v=3&s=96'});
                cb(null);
            });
        },
        function(cb){
           var mediaFiles = fs.readdirSync('./media/');
           mediaFiles.forEach(function(fileName){
                Item.create({user: 0, image_url: fileName}, function(err, newArticle){
                    if (err){
                        return console.log(err);
                    }
                });
            });
            cb(null);
        },
        function(cb){
            Pin.create({actor: 1, item: 1});
            Pin.create({actor: 1, item: 2});
            Pin.create({actor: 1, item: 3});
            Pin.create({actor: 1, item: 4});
            Pin.create({actor: 2, item: 6});
            Pin.create({actor: 1, item: 5});
            Pin.create({actor: 1, item: 7});
            Pin.create({actor: 3, item: 9});
            Pin.create({actor: 3, item: 8});
            Pin.create({actor: 3, item: 4});
            cb(null);
        },
        function(cb){
            Follow.create({actor: 1, target: 2});
            Follow.create({actor: 1, target: 3});
            Follow.create({actor: 2, target: 1});
            Follow.create({actor: 2, target: 3});
        }
    ]);
};

@@ -1,12 +1,33 @@
+#!/usr/bin/env node%0A%0A
 var models =
@@ -100,16 +100,47 @@
 'async')
+,%0A    app = require('./app.js')
 ;%0A%0Avar U
@@ -249,16 +249,29 @@
 xports =
+ importData =
  functio
@@ -308,32 +308,78 @@
   function(cb)%7B%0A
+            console.log('creating users...');%0A
             User
@@ -868,32 +868,78 @@
   function(cb)%7B%0A
+            console.log('creating items...');%0A
            var m
@@ -1145,16 +1145,57 @@
  (err)%7B%0A
+                        process.exit(1);%0A
         
@@ -1340,32 +1340,77 @@
   function(cb)%7B%0A
+            console.log('creating pins...');%0A
             Pin.
@@ -1890,32 +1890,80 @@
   function(cb)%7B%0A
+            console.log('creating follows...');%0A
             Foll
@@ -2158,17 +2158,203 @@
     
-%7D%0A    %5D);%0A%7D;%0A
+    cb(null);%0A        %7D,%0A        function(cb)%7B%0A            console.log('import completed');%0A            cb();%0A            process.exit(0);%0A        %7D%0A    %5D);%0A%7D;%0Aif(!module.parent)%7B%0A    importData();%0A%7D

make after_deploy a script