Removed legacy navigationtree
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
1. Install dependencies with `yarn`
|
||||
1. Register a Slack app at https://api.slack.com/apps
|
||||
1. Copy the file `.env.sample` to `.env` and fill out the keys
|
||||
1. Run DB migrations `yarn run sequelize -- db:migrate`
|
||||
1. Run DB migrations `yarn sequelize -- db:migrate`
|
||||
1. Start the development server `yarn start`
|
||||
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
Sequelize is used to create and run migrations, for example:
|
||||
|
||||
```
|
||||
yarn run sequelize migration:create
|
||||
yarn run sequelize db:migrate
|
||||
yarn sequelize migration:create
|
||||
yarn sequelize db:migrate
|
||||
```
|
||||
|
||||
Or to run migrations on test database:
|
||||
|
||||
```
|
||||
yarn run sequelize db:migrate -- --env test
|
||||
yarn sequelize db:migrate -- --env test
|
||||
```
|
||||
|
@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
up: function(queryInterface, Sequelize) {
|
||||
queryInterface.removeColumn('collections', 'navigationTree');
|
||||
},
|
||||
|
||||
down: function(queryInterface, Sequelize) {
|
||||
queryInterface.addColumn('collections', 'navigationTree', {
|
||||
type: Sequelize.JSONB,
|
||||
allowNull: true,
|
||||
});
|
||||
},
|
||||
};
|
@ -29,7 +29,6 @@ const Collection = sequelize.define(
|
||||
creatorId: DataTypes.UUID,
|
||||
|
||||
/* type: atlas */
|
||||
navigationTree: DataTypes.JSONB, // legacy
|
||||
documentStructure: DataTypes.JSONB,
|
||||
},
|
||||
{
|
||||
@ -98,28 +97,6 @@ Collection.prototype.getUrl = function() {
|
||||
return `/collections/${this.id}`;
|
||||
};
|
||||
|
||||
Collection.prototype.getDocumentsStructure = async function() {
|
||||
// Lazy fill this.documentStructure - TMP for internal release
|
||||
if (!this.documentStructure) {
|
||||
this.documentStructure = this.navigationTree.children;
|
||||
|
||||
// Remove parent references from all root documents
|
||||
await this.navigationTree.children.forEach(async ({ id }) => {
|
||||
const document = await Document.findById(id);
|
||||
document.parentDocumentId = null;
|
||||
await document.save();
|
||||
});
|
||||
|
||||
// Remove root document
|
||||
const rootDocument = await Document.findById(this.navigationTree.id);
|
||||
await rootDocument.destroy();
|
||||
|
||||
await this.save();
|
||||
}
|
||||
|
||||
return this.documentStructure;
|
||||
};
|
||||
|
||||
Collection.prototype.addDocumentToStructure = async function(
|
||||
document,
|
||||
index,
|
||||
|
@ -19,7 +19,7 @@ async function present(ctx: Object, collection: Collection) {
|
||||
};
|
||||
|
||||
if (collection.type === 'atlas') {
|
||||
data.documents = await collection.getDocumentsStructure();
|
||||
data.documents = collection.documentStructure;
|
||||
}
|
||||
|
||||
if (collection.documents) {
|
||||
|
Reference in New Issue
Block a user