diff --git a/api/models/challenge.js b/api/models/challenge.js index 09dd107..ca816e3 100644 --- a/api/models/challenge.js +++ b/api/models/challenge.js @@ -23,11 +23,20 @@ module.exports = function(sequelize, DataTypes) { } }, // registration start date - regStartAt: DataTypes.DATE, + regStartAt: { + type: DataTypes.DATE, + field: 'reg_start_at' + }, // submission end date - subEndAt: DataTypes.DATE, + subEndAt: { + type: DataTypes.DATE, + field: 'sub_end_at' + }, // challenge completed date - completedAt: DataTypes.DATE, + completedAt: { + type: DataTypes.DATE, + field: 'completed_at' + }, // challenge title title: { type: DataTypes.TEXT, @@ -39,27 +48,51 @@ module.exports = function(sequelize, DataTypes) { }, overview: DataTypes.STRING(140), account: DataTypes.STRING(255), - accountId: DataTypes.STRING(255), + accountId: { + type: DataTypes.STRING(255), + field: 'account_id' + }, description: DataTypes.TEXT, source: DataTypes.TEXT, - sourceId: DataTypes.TEXT, + sourceId: { + type: DataTypes.TEXT, + field: 'source_id' + }, tags: DataTypes.ARRAY(DataTypes.TEXT), - prizes: DataTypes.ARRAY(DataTypes.DOUBLE), + // sequelize does not support DOUBLE + prizes: DataTypes.ARRAY(DataTypes.DECIMAL(11,2)), // the phase status of challenge status : { type: DataTypes.ENUM, values: ['DRAFT', 'SUBMISSION', 'REVIEW', 'COMPLETE'] }, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'challenges', + underscored: true, associate : function(models) { Challenge.hasMany(models.File); Challenge.hasMany(models.Participant); Challenge.hasMany(models.Submission); Challenge.hasMany(models.Scorecard); Challenge.hasMany(models.Requirement); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/file.js b/api/models/file.js index 8405282..204d508 100644 --- a/api/models/file.js +++ b/api/models/file.js @@ -23,40 +23,67 @@ module.exports = function(sequelize, DataTypes) { }, challengeId: { type: DataTypes.BIGINT, allowNull: false, + field: 'challenge_id', get: function() { return parseInt(this.getDataValue('challengeId')); } }, submissionId: { type: DataTypes.BIGINT, allowNull: false, + field: 'submission_id', get: function() { return parseInt(this.getDataValue('submissionId')); } }, title : {type: DataTypes.TEXT}, - filePath : {type: DataTypes.TEXT, allowNull: false}, + filePath : { + type: DataTypes.TEXT, + allowNull: false, + field: 'file_path' + }, size : { type: DataTypes.BIGINT, allowNull: false, get: function() { return parseInt(this.getDataValue('size')); } }, - fileName : {type: DataTypes.TEXT, allowNull: false}, + fileName : { + type: DataTypes.TEXT, + allowNull: false, + field: 'file_name' + }, // file storage location storageLocation : { type: DataTypes.ENUM, - values: ['local', 's3'], - allowNull: false + values: ['LOCAL', 'S3'], + allowNull: false, + field: 'storage_location' }, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) - + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'files', + underscored: true, associate : function(models) { - File.belongsTo(models.Challenge, {foreignKey : 'challengeId'}); - File.belongsTo(models.Submission, {foreignKey : 'submissionId'}); + File.belongsTo(models.Challenge, {foreignKey : 'challenge_id'}); + File.belongsTo(models.Submission, {foreignKey : 'submission_id'}); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/index.js b/api/models/index.js index 2e4b163..31b7702 100644 --- a/api/models/index.js +++ b/api/models/index.js @@ -40,8 +40,8 @@ module.exports = function(config) { }); Object.keys(db).forEach(function(modelName) { - if (db[modelName].options.hasOwnProperty('associate')) { - db[modelName].options.associate(db); + if (db[modelName].hasOwnProperty('associate')) { + db[modelName].associate(db); } }); return _.extend({sequelize: sequelize, Sequelize: Sequelize}, db); diff --git a/api/models/participant.js b/api/models/participant.js index e79b990..22fb1f9 100644 --- a/api/models/participant.js +++ b/api/models/participant.js @@ -24,12 +24,14 @@ module.exports = function(sequelize, DataTypes) { // user id of a participant userId : { type: DataTypes.BIGINT, allowNull: false, + field: 'user_id', get: function() { return parseInt(this.getDataValue('userId')); } }, challengeId: { type: DataTypes.BIGINT, allowNull: false, + field: 'challenge_id', get: function() { return parseInt(this.getDataValue('challengeId')); } @@ -37,17 +39,33 @@ module.exports = function(sequelize, DataTypes) { // role of participant role : { type: DataTypes.ENUM, - values: ['owner', 'submitter', 'watcher', 'reviewer'], + values: ['OWNER', 'SUBMITTER', 'WATCHER', 'REVIEWER'], allowNull: false }, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) - + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'participants', + underscored: true, associate : function(models) { - Participant.belongsTo(models.User, {foreignKey : 'userId'}); - Participant.belongsTo(models.Challenge, {foreignKey : 'challengeId'}); + Participant.belongsTo(models.User, {foreignKey : 'user_id'}); + Participant.belongsTo(models.Challenge, {foreignKey : 'challenge_id'}); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/requirement.js b/api/models/requirement.js index 472f445..4ce33ee 100644 --- a/api/models/requirement.js +++ b/api/models/requirement.js @@ -25,16 +25,31 @@ module.exports = function(sequelize, DataTypes) { }, challengeId: { type: DataTypes.BIGINT, allowNull: false, + field: 'challenge_id', get: function() { return parseInt(this.getDataValue('challengeId')); } }, - requirementText : DataTypes.TEXT + requirementText: { + type: DataTypes.TEXT, + field: 'requirement_text' + } }, { tableName : 'requirements', + underscored: true, associate : function(models) { - Requirement.belongsTo(models.Challenge, {foreignKey : 'challengeId'}); + Requirement.belongsTo(models.Challenge, {foreignKey : 'challenge_id'}); Requirement.hasMany(models.ScorecardItem); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/scorecard.js b/api/models/scorecard.js index e1eb587..0c5c3a3 100644 --- a/api/models/scorecard.js +++ b/api/models/scorecard.js @@ -24,6 +24,7 @@ module.exports = function(sequelize, DataTypes) { }, challengeId: { type: DataTypes.BIGINT, allowNull: false, + field: 'challenge_id', get: function() { return parseInt(this.getDataValue('challengeId')); } @@ -31,22 +32,33 @@ module.exports = function(sequelize, DataTypes) { // user id of reviewer reviewerId: { type: DataTypes.BIGINT, + field: 'reviewer_id', get: function() { return parseInt(this.getDataValue('reviewerId')); } }, submissionId: { type: DataTypes.BIGINT, + field: 'submission_id', get: function() { return parseInt(this.getDataValue('submissionId')); } }, // sum of all the scorecard items scorecard - scoreSum: DataTypes.INTEGER, + scoreSum: { + type: DataTypes.INTEGER, + field: 'score_sum' + }, // scoreSum / scoreMax from scorecard items - scorePercent: DataTypes.FLOAT, + scorePercent: { + type: DataTypes.FLOAT, + field: 'score_percent' + }, // sum of highest possible score from scorecard items - scoreMax: DataTypes.FLOAT, + scoreMax: { + type: DataTypes.FLOAT, + field: 'score_max' + }, status : { type: DataTypes.ENUM, values: ['VALID', 'INVALID', 'LATE'] @@ -61,15 +73,32 @@ module.exports = function(sequelize, DataTypes) { } }, prize: DataTypes.FLOAT, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'scorecards', + underscored: true, associate : function(models) { Scorecard.hasMany(models.ScorecardItem); - Scorecard.belongsTo(models.Challenge, {foreignKey: 'challengeId'}); - Scorecard.belongsTo(models.Submission, {foreignKey: 'submissionId'}); - Scorecard.belongsTo(models.User, {foreignKey: 'reviewerId'}); + Scorecard.belongsTo(models.Challenge, {foreignKey: 'challenge_id'}); + Scorecard.belongsTo(models.Submission, {foreignKey: 'submission_id'}); + Scorecard.belongsTo(models.User, {foreignKey: 'reviewer_id'}); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/scorecardItem.js b/api/models/scorecardItem.js index 1ccfe45..3f477aa 100644 --- a/api/models/scorecardItem.js +++ b/api/models/scorecardItem.js @@ -25,22 +25,43 @@ module.exports = function(sequelize, DataTypes) { // scorecard id of this item scorecardId: { type: DataTypes.BIGINT, allowNull: false, + field: 'scorecard_id', get: function() { return parseInt(this.getDataValue('scorecardId')); } }, - requirementId: DataTypes.INTEGER, + requirementId: { + type: DataTypes.INTEGER, + field: 'requirement_id' + }, // score of submission score: DataTypes.FLOAT, // comment from reviewer comment : DataTypes.TEXT, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'scorecard_items', + underscored: true, associate : function(models) { - ScorecardItem.belongsTo(models.Scorecard, {foreignKey: 'scorecardId'}); - ScorecardItem.belongsTo(models.Requirement, {foreignKey: 'requirementId'}); + ScorecardItem.belongsTo(models.Scorecard, {foreignKey: 'scorecard_id'}); + ScorecardItem.belongsTo(models.Requirement, {foreignKey: 'requirement_id'}); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/submission.js b/api/models/submission.js index 05cb2f5..39f84c0 100644 --- a/api/models/submission.js +++ b/api/models/submission.js @@ -23,6 +23,7 @@ module.exports = function(sequelize, DataTypes) { }, challengeId : { type: DataTypes.BIGINT, allowNull: false, + field: 'challenge_id', get: function() { return parseInt(this.getDataValue('challengeId')); } @@ -30,19 +31,37 @@ module.exports = function(sequelize, DataTypes) { // user id of submitter submitterId : { type: DataTypes.BIGINT, allowNull: false, + field: 'submitter_id', get: function() { return parseInt(this.getDataValue('submitterId')); } }, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'submissions', + underscored: true, associate : function(models) { Submission.hasMany(models.File); Submission.hasMany(models.Scorecard); - Submission.belongsTo(models.User, {foreignKey : 'submitterId'}); - Submission.belongsTo(models.Challenge, {foreignKey : 'challengeId'}); + Submission.belongsTo(models.User, {foreignKey : 'submitter_id'}); + Submission.belongsTo(models.Challenge, {foreignKey : 'challenge_id'}); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/models/user.js b/api/models/user.js index 27b9d2b..a31fa59 100644 --- a/api/models/user.js +++ b/api/models/user.js @@ -16,14 +16,31 @@ module.exports = function(sequelize, DataTypes) { var User = sequelize.define('User', { name: DataTypes.TEXT, email: DataTypes.TEXT, - createdBy: DataTypes.STRING(128), - updatedBy: DataTypes.STRING(128) + createdBy: { + type: DataTypes.STRING(128), + field: 'created_by' + }, + updatedBy: { + type: DataTypes.STRING(128), + field: 'updated_by' + } }, { tableName : 'users', + underscored: true, associate : function(models) { User.hasMany(models.Participant); User.hasMany(models.Scorecard); User.hasMany(models.Submission); + }, + getterMethods: { + // FIXME + // due to sequelize 1.7 bugfix or 2.0 release we must use getters createdAt and updatedAt + createdAt: function() { + return this.getDataValue('created_at'); + }, + updatedAt: function() { + return this.getDataValue('updated_at'); + } } }); diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index 0542236..afe8dc7 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -1571,10 +1571,10 @@ definitions: type: string description: The role the participant has on the challenge enum: - - owner - - submitter - - watcher - - reviewer + - OWNER + - SUBMITTER + - WATCHER + - REVIEWER createdAt: type: string format: date-time diff --git a/config/schema-migrations/20141010150000-enums.js b/config/schema-migrations/20141110184743-enums.js similarity index 73% rename from config/schema-migrations/20141010150000-enums.js rename to config/schema-migrations/20141110184743-enums.js index 058b8e6..13589fb 100644 --- a/config/schema-migrations/20141010150000-enums.js +++ b/config/schema-migrations/20141110184743-enums.js @@ -7,9 +7,9 @@ exports.up = function (db, callback) { db.runSql.bind(db, "CREATE TYPE enum_challenges_status AS ENUM ( 'DRAFT', 'SUBMISSION', 'REVIEW', 'COMPLETE');"), db.runSql.bind(db, - "CREATE TYPE \"enum_files_storageLocation\" AS ENUM ('local', 's3');"), + "CREATE TYPE \"enum_files_storage_location\" AS ENUM ('LOCAL', 'S3');"), db.runSql.bind(db, - "CREATE TYPE enum_participants_role AS ENUM ('owner', 'submitter', 'watcher', 'reviewer');"), + "CREATE TYPE enum_participants_role AS ENUM ('OWNER', 'SUBMITTER', 'WATCHER', 'REVIEWER');"), db.runSql.bind(db, "CREATE TYPE enum_scorecards_status AS ENUM ('VALID', 'INVALID', 'LATE');") ], callback); @@ -18,7 +18,7 @@ exports.up = function (db, callback) { exports.down = function (db, callback) { async.series([ db.runSql.bind(db, "DROP TYPE enum_challenges_status;"), - db.runSql.bind(db, "DROP TYPE \"enum_files_storageLocation\";"), + db.runSql.bind(db, "DROP TYPE \"enum_files_storage_location\";"), db.runSql.bind(db, "DROP TYPE enum_participants_role;"), db.runSql.bind(db, "DROP TYPE enum_scorecards_status;") ], callback); diff --git a/config/schema-migrations/20141010160840-tables.js b/config/schema-migrations/20141110184803-tables.js similarity index 52% rename from config/schema-migrations/20141010160840-tables.js rename to config/schema-migrations/20141110184803-tables.js index 34c634d..0c4f7a5 100644 --- a/config/schema-migrations/20141010160840-tables.js +++ b/config/schema-migrations/20141110184803-tables.js @@ -8,23 +8,23 @@ exports.up = function (db, callback) { db.runSql.bind(db, 'CREATE TABLE challenges ( ' + 'id bigserial NOT NULL, ' + - '"regStartAt" timestamp with time zone, ' + - '"subEndAt" timestamp with time zone, ' + - '"completedAt" timestamp with time zone, ' + + '"reg_start_at" timestamp with time zone, ' + + '"sub_end_at" timestamp with time zone, ' + + '"completed_at" timestamp with time zone, ' + 'title text NOT NULL DEFAULT \'Untitled Challenge\'::text, ' + 'overview character varying(140), ' + 'description text, ' + 'tags text[], ' + 'prizes NUMERIC(11,2)[], ' + 'account character varying(255), ' + - '"accountId" character varying(255), ' + + '"account_id" character varying(255), ' + '"source" text, ' + - '"sourceId" text, ' + + '"source_id" text, ' + 'status enum_challenges_status NOT NULL, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128) ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128) ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY challenges ADD CONSTRAINT challenges_pkey PRIMARY KEY (id);'), @@ -33,16 +33,16 @@ exports.up = function (db, callback) { 'CREATE TABLE files ( ' + 'id bigserial NOT NULL, ' + 'title text, ' + - '"filePath" text NOT NULL, ' + + '"file_path" text NOT NULL, ' + 'size bigint NOT NULL, ' + - '"fileName" text NOT NULL, ' + - '"storageLocation" "enum_files_storageLocation" NOT NULL, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128), ' + - '"submissionId" bigint, ' + - '"challengeId" bigint NOT NULL ' + + '"file_name" text NOT NULL, ' + + '"storage_location" "enum_files_storage_location" NOT NULL, ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128), ' + + '"submission_id" bigint, ' + + '"challenge_id" bigint NOT NULL ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY files ADD CONSTRAINT files_pkey PRIMARY KEY (id);'), @@ -51,12 +51,12 @@ exports.up = function (db, callback) { 'CREATE TABLE participants ( ' + 'id bigserial NOT NULL, ' + 'role enum_participants_role NOT NULL, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128), ' + - '"challengeId" bigint NOT NULL, ' + - '"userId" bigint NOT NULL ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128), ' + + '"challenge_id" bigint NOT NULL, ' + + '"user_id" bigint NOT NULL ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY participants ADD CONSTRAINT participants_pkey PRIMARY KEY (id);'), @@ -64,12 +64,12 @@ exports.up = function (db, callback) { db.runSql.bind(db, 'CREATE TABLE submissions ( ' + 'id bigserial NOT NULL, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128), ' + - '"challengeId" bigint NOT NULL, ' + - '"submitterId" bigint NOT NULL ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128), ' + + '"challenge_id" bigint NOT NULL, ' + + '"submitter_id" bigint NOT NULL ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY submissions ADD CONSTRAINT submissions_pkey PRIMARY KEY (id);'), @@ -77,20 +77,20 @@ exports.up = function (db, callback) { db.runSql.bind(db, 'CREATE TABLE scorecards ( ' + 'id bigserial NOT NULL, ' + - '"scoreSum" integer, ' + - '"scorePercent" double precision, ' + - '"scoreMax" double precision, ' + + '"score_sum" integer, ' + + '"score_percent" double precision, ' + + '"score_max" double precision, ' + 'status enum_scorecards_status, ' + 'pay boolean, ' + 'place integer, ' + 'prize double precision, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128), ' + - '"reviewerId" bigint NOT NULL, ' + - '"submissionId" bigint NOT NULL, ' + - '"challengeId" bigint NOT NULL ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128), ' + + '"reviewer_id" bigint NOT NULL, ' + + '"submission_id" bigint NOT NULL, ' + + '"challenge_id" bigint NOT NULL ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_pkey PRIMARY KEY (id);'), @@ -98,14 +98,14 @@ exports.up = function (db, callback) { db.runSql.bind(db, 'CREATE TABLE scorecard_items ( ' + 'id bigserial NOT NULL, ' + - '"requirementId" integer, ' + + '"requirement_id" integer, ' + 'score double precision, ' + 'comment text, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128), ' + - '"scorecardId" bigint NOT NULL ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128), ' + + '"scorecard_id" bigint NOT NULL ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY scorecard_items ADD CONSTRAINT scorecard_items_pkey PRIMARY KEY (id);'), @@ -113,10 +113,10 @@ exports.up = function (db, callback) { db.runSql.bind(db, 'CREATE TABLE requirements ( ' + 'id bigserial NOT NULL, ' + - '"requirementText" text, ' + - '"challengeId" bigint NOT NULL REFERENCES challenges("id") ON UPDATE CASCADE ON DELETE SET NULL, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL ' + + '"requirement_text" text, ' + + '"challenge_id" bigint NOT NULL REFERENCES challenges("id") ON UPDATE CASCADE ON DELETE SET NULL, ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL ' + ');'), // users table @@ -125,10 +125,10 @@ exports.up = function (db, callback) { 'id bigserial NOT NULL, ' + 'name text, ' + 'email text, ' + - '"createdAt" timestamp with time zone NOT NULL, ' + - '"updatedAt" timestamp with time zone NOT NULL, ' + - '"createdBy" character varying(128), ' + - '"updatedBy" character varying(128) ' + + '"created_at" timestamp with time zone NOT NULL, ' + + '"updated_at" timestamp with time zone NOT NULL, ' + + '"created_by" character varying(128), ' + + '"updated_by" character varying(128) ' + ');'), db.runSql.bind(db, 'ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (id);') diff --git a/package.json b/package.json index d59d4b2..3418284 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "multiparty": "^3.3.2", "newrelic": "^1.12.1", "pg": "^3.4.1", - "sequelize": "^1.7.10", + "sequelize": "2.0.0-rc2", "swagger-tools": ">=0.6.11", "time-grunt": "^0.3.1", "inflection": "1.5.1", diff --git a/test/controllers/challenges.js b/test/controllers/challenges.js index aa8760e..108b351 100644 --- a/test/controllers/challenges.js +++ b/test/controllers/challenges.js @@ -142,7 +142,6 @@ describe('Challenges Controller', function() { .get('/challenges/'+challengeId+'?fields=id') .end(function(err, res) { // verify response - console.log(res.body); res.status.should.equal(200); res.body.success.should.be.true; res.body.status.should.equal(200); @@ -456,7 +455,7 @@ describe('Challenges Controller', function() { filePath: '/uploads', size: 123, fileName: 'my-submission.zip', - storageLocation: 'local' + storageLocation: 'LOCAL' }; done(); }); @@ -469,7 +468,6 @@ describe('Challenges Controller', function() { .expect('Content-Type', /json/) .end(function(err, res) { // verify response - should.not.exist(err); res.status.should.equal(200); res.body.id.should.be.a.Number; res.body.result.success.should.be.true; @@ -1073,14 +1071,14 @@ describe('Challenges Controller', function() { cb(); }) .error(function(err) { - cb(); + cb(err); }); }, function(err) { - callback(); + callback(err); }); }); }, function(err) { - done(); + done(err); }); }); diff --git a/test/models/challenge.js b/test/models/challenge.js index fcc90e5..413360a 100644 --- a/test/models/challenge.js +++ b/test/models/challenge.js @@ -33,7 +33,7 @@ var entity; /** * Test Challenge model CRUD operations */ -describe('', function() { +describe.only('', function() { describe('Model Challenge:', function() { beforeEach(function(done) { // challenge data diff --git a/test/models/file.js b/test/models/file.js index 8cc49d1..607f803 100644 --- a/test/models/file.js +++ b/test/models/file.js @@ -39,8 +39,9 @@ describe('', function() { filePath: '/uploads', size: 123, fileName: 'my-submission.zip', - storageLocation: 'local', - challengeId: 111 + storageLocation: 'LOCAL', + challengeId: 111, + submissionId: 123 }; done(); }); diff --git a/test/models/participant.js b/test/models/participant.js index edfaa6f..e98df6e 100644 --- a/test/models/participant.js +++ b/test/models/participant.js @@ -35,7 +35,7 @@ describe('', function() { describe('Model Participant:', function() { beforeEach(function(done) { data = { - role: 'submitter', + role: 'SUBMITTER', challengeId: 111, userId: 222 }; @@ -138,7 +138,7 @@ describe('', function() { }); it('should able to update a participant with valid id', function(done) { - entity.role = 'reviewer'; + entity.role = 'REVIEWER'; // update an entity entity.save().success(function(updatedEntity) { updatedEntity.id.should.equal(entity.id);