Cannot add new collections

I updated schema files using forest schema:update command. It added new entries under model, forest and route directory. Refreshed the page and I got the collection listed on the UI after 5-10 second I get toast message again “A new version of your admin panel has been deployed. Please refresh your browser.” Once I refresh the page the new collection gets removed from the collection list
This happens everytime I restart my local server, collection is visible first then I get a message to reload and it gets removed.

Here a screenshot for error on console if I try to view the collection before refreshing the page again.

image

  • Project name: ReachTenants
  • Team name: Operations
  • Environment name: Development (Local)

Other details from forestadmin-shema.json file
“meta”: {
“liana”: “forest-express-mongoose”,
“liana_version”: “8.6.5”,
“stack”: {
“database_type”: “MongoDB”,
“engine”: “nodejs”,
“engine_version”: “16.17.1”,
“orm_version”: “6.2.6”
}
}

I noticed my “engine_version” is modified to “16.17.1” previously it was “14.17.4”

Hello @aayush-sinha,

Very clear message. Can you share with me your route file please ? And do you have any logs on your server side ?

Thanks,

Collection name is contents.

routes/contents.js

const express = require('express');
const { PermissionMiddlewareCreator } = require('forest-express-mongoose');
const { contents } = require('../models');

const router = express.Router();
const permissionMiddlewareCreator = new PermissionMiddlewareCreator('contents');

// This file contains the logic of every route in Forest Admin for the collection contents:
// - Native routes are already generated but can be extended/overriden - Learn how to extend a route here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/extend-a-route
// - Smart action routes will need to be added as you create new Smart Actions - Learn how to create a Smart Action here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/actions/create-and-manage-smart-actions

// Create a Content
router.post('/contents', permissionMiddlewareCreator.create(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record
  next();
});

// Update a Content
router.put('/contents/:recordId', permissionMiddlewareCreator.update(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record
  next();
});

// Delete a Content
router.delete('/contents/:recordId', permissionMiddlewareCreator.delete(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#delete-a-record
  next();
});

// Get a list of Contents
router.get('/contents', permissionMiddlewareCreator.list(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#get-a-list-of-records
  next();
});

// Get a number of Contents
router.get('/contents/count', permissionMiddlewareCreator.list(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#get-a-number-of-records
  // Improve peformances disabling pagination: https://docs.forestadmin.com/documentation/reference-guide/performance#disable-pagination-count
  next();
});

// Get a Content
router.get('/contents/\\b(?!count\\b):recordId', permissionMiddlewareCreator.details(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#get-a-record
  next();
});

// Export a list of Contents
router.get('/contents.csv', permissionMiddlewareCreator.export(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#export-a-list-of-records
  next();
});

// Delete a list of Contents
router.delete('/contents', permissionMiddlewareCreator.delete(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#delete-a-list-of-records
  next();
});

module.exports = router;

Screenshot of server log:

I have the same problem too. It seems like it was updated on my console but not on my dashboard. Can anyone help me ?

Thanks for the sharing. Did you allow browse on the collection through the roles ?

You can have a look here: project settings → roles → your current role → content collection :slight_smile:

The corresponding cases should be ticked.

i haven’t deploy it yet. So the roles is not already enable.

The project is not deployed on production yet. So cannot add roles.

@lclisson Please let me know what should i do? Need to get this working ASAP.

Ok thanks for the clarification. Know that we are currently working on your issue.

Can you share your related model ?
+ Before disappearing, can you confirm that the content collection is visible through the collection list ?

Thanks

Hey @aayush-sinha :wave:

I can see on our end that we are received multiples schema

image

These 2 schemas are always in conflict (One adding a collection, then one remove it). Is it possible that your FOREST_ENV_SECRET is shared between multiples developers?

Facing issue with these two collections (added both of them recently):

  1. model/content.js
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models

module.exports = (mongoose, Mongoose) => {
  // This section contains the properties of your model, mapped to your collection's properties.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const schema = Mongoose.Schema({
    'answer': String,
    'updatedAt': Date,
    'type': String,
    'question': String,
    'createdAt': Date,
  }, {
    timestamps: false,
  });

  return mongoose.model('contents', schema, 'contents');
};

  1. models/projects.js
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models

module.exports = (mongoose, Mongoose) => {
  // This section contains the properties of your model, mapped to your collection's properties.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const schema = Mongoose.Schema({
    'createdAt': Date,
    'users': { type: [Mongoose.Schema.Types.ObjectId], ref: 'users' },
    'projectName': String,
    'updatedAt': Date,
    'projectAddress': String,
  }, {
    timestamps: false,
  });

  return mongoose.model('projects', schema, 'projects');
};

Yes I am able to view the records till the time collection is visible.

Hi @jeffladiray
No currently the secrect keys are just with me. And I’m running it on my local itself. I had initiated the process of deployment yesterday but did not complete because my admin backend url was not yet ready.
I can see an incomplete draft for new environment “Dev” under my project setting > environment page.

1 Like

I can see 2 different IPs sending a different schema though, using the same FOREST_ENV_SECRET.

I can share those to you privately if they can help investigate the issue on your end.

1 Like