From 0d4144f35d07a9c06d9357eb115acc2c63bd800e Mon Sep 17 00:00:00 2001 From: Sharan Yalburgi Date: Tue, 15 Aug 2017 11:18:44 +0530 Subject: [PATCH] Update models one by one, modify import in passport.js --- src/core/passport.js | 6 +++++- src/data/models/bonafide.js | 3 ++- src/data/models/cgpa_view.js | 1 + src/data/models/daypass.js | 4 ++-- src/data/models/daypasstablegate.js | 6 +++++- src/data/models/discp.js | 2 +- src/data/models/discp_view.js | 4 +++- src/data/models/faculty_incharge.js | 2 ++ src/data/models/info_update.js | 2 ++ src/data/models/inoutdetails.js | 8 ++++++++ src/data/models/institure_holidays.js | 2 +- src/data/models/leave_requests.js | 4 +++- src/data/models/leave_requests_view.js | 2 +- src/data/models/leavetablegate.js | 7 ++++++- src/data/models/login_ids.js | 1 + src/data/models/mess_option_open.js | 2 +- src/data/models/notices.js | 6 +++--- src/data/models/nucleus.js | 2 ++ src/data/models/products.js | 2 +- src/data/models/staff.js | 2 ++ src/data/models/student_info.js | 12 ++++++++++++ src/data/models/students_basic.js | 1 + src/data/models/superintendents.js | 3 +++ src/data/models/wardens.js | 3 +++ src/data/sequelize.js | 1 + 25 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/core/passport.js b/src/core/passport.js index 6772810..b050a54 100644 --- a/src/core/passport.js +++ b/src/core/passport.js @@ -15,7 +15,11 @@ import passport from 'passport'; import { Strategy as FacebookStrategy } from 'passport-facebook'; -import { User, UserLogin, UserClaim, UserProfile } from '../data/models'; +// import { User, UserLogin, UserClaim, UserProfile } from '../data/models'; +import User from '../data/models/User.js'; +import UserLogin from '../data/models/UserLogin.js'; +import UserClaim from '../data/models/UserClaim.js'; +import UserProfile from '../data/models/UserProfile.js'; import { auth as config } from '../config'; /** diff --git a/src/data/models/bonafide.js b/src/data/models/bonafide.js index 85445f1..8acf3af 100644 --- a/src/data/models/bonafide.js +++ b/src/data/models/bonafide.js @@ -22,9 +22,10 @@ const Bonafide = Model.define('bonafide', { allowNull: false, primaryKey: true, autoIncrement: true, + unique: true, }, req_date: { - type: DataTypes.BIGINT, + type: DataTypes.BIGINT(20), allowNull: false, }, other_reason: { diff --git a/src/data/models/cgpa_view.js b/src/data/models/cgpa_view.js index c887ccd..1601fd3 100644 --- a/src/data/models/cgpa_view.js +++ b/src/data/models/cgpa_view.js @@ -16,6 +16,7 @@ const CGPA_View = Model.define('cgpa_view', { cgpa: { type: DataTypes.INTEGER(10), allowNull: true, + defaultValue: null, }, }, { tableName: 'cgpa_view', diff --git a/src/data/models/daypass.js b/src/data/models/daypass.js index 28537e6..331ab6c 100644 --- a/src/data/models/daypass.js +++ b/src/data/models/daypass.js @@ -15,7 +15,7 @@ const DayPass = Model.define('daypass', { allowNull: false, }, Date: { - type: DataTypes.BIGINT, + type: DataTypes.BIGINT(20), allowNull: false, }, Phone: { @@ -35,7 +35,7 @@ const DayPass = Model.define('daypass', { allowNull: false, }, Approved: { - type: DataTypes.INTEGER(1), + type: DataTypes.BOOLEAN, allowNull: false, }, Comment: { diff --git a/src/data/models/daypasstablegate.js b/src/data/models/daypasstablegate.js index 3370e0a..a10c78e 100644 --- a/src/data/models/daypasstablegate.js +++ b/src/data/models/daypasstablegate.js @@ -12,18 +12,22 @@ const DayPassTableGate = Model.define('daypasstablegate', { ID: { type: DataTypes.STRING(12), allowNull: true, + defaultValue: null, }, Name: { type: DataTypes.STRING(100), allowNull: true, + defaultValue: null, }, DayPassDate: { type: DataTypes.DATE, allowNull: true, + defaultValue: null, }, DayPassApproved: { - type: DataTypes.INTEGER(1), + type: DataTypes.BOOLEAN, allowNull: true, + defaultValue: null, }, }, { tableName: 'daypasstablegate', diff --git a/src/data/models/discp.js b/src/data/models/discp.js index 297e52d..26d53a3 100644 --- a/src/data/models/discp.js +++ b/src/data/models/discp.js @@ -20,7 +20,7 @@ const Discp = Model.define('discp', { allowNull: false, }, severe: { - type: DataTypes.INTEGER(1), + type: DataTypes.BOOLEAN, allowNull: false, defaultValue: '0', }, diff --git a/src/data/models/discp_view.js b/src/data/models/discp_view.js index c15ad87..dcc6a46 100644 --- a/src/data/models/discp_view.js +++ b/src/data/models/discp_view.js @@ -26,12 +26,14 @@ const DiscpView = Model.define('discp_view', { allowNull: false, }, severe: { - type: DataTypes.INTEGER(1), + type: DataTypes.BOOLEAN, allowNull: true, + defaultValue: null, }, date: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'discp_view', diff --git a/src/data/models/faculty_incharge.js b/src/data/models/faculty_incharge.js index edf248b..ee5208d 100644 --- a/src/data/models/faculty_incharge.js +++ b/src/data/models/faculty_incharge.js @@ -23,10 +23,12 @@ const Faculty_Incharge = Model.define('faculty_incharge', { chamber: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, office: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'faculty_incharge', diff --git a/src/data/models/info_update.js b/src/data/models/info_update.js index 9544758..0dfa731 100644 --- a/src/data/models/info_update.js +++ b/src/data/models/info_update.js @@ -23,6 +23,7 @@ const Info_Update = Model.define('info_update', { phone: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, address: { type: DataTypes.TEXT, @@ -31,6 +32,7 @@ const Info_Update = Model.define('info_update', { email: { type: DataTypes.STRING(100), allowNull: true, + defaultValue: null, }, }, { tableName: 'info_update', diff --git a/src/data/models/inoutdetails.js b/src/data/models/inoutdetails.js index c4a74e0..f2c6207 100644 --- a/src/data/models/inoutdetails.js +++ b/src/data/models/inoutdetails.js @@ -11,18 +11,22 @@ const InOutDetails = Model.define('inoutdetails', { Name: { type: DataTypes.STRING(100), allowNull: true, + defaultValue: null, }, Hostel: { type: DataTypes.STRING(4), allowNull: true, + defaultValue: null, }, Room: { type: DataTypes.STRING(3), allowNull: true, + defaultValue: null, }, Phone: { type: DataTypes.STRING(10), allowNull: true, + defaultValue: null, }, Place: { type: DataTypes.STRING(20), @@ -31,6 +35,7 @@ const InOutDetails = Model.define('inoutdetails', { OutDate: { type: DataTypes.DATE, allowNull: true, + defaultValue: null, }, OutTime: { type: DataTypes.TIME, @@ -39,14 +44,17 @@ const InOutDetails = Model.define('inoutdetails', { InDate: { type: DataTypes.DATE, allowNull: true, + defaultValue: null, }, InTime: { type: DataTypes.TIME, allowNull: true, + defaultValue: null, }, OnCampus: { type: DataTypes.INTEGER(1), allowNull: true, + defaultValue: null, }, exit_id: { type: DataTypes.INTEGER(11), diff --git a/src/data/models/institure_holidays.js b/src/data/models/institure_holidays.js index 4e2a1dd..66a5b83 100644 --- a/src/data/models/institure_holidays.js +++ b/src/data/models/institure_holidays.js @@ -11,7 +11,7 @@ const Institure_Holidays = Model.define('institure_holidays', { primaryKey: true, }, date: { - type: DataTypes.BIGINT, + type: DataTypes.DATE, allowNull: false, }, }, { diff --git a/src/data/models/leave_requests.js b/src/data/models/leave_requests.js index 4e1dbf9..ce22eeb 100644 --- a/src/data/models/leave_requests.js +++ b/src/data/models/leave_requests.js @@ -44,10 +44,12 @@ const Leave_Requests = Model.define('leave_requests', { approved_by: { type: DataTypes.STRING(50), allowNull: true, + defaultValue: null, }, approved: { - type: DataTypes.INTEGER(1).UNSIGNED, + type: DataTypes.BOOLEAN, allowNull: true, + defaultValue: null, }, comment: { type: DataTypes.TEXT, diff --git a/src/data/models/leave_requests_view.js b/src/data/models/leave_requests_view.js index 1e9d99e..d130ebb 100644 --- a/src/data/models/leave_requests_view.js +++ b/src/data/models/leave_requests_view.js @@ -7,7 +7,6 @@ const Leave_Requests_View = Model.define('leave_requests_view', { id: { type: DataTypes.STRING(12), allowNull: false, - primaryKey: true, }, student_name: { type: DataTypes.TEXT, @@ -16,6 +15,7 @@ const Leave_Requests_View = Model.define('leave_requests_view', { leave_id: { type: DataTypes.INTEGER(20), allowNull: false, + primaryKey: true, }, login_id: { type: DataTypes.STRING(20), diff --git a/src/data/models/leavetablegate.js b/src/data/models/leavetablegate.js index dbe801c..391bfc7 100644 --- a/src/data/models/leavetablegate.js +++ b/src/data/models/leavetablegate.js @@ -12,22 +12,27 @@ const LeaveTableGate = Model.define('leavetablegate', { ID: { type: DataTypes.STRING(12), allowNull: true, + defaultValue: null, }, Name: { type: DataTypes.STRING(100), allowNull: true, + defaultValue: null, }, LeaveStart: { type: DataTypes.DATE, allowNull: true, + defaultValue: null, }, LeaveEnd: { type: DataTypes.DATE, allowNull: true, + defaultValue: null, }, LeaveApproved: { - type: DataTypes.INTEGER(1), + type: DataTypes.BOOLEAN, allowNull: true, + defaultValue: null, }, }, { tableName: 'leavetablegate', diff --git a/src/data/models/login_ids.js b/src/data/models/login_ids.js index dbf31c0..dbe8912 100644 --- a/src/data/models/login_ids.js +++ b/src/data/models/login_ids.js @@ -9,6 +9,7 @@ const Login_IDs = Model.define('login_ids', { allowNull: false, defaultValue: '', primaryKey: true, + unique: true, }, type: { type: DataTypes.STRING(11), diff --git a/src/data/models/mess_option_open.js b/src/data/models/mess_option_open.js index 02641d3..7c35c9c 100644 --- a/src/data/models/mess_option_open.js +++ b/src/data/models/mess_option_open.js @@ -5,7 +5,7 @@ import Model from '../sequelize'; const Mess_Option_Open = Model.define('mess_option_open', { open: { - type: DataTypes.INTEGER(1), + type: DataTypes.BOOLEAN, allowNull: false, defaultValue: '0', primaryKey: true, diff --git a/src/data/models/notices.js b/src/data/models/notices.js index 5347956..54c3ac0 100644 --- a/src/data/models/notices.js +++ b/src/data/models/notices.js @@ -11,7 +11,7 @@ const Notices = Model.define('notices', { autoIncrement: true, }, archived: { - type: DataTypes.INTEGER(1).UNSIGNED, + type: DataTypes.BOOLEAN, allowNull: false, defaultValue: '0', }, @@ -26,11 +26,11 @@ const Notices = Model.define('notices', { defaultValue: '', }, published: { - type: DataTypes.BIGINT, + type: DataTypes.BIGINT(20), allowNull: false, }, updated: { - type: DataTypes.BIGINT, + type: DataTypes.BIGINT(20), allowNull: false, }, category: { diff --git a/src/data/models/nucleus.js b/src/data/models/nucleus.js index 4f303f0..dcce47d 100644 --- a/src/data/models/nucleus.js +++ b/src/data/models/nucleus.js @@ -18,10 +18,12 @@ const Nucleus = Model.define('nucleus', { chamber: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, office: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'nucleus', diff --git a/src/data/models/products.js b/src/data/models/products.js index 876e95f..018a730 100644 --- a/src/data/models/products.js +++ b/src/data/models/products.js @@ -5,7 +5,7 @@ import Model from '../sequelize'; const Products = Model.define('products', { id: { - type: DataTypes.BIGINT, + type: DataTypes.BIGINT(20), allowNull: false, primaryKey: true, autoIncrement: true, diff --git a/src/data/models/staff.js b/src/data/models/staff.js index c4e636a..190f275 100644 --- a/src/data/models/staff.js +++ b/src/data/models/staff.js @@ -18,10 +18,12 @@ const Staff = Model.define('staff', { chamber: { type: DataTypes.STRING(10), allowNull: true, + defaultValue: null, }, office: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'staff', diff --git a/src/data/models/student_info.js b/src/data/models/student_info.js index be37882..860e793 100644 --- a/src/data/models/student_info.js +++ b/src/data/models/student_info.js @@ -14,14 +14,17 @@ const Student = Model.define('student_info', { allowNull: true, unique: true, primaryKey: true, + defaultValue: null, }, hostel: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, hostel_room: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, id: { type: DataTypes.STRING(20), @@ -31,14 +34,17 @@ const Student = Model.define('student_info', { bday: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, phone: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, email: { type: DataTypes.STRING(100), allowNull: true, + defaultValue: null, }, address: { type: DataTypes.TEXT, @@ -47,26 +53,32 @@ const Student = Model.define('student_info', { father_name: { type: DataTypes.STRING(200), allowNull: true, + defaultValue: null, }, father_phone: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, father_email: { type: DataTypes.STRING(100), allowNull: true, + defaultValue: null, }, admit: { type: DataTypes.STRING(50), allowNull: true, + defaultValue: null, }, gender: { type: DataTypes.CHAR(5), allowNull: true, + defaultValue: null, }, bloodgroup: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'student_info', diff --git a/src/data/models/students_basic.js b/src/data/models/students_basic.js index 3c06208..941d8c7 100644 --- a/src/data/models/students_basic.js +++ b/src/data/models/students_basic.js @@ -9,6 +9,7 @@ const Students_Basic = Model.define('students_basic', { allowNull: false, defaultValue: '', primaryKey: true, + unique: true, }, student_name: { type: DataTypes.STRING(200), diff --git a/src/data/models/superintendents.js b/src/data/models/superintendents.js index cf1d201..f098a54 100644 --- a/src/data/models/superintendents.js +++ b/src/data/models/superintendents.js @@ -23,14 +23,17 @@ const Superintendents = Model.define('superintendents', { chamber: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, office: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, residence: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'superintendents', diff --git a/src/data/models/wardens.js b/src/data/models/wardens.js index 67bd4d4..3e12885 100644 --- a/src/data/models/wardens.js +++ b/src/data/models/wardens.js @@ -23,14 +23,17 @@ const Wardens = Model.define('wardens', { chamber: { type: DataTypes.STRING(10), allowNull: true, + defaultValue: null, }, office: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, residence: { type: DataTypes.STRING(20), allowNull: true, + defaultValue: null, }, }, { tableName: 'wardens', diff --git a/src/data/sequelize.js b/src/data/sequelize.js index 0255ced..3663fd4 100644 --- a/src/data/sequelize.js +++ b/src/data/sequelize.js @@ -14,6 +14,7 @@ const sequelize = new Sequelize(databaseConfig.databasename, databaseConfig.user databaseConfig.password, { define: { freezeTableName: true, + timestamps: false, }, });