Finished guestbook and gallery. started diary
This commit is contained in:
31
backend/models/community/diary.js
Normal file
31
backend/models/community/diary.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
|
||||
class Diary extends Model { }
|
||||
|
||||
Diary.init({
|
||||
userId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
text: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false,
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW,
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW,
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Diary',
|
||||
tableName: 'diary',
|
||||
schema: 'community',
|
||||
timestamps: true,
|
||||
});
|
||||
|
||||
export default Diary;
|
||||
35
backend/models/community/diary_history.js
Normal file
35
backend/models/community/diary_history.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
|
||||
class DiaryHistory extends Model { }
|
||||
|
||||
DiaryHistory.init({
|
||||
diaryId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
userId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
oldText: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false,
|
||||
},
|
||||
oldCreatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
oldUpdatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'DiaryHistory',
|
||||
tableName: 'diary_history',
|
||||
schema: 'community',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
export default DiaryHistory;
|
||||
47
backend/models/community/guestbook.js
Normal file
47
backend/models/community/guestbook.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
import User from './user.js';
|
||||
|
||||
const GuestbookEntry = sequelize.define('guestbook_entry', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
recipientId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: User,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
senderId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: User,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
senderUsername: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
contentHtml: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false,
|
||||
},
|
||||
imageUrl: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
}, {
|
||||
tableName: 'guestbook_entry',
|
||||
schema: 'community',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default GuestbookEntry;
|
||||
Reference in New Issue
Block a user