# \`This schema does not exists\` when running \` forest schema:update\`

**URL:** <https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796>\
**Category:** Help me!\
**Created:** [January 5, 2023, 9:48pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796 "2023-01-05T21:48:52Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 5, 2023, 9:48pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/1 "2023-01-05T21:48:52Z")

</div>

I am trying to add a table to FA. There are only a few tables from this database that are displayed in the project but I can’t find how we a limiting the tables included - I see in the documentation how to accomplish this but I don’t see that we’ve done that in our code. So, I’m messing around trying to figure it out and, on my understanding, `forest schema:update` should update all of the models for both of our databases instead, I get this error.

In searching for an answer, I saw a help topic on this board that mentions that the default schema is `public`. I notice that, when using DBeaver, this database does not have a designated `schema` which is something I’ve not noticed nor encountered before.

This DB is mySQL and our “primary” DB in this project is postgreSQL if that lends any clarification to the issue.

## Feature(s) impacted

`forest schema:update`

## Observed behavior

`This schema does not exists.` error returned when running commnd.

## Expected behavior

Updates schema

## Context

- Project name: scratch-payment-service
- Team name: all
- Environment name: development
- Agent type & version: …
- Recent changes made on your end if any: …

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [January 6, 2023, 8:22am UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/2 "2023-01-06T08:22:30Z")

</div>

Hi @Brett_Belka 👋 can you share with us the whole error logs please?

For your `include/exclude` models question please refer to the [documentation](https://docs.forestadmin.com/documentation/how-tos/settings/include-exclude-models) and do the modification inside `middlewares/forestadmin.js`.

`forest schema:update` as the [documentation](https://docs.forestadmin.com/documentation/how-tos/maintain/update-your-models-definition) said create all missing needed files for a new table, or help you to update your Sequelize model if you change some fields or relations.

Let me know if that help 🙏

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 6, 2023, 4:26pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/3 "2023-01-06T16:26:40Z")

</div>

HI @Arnaud_Moncel

```javascript
√ Connecting to your database(s)
× This schema does not exists.

```

That’s it.

As I mentioned previously, I have already read this documentation regarding including/excluding specific models. Our middleware is not excluding any models, so they should all be there but only select models are there for this database (the other database includes all models in FA). I also tried specifically including just the model I need to add and I got the same error as above.

`forest schema:update` only returns the error above. It does nothing else.

My thought is that liana is looking for a `public` schema but, as far as I can tell, this database does not have anything referred to as a `schema` at all - it’s just a data base with tables…

Normally, when viewing through a db visualization tool (in this case DBeaver) I would expect:

```javascript
-Connection
  -databases
    -DB_name
      -schemas
        -public
          -tables

```

But for this database, I see

```javascript
-Connection
  -databases
    -DB_name
      -tables

```

I’m thinking the error might be resultant of liana looking for a default (`public`) schema but not seeing it because it doesn’t exist.

It may be worth noting that this is a mySQL database and the other database (which seems to work as expected) is postgreSQL.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [January 9, 2023, 5:11am UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/4 "2023-01-09T05:11:34Z")

</div>

Can you check if you have `DATABASE_SCHEMA` env var in your `.env` file and remove it if it is the case?  
Can you check if your connection uri begin like `mysql://....`?  
let me know if that help.

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 9, 2023, 2:45pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/5 "2023-01-09T14:45:28Z")

</div>

@Arnaud_Moncel

Thanks for the help!

We do have a `DATABASE_SCHEMA` env var but it is only utilized in the models for the database that does have the `public` schema. (The one that appears to be working correctly).

The `DATABASE_SCHEMA` var isn’t utilized in the models for this database.

As for the connections string, yes, it starts `mysql://...`

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 9, 2023, 9:10pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/6 "2023-01-09T21:10:55Z")

</div>

@Arnaud_Moncel I re-thought and then tried removing the `DATABASE_SCHEMA` env var as suggested and that indeed worked! Thanks!

However, it didn’t update the existing models files. Rather, it produced duplicates. Of everything.

