Skip to content

Commit

Permalink
tabela LearningPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
yaskisoba committed Nov 19, 2023
1 parent ca611f3 commit 5a95362
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
28 changes: 28 additions & 0 deletions backend/migrations/learning_paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

let learning_paths = { schema: 'learning_paths', tableName: 'tb_learning_paths'}

module.exports = {
up: async (queryInterface, Sequelize) => {
const transaction = await queryInterface.sequelize.transaction();

try {
await queryInterface.createTable(learning_paths, {
co_learning_paths: { type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true, allowNull: false },
ds_name: { type: Sequelize. STRING(40), allowNull: false },
ds_description: { type: Sequelize.STRING(150),allowNull: false },
ds_school_year: { type: Sequelize.INTEGER, allowNull: false },
ds_electives: { type: Sequelize.JSON, allowNull: false}
})

await transaction.commit()
}catch (e) {
await transaction.rollback()
throw e
}
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable(learning_paths)
}
}
33 changes: 33 additions & 0 deletions backend/models/schemas/LearningPaths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = (sequelize, DataTypes) => {
const LearningPaths = sequelize.define("LearningPaths", {
id: {
type: DataTypes.INTEGER,
field: "co_learning_paths",
primaryKey: true,
autoIncrement: true,
allowNull: false
},
name: {
type: DataTypes.STRING(40),
field: "ds_name",
allowNull: false
},
description: {
type: DataTypes.STRING(150),
field: "ds_description",
allowNull: false
},
school_year: {
type: DataTypes.INTEGER,
field: "ds_school_year",
allowNull: false
},
electives: {
type: DataTypes.JSON,
field: "ds_electives",
allowNull: false
}
})

return LearningPaths;
}

0 comments on commit 5a95362

Please sign in to comment.