﻿var DB = require('./db').DB;

/*
CREATE TABLE `tblUsers` (
  `userId` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(100) DEFAULT NULL,
  `password` varchar(100) DEFAULT NULL,
  `admin` boolean not null default 0,
  PRIMARY KEY (`userId`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
*/ 
var User = DB.Model.extend({
    tableName: 'tblUsers',
    idAttribute: 'userId'
});

/*
CREATE TABLE `tblSessions` (
  `session_id` varchar(255) COLLATE utf8_bin NOT NULL,
  `expires` int(11) unsigned NOT NULL,
  `data` text COLLATE utf8_bin,
  PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
*/
var Session = DB.Model.extend({    
    tableName: 'tblSessions',
    idAttribute: 'session_id'            
});


/*
 CREATE TABLE `tblVideos` ( 
  `videoId` int(11) NOT NULL AUTO_INCREMENT,
  `path` varchar(512) DEFAULT NULL,  
  `labeler` varchar(100), 
  `labeled` boolean not null default 0,
  `label` char(1) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`videoId`)      
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
 */
var Video = DB.Model.extend({
    tableName: 'tblVideos',
    idAttribute: 'videoId'
});


/*
 CREATE TABLE `tblConfig` (   
  `key` varchar(50) not null,  
  `value` varchar(512) not null,    
  PRIMARY KEY (`key`)      
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
 */
var Config = DB.Model.extend({
    tableName: 'tblConfig',
    idAttribute: 'key'
});

module.exports = {
    User: User,
    Session: Session,
    Video: Video,
    Config: Config
};
@@ -813,17 +813,16 @@
 ideos%60 (
- 
 %0A  %60vide
@@ -880,28 +880,22 @@
 har(
-512) DEFAUL
+200) NO
 T NULL,
-  
 %0A  %60
@@ -919,68 +919,54 @@
 100)
-, %0A  %60labeled%60 boolean not null default 0,%0A  %60label%60 char(1)
+ DEFAULT NULL,%0A  %60labeled%60 tinyint(1) NOT NULL
  DEF
@@ -966,28 +966,27 @@
 ULL DEFAULT 
-NULL
+'0'
 ,%0A  %60created
@@ -990,25 +990,34 @@
 ted_at%60 
-TIMESTAMP
+timestamp NOT NULL
  DEFAULT
@@ -1084,16 +1084,16 @@
 at%60 
-DATETIME
+datetime
  DEF
@@ -1150,37 +1150,100 @@
 ,%0A  
-PRIMARY KEY (%60videoId%60)      
+%60label%60 char(1) DEFAULT NULL,%0A  PRIMARY KEY (%60videoId%60),%0A  UNIQUE KEY %60path_UNIQUE%60 (%60path%60)
 %0A) E
@@ -1262,33 +1262,34 @@
  AUTO_INCREMENT=
-4
+29
  DEFAULT CHARSET
@@ -1287,32 +1287,33 @@
 T CHARSET=utf8;%0A
+%0A
  */%0Avar Video = 

Load videos do not add duplicated entries