tududi/backend/models/project.js
Chris 3c1209a5a9
Express migration (#80)
* Initial migration

* Cleanup and create migration scripts

* Introduce test suite

* Fix test issues

* Correct CORS issue and update paths

* Update README
2025-06-16 21:50:44 +03:00

69 lines
No EOL
1.2 KiB
JavaScript

const { DataTypes } = require('sequelize');
module.exports = (sequelize) => {
const Project = sequelize.define('Project', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING,
allowNull: false
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
active: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
pin_to_sidebar: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
priority: {
type: DataTypes.INTEGER,
allowNull: true,
validate: {
min: 0,
max: 2
}
},
due_date_at: {
type: DataTypes.DATE,
allowNull: true
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id'
}
},
area_id: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: 'areas',
key: 'id'
}
}
}, {
tableName: 'projects',
indexes: [
{
fields: ['user_id']
},
{
fields: ['area_id']
}
]
});
return Project;
};