Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] learn and earn user lesson #1030

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ module.exports = {
allowNull: false,
defaultValue: 0,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
},
down: (queryInterface) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
if (process.env.NODE_ENV === 'test') {
return;
}

await queryInterface.addColumn('learn_and_earn_user_lesson', 'createdAt', {
type: Sequelize.DATE,
allowNull: true
});

await queryInterface.sequelize.query(`
UPDATE learn_and_earn_user_lesson
SET "createdAt" = COALESCE("completionDate", CURRENT_DATE);
`);

await queryInterface.changeColumn('learn_and_earn_user_lesson', 'createdAt', {
type: Sequelize.DATE,
allowNull: false
});
},
async down(queryInterface, Sequelize) {
//
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class LearnAndEarnUserLessonModel extends Model<LearnAndEarnUserLesson, L
public completionDate!: Date;
public attempts!: number;
public points!: number;

public readonly createdAt!: Date;
}

export function initializeLearnAndEarnUserLesson(sequelize: Sequelize): typeof LearnAndEarnUserLessonModel {
Expand Down Expand Up @@ -62,12 +64,16 @@ export function initializeLearnAndEarnUserLesson(sequelize: Sequelize): typeof L
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0
},
createdAt: {
type: DataTypes.DATE,
allowNull: false
}
},
{
tableName: 'learn_and_earn_user_lesson',
modelName: 'learnAndEarnUserLesson',
timestamps: false,
updatedAt: false,
sequelize
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface LearnAndEarnUserLesson {
completionDate: Date;
attempts: number;
points: number;
createdAt: Date;
}

export interface LearnAndEarnUserLessonCreation {
Expand Down
Loading