tududi/backend/models/note.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

47 lines
No EOL
829 B
JavaScript

const { DataTypes } = require('sequelize');
module.exports = (sequelize) => {
const Note = sequelize.define('Note', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
title: {
type: DataTypes.STRING,
allowNull: true
},
content: {
type: DataTypes.TEXT,
allowNull: true
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id'
}
},
project_id: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: 'projects',
key: 'id'
}
}
}, {
tableName: 'notes',
indexes: [
{
fields: ['user_id']
},
{
fields: ['project_id']
}
]
});
return Note;
};