# Bake w/ specify database schema

**URL:** <https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698>\
**Category:** Need Help\
**Created:** [April 21, 2020, 4:59pm UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698 "2020-04-21T16:59:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taco](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/taco/32/1775_2.png) [@Taco](https://discourse.cakephp.org/u/Taco)\
**Post date:** [April 21, 2020, 4:59pm UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/1 "2020-04-21T16:59:24Z")

</div>

Is it possible to specify the PostgreSQL database schema with the bake command?

I have tables in other schemas other than public in the same database that I want to bake. I am using CakePHP 4.0.6 and bake 2.0.9

---

<div class="post-metadata">

**Author:** ![coreytaylor](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coreytaylor](https://discourse.cakephp.org/u/coreytaylor)\
**Post date:** [April 22, 2020, 10:38am UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/2 "2020-04-22T10:38:33Z")

</div>

You should be able to specify it with `--table` option.

Run `bin/cake bake model --help` to see all the options.

---

<div class="post-metadata">

**Author:** ![Taco](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/taco/32/1775_2.png) [@Taco](https://discourse.cakephp.org/u/Taco)\
**Post date:** [April 22, 2020, 3:58pm UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/3 "2020-04-22T15:58:31Z")

</div>

Thanks for the suggestion, I had tried that though, and it won’t find it. If my schema is called “private” and my table is called “soitem”, what would the syntax be? I tried a few variations.

This unfortunately is really holding me up though 😭

---

<div class="post-metadata">

**Author:** ![coreytaylor](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coreytaylor](https://discourse.cakephp.org/u/coreytaylor)\
**Post date:** [April 22, 2020, 4:13pm UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/4 "2020-04-22T16:13:41Z")

</div>

Does `--table "private.soitem"` not work? If so, can you create an issue if your setup?

> **[cakephp/bake](https://github.com/cakephp/bake/issues)**
>
> The Bake Command Plugin. Contribute to cakephp/bake development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Taco](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/taco/32/1775_2.png) [@Taco](https://discourse.cakephp.org/u/Taco)\
**Post date:** [April 22, 2020, 4:22pm UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/5 "2020-04-22T16:22:48Z")

</div>

No, it does not, instead it just says “Choose a model to bake …”. Here is the output:

```
[vagrant@localhost:/path/to/my/app/]$ bin/cake bake model --table "private.soitem"
Choose a model to bake from the following:
- Categories
- GridStates
- NotesSoLines
- ProductCodes
[vagrant@localhost:/path/to/my/app/]$
```

---

<div class="post-metadata">

**Author:** ![coreytaylor](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coreytaylor](https://discourse.cakephp.org/u/coreytaylor)\
**Post date:** [April 23, 2020, 2:48am UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/6 "2020-04-23T02:48:03Z")

</div>

You have to specify the model name to bake as noted in the options help.

---

<div class="post-metadata">

**Author:** ![Taco](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/taco/32/1775_2.png) [@Taco](https://discourse.cakephp.org/u/Taco)\
**Post date:** [April 23, 2020, 9:18pm UTC](https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698/7 "2020-04-23T21:18:33Z")

</div>

you’re my hero! Not only did that let me bake a non-public schema, but it also let me bake a database view into a cake model, which I also was needing to figure out, but didn’t mention. I put the command that worked for me in the issue on github. Kudos!

> <https://github.com/cakephp/bake/issues/682>
>
> Hi,
> I tried inquiring about this on the CakePHP forums in discourse (https://discourse.cakephp.org/t/bake-w-specify-database-schema/7698). They said to open an issue here. I have...
