Skip to content
Snippets Groups Projects
Commit 4e5da035 authored by Ahmad Nadil's avatar Ahmad Nadil
Browse files

feat: database models

parent d3eaf464
1 merge request!1feat: database models
Pipeline #59253 canceled with stages
module.exports = (sequelize, DataTypes) => {
const Scholarship = sequelize.define("Scholarship", {
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
references: {
model: 'ScholarshipAdmin',
key: 'user_id',
},
onDelete: 'CASCADE',
},
scholarship_id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
},
title: {
type: DataTypes.STRING(50),
allowNull: false,
},
description: {
type: DataTypes.TEXT('long'),
},
short_description: {
type: DataTypes.STRING(255),
},
coverage: {
type: DataTypes.INTEGER,
allowNull: false,
},
contact_name: {
type: DataTypes.STRING(50),
allowNull: false,
},
contact_email: {
type: DataTypes.STRING(50),
allowNull: false,
},
}, {
tableName: 'Scholarship',
timestamps: false,
});
Scholarship.associate = function(models) {
Scholarship.belongsTo(models.ScholarshipAdmin, { foreignKey: 'user_id', onDelete: 'CASCADE' });
};
return Scholarship;
};
\ No newline at end of file
module.exports = (sequelize, DataTypes) => {
const ScholarshipAdmin = sequelize.define("ScholarshipAdmin", {
user_id: {
type: DataTypes.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey: true,
},
name: {
type: DataTypes.STRING(50),
allowNull: false,
},
password: {
type: DataTypes.STRING(255),
allowNull: false,
},
email: {
type: DataTypes.STRING(255),
allowNull: false,
unique: true,
},
image: {
type: DataTypes.STRING(255),
allowNull: false,
defaultValue: 'placeholder.jpg',
},
reset_token: {
type: DataTypes.STRING(64),
defaultValue: null,
},
is_verified: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
verify_token: {
type: DataTypes.STRING(64),
defaultValue: null,
},
organization: {
type: DataTypes.STRING(50),
allowNull: false,
},
}, {
tableName: 'ScholarshipAdmin',
timestamps: false,
});
return ScholarshipAdmin;
};
\ No newline at end of file
module.exports = (sequelize, DataTypes) => {
const ScholarshipType = sequelize.define("ScholarshipType", {
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
},
scholarship_id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
},
type: {
type: DataTypes.STRING(50),
allowNull: false,
},
}, {
tableName: 'ScholarshipType',
timestamps: false,
});
ScholarshipType.associate = function(models) {
ScholarshipType.belongsTo(models.Scholarship, {
foreignKey: 'user_id',
onDelete: 'CASCADE',
primaryKey: true
});
ScholarshipType.belongsTo(models.Scholarship, {
foreignKey: 'scholarship_id',
onDelete: 'CASCADE',
primaryKey: true
});
};
return ScholarshipType;
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment