* Stash. Super rough progress * Stash * 'h' how toggles history panel Add documents.restore endpoint * Add tests for documents.restore endpoint * Document restore endpoint * Tiding, RevisionMenu, remove scroll dep * Add history menu item * Paginate loading * Fixed: Error boundary styling Select first revision faster * Diff summary, styling * Add history loading placeholder Fix move modal not opening * Fixes: Refreshing page on specific revision * documentation for document.revision * Better handle versions with no text changes (will no longer be created)
50 lines
903 B
JavaScript
50 lines
903 B
JavaScript
// @flow
|
|
import { DataTypes, sequelize } from '../sequelize';
|
|
|
|
const Revision = sequelize.define('revision', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
title: DataTypes.STRING,
|
|
text: DataTypes.TEXT,
|
|
|
|
userId: {
|
|
type: 'UUID',
|
|
allowNull: false,
|
|
references: {
|
|
model: 'users',
|
|
},
|
|
},
|
|
|
|
documentId: {
|
|
type: 'UUID',
|
|
allowNull: false,
|
|
references: {
|
|
model: 'documents',
|
|
onDelete: 'CASCADE',
|
|
},
|
|
},
|
|
});
|
|
|
|
Revision.associate = models => {
|
|
Revision.belongsTo(models.Document, {
|
|
as: 'document',
|
|
foreignKey: 'documentId',
|
|
});
|
|
Revision.belongsTo(models.User, {
|
|
as: 'user',
|
|
foreignKey: 'userId',
|
|
});
|
|
Revision.addScope(
|
|
'defaultScope',
|
|
{
|
|
include: [{ model: models.User, as: 'user', paranoid: false }],
|
|
},
|
|
{ override: true }
|
|
);
|
|
};
|
|
|
|
export default Revision;
|