feat: table migration to database function
This commit is contained in:
parent
f4a3e6d02d
commit
48c2634c62
|
|
@ -318,7 +318,6 @@ export const monitoringStudentProgressById = async (req, res) => {
|
|||
const topicName = stdLearning.level.levelTopic.NAME_TOPIC;
|
||||
const sectionName = stdLearning.level.levelTopic.topicSection.NAME_SECTION;
|
||||
|
||||
// Fetch levels with pagination, search, and sort
|
||||
const levels = await models.StdLearning.findAndCountAll({
|
||||
where: {
|
||||
ID: userID,
|
||||
|
|
@ -333,16 +332,17 @@ export const monitoringStudentProgressById = async (req, res) => {
|
|||
{
|
||||
FEEDBACK_STUDENT: { [models.Op.like]: `%${search}%` },
|
||||
},
|
||||
// {
|
||||
// [models.Sequelize.fn('DATE_FORMAT', models.Sequelize.col('STUDENT_START'), '%Y-%m-%d')]: {
|
||||
// [models.Op.like]: `%${search}%`,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// [models.Sequelize.fn('DATE_FORMAT', models.Sequelize.col('STUDENT_FINISH'), '%Y-%m-%d')]: {
|
||||
// [models.Op.like]: `%${search}%`,
|
||||
// },
|
||||
// },
|
||||
// Search student_start dan student_finish belum bisa
|
||||
{
|
||||
[models.Sequelize.fn('DATE_FORMAT', models.Sequelize.col('STUDENT_START'), '%Y-%m-%d')]: {
|
||||
[models.Op.like]: `%${search}%`,
|
||||
},
|
||||
},
|
||||
{
|
||||
[models.Sequelize.fn('DATE_FORMAT', models.Sequelize.col('STUDENT_FINISH'), '%Y-%m-%d')]: {
|
||||
[models.Op.like]: `%${search}%`,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
|
|
@ -388,7 +388,6 @@ export const monitoringStudentProgressById = async (req, res) => {
|
|||
return 0;
|
||||
});
|
||||
|
||||
// Pagination logic
|
||||
const paginatedResult = levelArray.slice((page - 1) * limit, page * limit);
|
||||
const totalPages = Math.ceil(levels.count / limit);
|
||||
const currentPage = parseInt(page);
|
||||
|
|
|
|||
44
database/migrations/20241014033659-create-teacher.cjs
Normal file
44
database/migrations/20241014033659-create-teacher.cjs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("teacher", {
|
||||
ID_GURU: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
NIP: {
|
||||
type: Sequelize.BIGINT(11),
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("teacher", {
|
||||
fields: ["NIP"],
|
||||
type: "unique",
|
||||
name: "teacher_unique_nip",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("teacher", {
|
||||
fields: ["ID"],
|
||||
type: "foreign key",
|
||||
name: "FK_MERANGKAP",
|
||||
references: {
|
||||
table: "users",
|
||||
field: "ID",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("teacher");
|
||||
},
|
||||
};
|
||||
43
database/migrations/20241014063413-create-report.cjs
Normal file
43
database/migrations/20241014063413-create-report.cjs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("report", {
|
||||
ID_REPORT: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
REPORTS: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: false,
|
||||
},
|
||||
TIME_REPORT: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("report", {
|
||||
fields: ["ID"],
|
||||
type: "foreign key",
|
||||
name: "FK_MELAPORKAN",
|
||||
references: {
|
||||
table: "users",
|
||||
field: "ID",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("report");
|
||||
},
|
||||
};
|
||||
31
database/migrations/20241014063944-create-class.cjs
Normal file
31
database/migrations/20241014063944-create-class.cjs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("class", {
|
||||
ID_CLASS: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
NAME_CLASS: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
TOTAL_STUDENT: {
|
||||
type: Sequelize.INTEGER(11),
|
||||
allowNull: true,
|
||||
},
|
||||
TIME_CLASS: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("class");
|
||||
},
|
||||
};
|
||||
60
database/migrations/20241014064557-create-student.cjs
Normal file
60
database/migrations/20241014064557-create-student.cjs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("student", {
|
||||
ID_SISWA: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_CLASS: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
ID: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
NISN: {
|
||||
type: Sequelize.BIGINT(11),
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student", {
|
||||
fields: ["NISN"],
|
||||
type: "unique",
|
||||
name: "student_unique_nisn",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student", {
|
||||
fields: ["ID_CLASS"],
|
||||
type: "foreign key",
|
||||
name: "FK_MENAMPUNG",
|
||||
references: {
|
||||
table: "class",
|
||||
field: "ID_CLASS",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "SET NULL",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student", {
|
||||
fields: ["ID"],
|
||||
type: "foreign key",
|
||||
name: "FK_MENJADI",
|
||||
references: {
|
||||
table: "users",
|
||||
field: "ID",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("student");
|
||||
},
|
||||
};
|
||||
40
database/migrations/20241014065005-create-section.cjs
Normal file
40
database/migrations/20241014065005-create-section.cjs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("section", {
|
||||
ID_SECTION: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
NAME_SECTION: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
DESCRIPTION_SECTION: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
THUMBNAIL: {
|
||||
type: Sequelize.STRING(255),
|
||||
allowNull: true,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
},
|
||||
TIME_SECTION: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("section");
|
||||
},
|
||||
};
|
||||
52
database/migrations/20241014065621-create-topic.cjs
Normal file
52
database/migrations/20241014065621-create-topic.cjs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("topic", {
|
||||
ID_TOPIC: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_SECTION: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
NAME_TOPIC: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
DESCRIPTION_TOPIC: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
},
|
||||
TIME_TOPIC: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("topic", {
|
||||
fields: ["ID_SECTION"],
|
||||
type: "foreign key",
|
||||
name: "FK_MEMILIKI",
|
||||
references: {
|
||||
table: "section",
|
||||
field: "ID_SECTION",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("topic");
|
||||
},
|
||||
};
|
||||
115
database/migrations/20241014070248-create-level.cjs
Normal file
115
database/migrations/20241014070248-create-level.cjs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("level", {
|
||||
ID_LEVEL: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_TOPIC: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_SECTION: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
NAME_LEVEL: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
CONTENT: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
AUDIO: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
IMAGE: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
VIDEO: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
IS_PRETEST: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
},
|
||||
ROUTE_1: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
ROUTE_2: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
ROUTE_3: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
ROUTE_4: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
ROUTE_5: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
ROUTE_6: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
},
|
||||
TIME_LEVEL: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("level", {
|
||||
fields: ["ID_TOPIC"],
|
||||
type: "foreign key",
|
||||
name: "FK_BERHUBUNGAN",
|
||||
references: {
|
||||
table: "topic",
|
||||
field: "ID_TOPIC",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("level", {
|
||||
fields: ["ID_SECTION"],
|
||||
type: "foreign key",
|
||||
name: "FK_MEMPUNYAI",
|
||||
references: {
|
||||
table: "section",
|
||||
field: "ID_SECTION",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("level");
|
||||
},
|
||||
};
|
||||
73
database/migrations/20241014070802-create-exercise.cjs
Normal file
73
database/migrations/20241014070802-create-exercise.cjs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("admin_exercise", {
|
||||
ID_ADMIN_EXERCISE: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_LEVEL: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
TITLE: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
QUESTION: {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: false,
|
||||
},
|
||||
SCORE_WEIGHT: {
|
||||
type: Sequelize.INTEGER(11),
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
},
|
||||
QUESTION_TYPE: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
AUDIO: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
VIDEO: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
IMAGE: {
|
||||
type: Sequelize.STRING(1024),
|
||||
allowNull: true,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
},
|
||||
TIME_ADMIN_EXC: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("admin_exercise", {
|
||||
fields: ["ID_LEVEL"],
|
||||
type: "foreign key",
|
||||
name: "FK_MEMBUTUHKAN",
|
||||
references: {
|
||||
table: "level",
|
||||
field: "ID_LEVEL",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("admin_exercise");
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("multiple_choices", {
|
||||
ID_MULTIPLE_CHOICES: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_ADMIN_EXERCISE: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
OPTION_A: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_B: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_C: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_D: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_E: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
ANSWER_KEY: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
TIME_MULTIPLE_CHOICES: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("multiple_choices", {
|
||||
fields: ["ID_ADMIN_EXERCISE"],
|
||||
type: "foreign key",
|
||||
name: "FK_MC_TERDAPAT",
|
||||
references: {
|
||||
table: "admin_exercise",
|
||||
field: "ID_ADMIN_EXERCISE",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("multiple_choices");
|
||||
},
|
||||
};
|
||||
47
database/migrations/20241014072116-create-matching-pairs.cjs
Normal file
47
database/migrations/20241014072116-create-matching-pairs.cjs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("matching_pairs", {
|
||||
ID_MATCHING_PAIRS: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_ADMIN_EXERCISE: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
LEFT_PAIR: {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
RIGHT_PAIR: {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
TIME_MATCHING_PAIRS: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("matching_pairs", {
|
||||
fields: ["ID_ADMIN_EXERCISE"],
|
||||
type: "foreign key",
|
||||
name: "FK_MP_TERDAPAT",
|
||||
references: {
|
||||
table: "admin_exercise",
|
||||
field: "ID_ADMIN_EXERCISE",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("matching_pairs");
|
||||
},
|
||||
};
|
||||
43
database/migrations/20241014072654-create-true-false.cjs
Normal file
43
database/migrations/20241014072654-create-true-false.cjs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("true_false", {
|
||||
ID_TRUE_FALSE: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_ADMIN_EXERCISE: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
IS_TRUE: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: false,
|
||||
},
|
||||
TIME_TRUE_FALSE: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("true_false", {
|
||||
fields: ["ID_ADMIN_EXERCISE"],
|
||||
type: "foreign key",
|
||||
name: "FK_TF_TERDAPAT",
|
||||
references: {
|
||||
table: "admin_exercise",
|
||||
field: "ID_ADMIN_EXERCISE",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("true_false");
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("student_learning", {
|
||||
ID_STUDENT_LEARNING: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_LEVEL: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
STUDENT_START: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
STUDENT_FINISH: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
SCORE: {
|
||||
type: Sequelize.INTEGER(11),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
IS_PASS: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
NEXT_LEARNING: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
FEEDBACK_STUDENT: {
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
TIME_LEARNING: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
onUpdate: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student_learning", {
|
||||
fields: ["ID"],
|
||||
type: "foreign key",
|
||||
name: "FK_MENGAKSES",
|
||||
references: {
|
||||
table: "users",
|
||||
field: "ID",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student_learning", {
|
||||
fields: ["ID_LEVEL"],
|
||||
type: "foreign key",
|
||||
name: "FK_DIGUNAKAN",
|
||||
references: {
|
||||
table: "level",
|
||||
field: "ID_LEVEL",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student_learning", {
|
||||
fields: ["NEXT_LEARNING"],
|
||||
type: "foreign key",
|
||||
name: "FK_MELANJUTKAN",
|
||||
references: {
|
||||
table: "level",
|
||||
field: "ID_LEVEL",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("student_learning");
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("student_exercise", {
|
||||
ID_STUDENT_EXERCISE: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_ADMIN_EXERCISE: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_STUDENT_LEARNING: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
ANSWER_STUDENT: {
|
||||
type: Sequelize.STRING(256),
|
||||
allowNull: false,
|
||||
},
|
||||
IS_CORRECT: {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
RESULT_SCORE_STUDENT: {
|
||||
type: Sequelize.FLOAT,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
TIME_STUDENT_EXC: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
onUpdate: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student_exercise", {
|
||||
fields: ["ID_ADMIN_EXERCISE"],
|
||||
type: "foreign key",
|
||||
name: "FK_MENGERJAKAN",
|
||||
references: {
|
||||
table: "admin_exercise",
|
||||
field: "ID_ADMIN_EXERCISE",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("student_exercise", {
|
||||
fields: ["ID_STUDENT_LEARNING"],
|
||||
type: "foreign key",
|
||||
name: "FK_MELIBATKAN",
|
||||
references: {
|
||||
table: "student_learning",
|
||||
field: "ID_STUDENT_LEARNING",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("student_exercise");
|
||||
},
|
||||
};
|
||||
75
database/migrations/20241014082720-create-monitoring.cjs
Normal file
75
database/migrations/20241014082720-create-monitoring.cjs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
const { Sequelize } = require("sequelize");
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.createTable("monitoring", {
|
||||
ID_MONITORING: {
|
||||
type: Sequelize.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_STUDENT_LEARNING: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
ID_CLASS: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
ID_GURU: {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
FEEDBACK_GURU: {
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
},
|
||||
TIME_MONITORING: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW,
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("monitoring", {
|
||||
fields: ["ID_STUDENT_LEARNING"],
|
||||
type: "foreign key",
|
||||
name: "FK_MENGACU",
|
||||
references: {
|
||||
table: "student_learning",
|
||||
field: "ID_STUDENT_LEARNING",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("monitoring", {
|
||||
fields: ["ID_CLASS"],
|
||||
type: "foreign key",
|
||||
name: "FK_MENDAPATKAN",
|
||||
references: {
|
||||
table: "class",
|
||||
field: "ID_CLASS",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "SET NULL",
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint("monitoring", {
|
||||
fields: ["ID_GURU"],
|
||||
type: "foreign key",
|
||||
name: "FK_DILAKUKAN",
|
||||
references: {
|
||||
table: "teacher",
|
||||
field: "ID_GURU",
|
||||
},
|
||||
onUpdate: "CASCADE",
|
||||
onDelete: "SET NULL",
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable("monitoring");
|
||||
},
|
||||
};
|
||||
|
|
@ -39,7 +39,7 @@ const ExerciseModel = (DataTypes) => {
|
|||
},
|
||||
},
|
||||
SCORE_WEIGHT: {
|
||||
type: DataTypes.INTEGER(6),
|
||||
type: DataTypes.INTEGER(11),
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
validate: {
|
||||
|
|
@ -66,7 +66,7 @@ const ExerciseModel = (DataTypes) => {
|
|||
allowNull: true,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ const LevelModel = (DataTypes) => {
|
|||
allowNull: true,
|
||||
},
|
||||
IS_PRETEST: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
@ -91,7 +91,7 @@ const LevelModel = (DataTypes) => {
|
|||
allowNull: false,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const SectionModel = (DataTypes) => {
|
|||
allowNull: true,
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const TopicModel = (DataTypes) => {
|
|||
},
|
||||
},
|
||||
IS_DELETED: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
|
|||
|
|
@ -25,28 +25,28 @@ const MultipleChoicesModel = (DataTypes) => {
|
|||
},
|
||||
},
|
||||
OPTION_A: {
|
||||
type: DataTypes.STRING(200),
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_B: {
|
||||
type: DataTypes.STRING(200),
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_C: {
|
||||
type: DataTypes.STRING(200),
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_D: {
|
||||
type: DataTypes.STRING(200),
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
OPTION_E: {
|
||||
type: DataTypes.STRING(200),
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: true,
|
||||
},
|
||||
ANSWER_KEY: {
|
||||
type: DataTypes.STRING(5),
|
||||
allowNull: true,
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
TIME_MULTIPLE_CHOICES: {
|
||||
type: DataTypes.DATE,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const TrueFalseModel = (DataTypes) => {
|
|||
},
|
||||
IS_TRUE: {
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: true,
|
||||
allowNull: false,
|
||||
},
|
||||
TIME_TRUE_FALSE: {
|
||||
type: DataTypes.DATE,
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ const StdExerciseModel = (DataTypes) => {
|
|||
},
|
||||
},
|
||||
ANSWER_STUDENT: {
|
||||
type: DataTypes.CHAR(1),
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: false,
|
||||
validate: {
|
||||
notEmpty: true,
|
||||
},
|
||||
},
|
||||
IS_CORRECT: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
@ -52,7 +52,7 @@ const StdExerciseModel = (DataTypes) => {
|
|||
},
|
||||
},
|
||||
RESULT_SCORE_STUDENT: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ const StdLearningModel = (DataTypes) => {
|
|||
defaultValue: null,
|
||||
},
|
||||
SCORE: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER(11),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
IS_PASS: {
|
||||
type: DataTypes.INTEGER(1),
|
||||
type: DataTypes.TINYINT(1),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const ReportModel = (DataTypes) => {
|
|||
},
|
||||
},
|
||||
REPORTS: {
|
||||
type: DataTypes.STRING,
|
||||
type: DataTypes.STRING(256),
|
||||
allowNull: false,
|
||||
validate: {
|
||||
notEmpty: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user