I’ve tried excluding all models I don’t want, as well as including only those that I do as indicated here: [Include/exclude models - Developer guide](https://docs.forestadmin.com/documentation/how-tos/settings/include-exclude-models) but the result is the same.

As I was reviewing everything related to this, I also notice that there are a numbe of models in our FA code that are missing certain columns that have been added to the database. My reading of the FA documentation indicates to me that our schema should be updated everytime the program is run. The existing models in our FA code were last committed 3 years ago. I’m wondering if an older method was used to set up these models and whether I should be approaching this from a different angle than merely trying to add a single model. Perhaps a more comprehensive overhaul is necessary??

Or if, perhaps, it’s possible to simply add the specific model I need manually and I’m just not finding the method in the documentation…

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [January 11, 2023, 8:20am UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/8 "2023-01-11T08:20:16Z")

</div>

> [@Brett\_Belka](#):
>
> However, it didn’t update the existing models files. Rather, it produced duplicates. Of everything.

Do you run the update command with some options ?  
This command should only create missing models, route and forest files. To really update models after a column addition in the database or something like that you should remove impacted models and re-run the command.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [January 11, 2023, 8:27am UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/9 "2023-01-11T08:27:22Z")

</div>

> [@Brett\_Belka](#):
>
> I’ve tried excluding all models I don’t want, as well as including only those that I do as indicated here: [Include/exclude models - Developer guide](https://docs.forestadmin.com/documentation/how-tos/settings/include-exclude-models) but the result is the same.

If you use only `includedModels` and put the right model name it should work, i’ve juste tested now.  
Please be sure the name you put in string inside the included array is the one defined on your Sequelize models like below

```javascript
// the model name here is `user` not `User`
const User = sequelize.define('user', {

```

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 11, 2023, 5:22pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/10 "2023-01-11T17:22:19Z")

</div>

> [@\`This schema does not exists\` when running \` forest schema:update\`](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/8):
>
> Do you run the update command with some options ? This command should only create missing models, route and forest files. To really update models after a column addition in the database or something like that you should remove impacted models and re-run the command.

No options. It did create the missing models but it also created duplicate models for the models that already existed. The strangest part in my mind is that they were the exact same filename. I’m not sure how that was allowed…

> [@\`This schema does not exists\` when running \` forest schema:update\`](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/9):
>
> If you use only includedModels and put the right model name it should work, i’ve juste tested now. Please be sure the name you put in string inside the included array is the one defined on your Sequelize models like below // the model name here is `user` not `User` const User = sequelize.define('user', {

My interpretation was that using `includedModels` or `excludedModels` would not create them in the first place but now that I think more about it, that doesn’t really make sense. So, `forest schema:update` creates models/route/etc. for all tables regardless and then we can exclude or include them for use?

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 11, 2023, 5:40pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/11 "2023-01-11T17:40:16Z")

</div>

Pretty much all of our models have been updated but most of that data is not data that we need to actually view in FA, so I’m I’m looking at a complete overhaul, right?  
I’ll have to

1. Delete all models/routes files
2. run `forest schema:update` (update is a misnomer)
3. go through and manually change the view for each model to exclude unnecessary fields
4. go through and manually add all of the routes to disable the count middleware (unnecessary and are the most time-intensive queries on our database).

Are there any shortcuts to any of this that I’m not thinking of?

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [January 12, 2023, 8:23am UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/12 "2023-01-12T08:23:37Z")

</div>

> [@Brett\_Belka](#):
>
> The strangest part in my mind is that they were the exact same filename.

Yeah pretty strange indeed.

You are right ! We perform introspection on the whole database locally. Next you can exclude model for the UI. Sometimes you maybe want to uses some model internally and don’t want forest to be aware of.

It is not really necessary to remove route files.  
I suggest you to remove only models, especially if you already configured some behavior.  
Unfortunately we does not have shortcut to hide unnecessary field.

Let me know if that help 🙏

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 12, 2023, 5:27pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/13 "2023-01-12T17:27:45Z")

</div>

@Arnaud_Moncel Thanks!

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [January 13, 2023, 8:05am UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/14 "2023-01-13T08:05:21Z")

</div>

Don’t hesitate to ask more questions.  
Can I mark as resolve this thread?

---

<div class="post-metadata">

**Author:** ![Brett\_Belka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/brett_belka/32/4807_2.png) [@Brett\_Belka](https://community.forestadmin.com/u/Brett_Belka)\
**Post date:** [January 13, 2023, 5:17pm UTC](https://community.forestadmin.com/t/this-schema-does-not-exists-when-running-forest-schema-update/5796/15 "2023-01-13T17:17:54Z")

</div>

@Arnaud_Moncel yes. Thanks again!
