84 lines
1.9 KiB
JavaScript
84 lines
1.9 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
/**
|
|
* Schools Model - Quản lý thông tin 200 trường
|
|
*/
|
|
const School = sequelize.define('schools', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
school_code: {
|
|
type: DataTypes.STRING(20),
|
|
unique: false,
|
|
allowNull: false,
|
|
comment: 'Mã trường duy nhất',
|
|
},
|
|
school_name: {
|
|
type: DataTypes.STRING(200),
|
|
allowNull: false,
|
|
comment: 'Tên trường',
|
|
},
|
|
school_type: {
|
|
type: DataTypes.ENUM('preschool', 'primary', 'secondary', 'high_school'),
|
|
allowNull: false,
|
|
comment: 'Loại trường',
|
|
},
|
|
address: {
|
|
type: DataTypes.TEXT,
|
|
comment: 'Địa chỉ trường',
|
|
},
|
|
city: {
|
|
type: DataTypes.STRING(100),
|
|
comment: 'Thành phố',
|
|
},
|
|
district: {
|
|
type: DataTypes.STRING(100),
|
|
comment: 'Quận/Huyện',
|
|
},
|
|
phone: {
|
|
type: DataTypes.STRING(20),
|
|
comment: 'Số điện thoại',
|
|
},
|
|
logo: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: 'URL logo của trường',
|
|
},
|
|
config: {
|
|
type: DataTypes.JSON,
|
|
defaultValue: {},
|
|
comment: 'Cấu hình riêng của trường (JSON)',
|
|
},
|
|
is_active: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: true,
|
|
comment: 'Trạng thái hoạt động',
|
|
},
|
|
created_at: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW,
|
|
},
|
|
updated_at: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW,
|
|
},
|
|
}, {
|
|
tableName: 'schools',
|
|
timestamps: true,
|
|
underscored: true,
|
|
indexes: [
|
|
{ fields: ['school_code'], unique: true },
|
|
{ fields: ['school_type'] },
|
|
{ fields: ['is_active'] },
|
|
{ fields: ['city', 'district'] },
|
|
],
|
|
comment: 'Bảng quản lý thông tin 200 trường học',
|
|
});
|
|
|
|
module.exports = School;
|