This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/server/migrations/20160626175224-add-revision...

71 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-06-26 18:23:03 +00:00
module.exports = {
2017-04-27 04:47:03 +00:00
up: function(queryInterface, Sequelize) {
2016-06-26 18:23:03 +00:00
queryInterface.createTable('revisions', {
id: {
type: 'UUID',
allowNull: false,
2017-04-27 04:47:03 +00:00
primaryKey: true,
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
title: {
type: 'CHARACTER VARYING',
allowNull: false,
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
text: {
type: 'TEXT',
allowNull: true,
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
html: {
type: 'TEXT',
allowNull: true,
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
preview: {
type: 'TEXT',
allowNull: true,
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
createdAt: {
type: 'TIMESTAMP WITH TIME ZONE',
allowNull: false,
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
updatedAt: {
type: 'TIMESTAMP WITH TIME ZONE',
allowNull: false,
2016-06-26 18:23:03 +00:00
},
userId: {
type: 'UUID',
allowNull: false,
references: {
model: 'users',
2017-04-27 04:47:03 +00:00
},
2016-06-26 18:23:03 +00:00
},
documentId: {
type: 'UUID',
allowNull: false,
references: {
model: 'documents',
onDelete: 'CASCADE',
2017-04-27 04:47:03 +00:00
},
2016-06-26 18:23:03 +00:00
},
});
2017-04-27 04:47:03 +00:00
queryInterface.addColumn('documents', 'lastModifiedById', {
type: 'UUID',
allowNull: false,
references: {
model: 'users',
},
});
2016-06-26 18:23:03 +00:00
2017-04-27 04:47:03 +00:00
queryInterface.addColumn('documents', 'revisionCount', {
type: 'INTEGER',
defaultValue: 0,
});
2016-06-26 18:23:03 +00:00
},
2017-04-27 04:47:03 +00:00
down: function(queryInterface, Sequelize) {
2016-06-26 18:23:03 +00:00
queryInterface.dropTable('revisions');
queryInterface.removeColumn('documents', 'lastModifiedById');
queryInterface.removeColumn('documents', 'revisionCount');
2017-04-27 04:47:03 +00:00
},
2016-06-26 18:23:03 +00:00
};