Schema isn't regenerating anymore but I don't know since when

Hey!

I don’t really have an idea why but my .forestadmin-schema.json isn’t getting updated anymore automatically…

So now, I have to updated it manually each time I add a smart action or a smart field… Do you have any idea in which direction I should investigate to? I have no error in the output or anywhere else…

I am quite sure you can’t access the code of the project but I am open to share the code if you need to.

Thanks!

Max

Hi @Emixam23 !
You should never update the schema manually as it should be re-generated every time you launch your server.
Do you have any error log when you start your server ?

Hey!

Sorry for the late response…
I know right, it should be automatic but as of today, it’s not anymore so I do it manually each time I need to update it…
I have absolutely no log(s) about it… However, if it’s missing (like if I remove the file), it throw an error as schema couldn’t be found :confused:

I don’t really know how I can provide to you information but I am open to share the code with you if required (with a dataset of course)

Best,

Max

Hello @Emixam23 :wave:

Could you pin the version of forest-express-{mongoose|sequelize} you are using? (Even forest-express if it is still in your package.json?). It would be easier to investigate this issue, since a few contributions happened this year on the schema generation.

Thanks

Hey!

Of course, sorry I should have gave you everything before…

{
  "name": "backoffice-forest-admin",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node ./dist/server.js",
    "legacy-start": "node server.js",
    "build": "tsc",
    "start-dev": "tsc-watch --project ./tsconfig.json --noClear --onSuccess \"nodemon --watch ./dist ./dist/server.js\""
  },
  "dependencies": {
    "@google-cloud/storage": "^5.7.4",
    "@types/express": "^4.17.11",
    "@types/forest-express-mongoose": "^6.3.3",
    "@types/mongoose": "^5.10.3",
    "@types/node": "^14.14.25",
    "body-parser": "1.19.0",
    "chalk": "~1.1.3",
    "cookie-parser": "1.4.4",
    "cors": "2.8.5",
    "debug": "~4.0.1",
    "dotenv": "~6.1.0",
    "express": "~4.17.1",
    "express-jwt": "5.3.1",
    "forest-express-mongoose": "^6.0.0",
    "mongoose": "~5.8.2",
    "morgan": "1.9.1",
    "nodemon": "^2.0.7",
    "require-all": "^3.0.0",
    "tsc-watch": "^4.2.9",
    "typescript": "^4.1.3"
  }
}

Alright, thanks and sorry to not be able to provide logs or anything but I don’t have anything :confused:

Thanks,

Max

Hi @Emixam23 :wave:
Have you set the FOREST_DISABLE_AUTO_SCHEMA_APPLY env var?
Can you give me the exact version of forest-express-mongoose please by

npm ls forest-express-mongoose

Have you change the default architecture of your project?

Hello :slight_smile:

Sorry for the late reply I am a bit busy ^^’
First, thanks for your answer :slight_smile:

Regarding the npm ls forest-express-mongoose, I get the following:

C:\Workspace\forest-admin\backoffice-forest-admin>npm ls forest-express-mongoose

(node:4920) ExperimentalWarning: The fs.promises API is experimental

backoffice-forest-admin@0.0.1 C:\Workspace\forest-admin\backoffice-forest-admin

`-- forest-express-mongoose@6.6.3

Now, regarding the architecture, I don’t know if chaging the language of the files from JS to TS means “chaging the architecture” to you but that the only things that comes up to me as of today :confused:

Also, I don’t have at all this environment variable set → FOREST_DISABLE_AUTO_SCHEMA_APPLY

Thanks again :slight_smile: I will try to be more reactive next time :slight_smile:

Best,

Max

Hello @Emixam23,

Could you please tell me if you are making changes to your development or production environment?

Hey :slight_smile:

I am not sure to get you… I am actually editing the layout (as well as the .forestadmin-schema.json) in the “local (dev)” environment and when I need to, I copy the “layout configuration” to the other projects env using your system in the top banner (that emails me once OK)

I hope I could answer as expected to your interrogation :slight_smile:

Thanks,

Max

Hi :wave: @Emixam23, I have some questions.
Sorry for the first ones, Do you restart your server when you change something to regenerate the schema?
How do you start your server?

I have maybe an idea to debug this.
It seems that there are a silent error, I think due to your model definition.
What I suggest is to try to:

  1. FOREST_DISABLE_AUTO_SCHEMA_APPLY=true put this env variable on your .env file. this variable will prevent, for the next step, the synchronization of your schema on our server.
    2 . Try to remove / comment your models one by one and restart your server until the .forestadmin-schema.json re-generates again.

I hope it’s help, let me know if my suggestion help you find the model involved.

Hey!

Sorry for the late reply :confused:

So, i just tried out and… nothing :’(

  • I commented out all my schemas and models (kept only interfaces to do not have to comment out the whole project)
  • I removed the .forestadmin-schema.json file
  • I start the server with FOREST_DISABLE_AUTO_SCHEMA_APPLY=true
  • I start the server with FOREST_DISABLE_AUTO_SCHEMA_APPLY=false

logs on start (no matter if FOREST_DISABLE_AUTO_SCHEMA_APPLY is true or false)

[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): dist\**\*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./dist/server.js`
Your application is listening on port 3310.
[forest] ���  The .forestadmin-schema.json file does not exist.
[forest] ���  The schema cannot be synchronized with Forest Admin servers.
Your admin panel is available here: https://app.forestadmin.com/projects

Hope it helps :confused:

Thanks again for your help!

Best,

Max

Hello @Emixam23,

Let’s try something :slight_smile:
Could you create a new project on Forest Admin with the exact same database and look a what the last version of lumber generated for you.
Tell me if you see any big differences between the models regeneration. Maybe we could have a clue there.
See if the .forestadmin-schema.json is well generated.

Let me know :wink:

Hi :slight_smile: Ok i will try that up :slight_smile:

I updated my database schema (added two new collections) so once I work back on forest admin (releasing my new feature) i will do so :slight_smile:

Thanks,

Max

Hi @Emixam23,

Reading your server start logs:

[forest] ���  The .forestadmin-schema.json file does not exist.
[forest] ���  The schema cannot be synchronized with Forest Admin servers.

I wonder if you don’t have an environment variable misconfiguration in your development environment.
Can you check the value of your NODE_ENV?

Unless the value is "dev" or "development", your local server will behave as a “production” admin backend and will never try to introspect your models and generate the .forestadmin-schema.json.
It will sent the .forestadmin-schema.json as versioned.

More informations available here:
https://docs.forestadmin.com/documentation/reference-guide/models#the-forestadmin-schema-json-file

Let us know if it helps.

Hey :slight_smile:

Thanks for your feedbacks, actually I have NODE_ENV=local.
This can vary between:

NODE_ENV=local
NODE_ENV=staging
NODE_ENV=production

Based on the environment of course… So what you’re suggesting would be to set “dev” instead of “local”?

Thanks,

Max

Hey @Emixam23 :wave:

As stated by @arnaud, the .forestadmin-schema.json will only be regenerated if NODE_ENV is dev or development so yes, it worth giving this a shot, and it will definitely allow you to regenerate the forestadmin-schema when modifying your models.

The other values for NODE_ENV to be used on remote environment should be displayed on the deploy-to-remote/production flow and are mandatory for everything to work as expected.

Let us know if it fixes your issue :pray: