# Table names altered by bake

**URL:** <https://discourse.cakephp.org/t/table-names-altered-by-bake/4768>\
**Category:** Need Help\
**Created:** [August 21, 2018, 3:17am UTC](https://discourse.cakephp.org/t/table-names-altered-by-bake/4768 "2018-08-21T03:17:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lundissimo](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lundissimo](https://discourse.cakephp.org/u/lundissimo)\
**Post date:** [August 21, 2018, 3:17am UTC](https://discourse.cakephp.org/t/table-names-altered-by-bake/4768/1 "2018-08-21T03:17:18Z")

</div>

I’m installing Cake for the 1st time. I’ve got databases and tables, and tried to run  
bin/cake bake all --everything  
to create a bunch of files. When it encounters a table named ‘BidBuy\_totals’, it produces an error:  
2018-08-21 02:25:17 Error: [Cake\Database\Exception] SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘master.bid\_buy\_totals’ doesn’t exist in /Users/lundo/Sites/tarisio\_cmt/api/vendor/cakephp/cakephp/src/Database/Schema/Collection.php on line 131  
It not only sets it tolowercase, but adds ‘\_’ before ‘Buy’! Similarly, my ‘AR\_unknown\_house’ table produces an error trying to locate ‘a\_r\_unknown\_house’.  
Is there an internal setting that tells Cake to use table names as they appear?

---

<div class="post-metadata">

**Author:** ![Graziel](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Graziel](https://discourse.cakephp.org/u/Graziel)\
**Post date:** [August 21, 2018, 6:07am UTC](https://discourse.cakephp.org/t/table-names-altered-by-bake/4768/2 "2018-08-21T06:07:31Z")

</div>

cake uses its magic by assuming that you follow some pointers in first steps of creating application, those table names are something that cake doesnt expect,

[https://book.cakephp.org/3.0/en/intro/conventions.html#database-conventions](https://book.cakephp.org/3.0/en/intro/conventions.html#database-conventions)

---

<div class="post-metadata">

**Author:** ![dakota](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dakota/32/1421_2.png) [@dakota](https://discourse.cakephp.org/u/dakota)\
**Post date:** [August 21, 2018, 9:04am UTC](https://discourse.cakephp.org/t/table-names-altered-by-bake/4768/3 "2018-08-21T09:04:02Z")

</div>

CakePHP is a conventions over configuration framework. If you don’t follow the CakePHP conventions, then a lot of the automated tools (Bake being a good example) will not work as expected (Or at all).

So, either follow the conventions, or don’t use Bake (and create everything manually)

---

<div class="post-metadata">

**Author:** ![lundissimo](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lundissimo](https://discourse.cakephp.org/u/lundissimo)\
**Post date:** [August 21, 2018, 8:15pm UTC](https://discourse.cakephp.org/t/table-names-altered-by-bake/4768/4 "2018-08-21T20:15:23Z")

</div>

“Follow conventions or don’t use Bake”! That’s a rather inflexible “solution”. I’ve got multiple existing databases and tables, and would like to start using Cake. Bake apparently does a “SHOW TABLES” command to get a list of tables, then modifies those names to fit its conventions, then produces a fatal error when it fails to find the tables with modified names??? It’s hard to believe such foolish code would be included in such a smart package. Can anyone confirm that there’s no way to tell bake to use the existing table names?

---

<div class="post-metadata">

**Author:** ![dakota](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dakota/32/1421_2.png) [@dakota](https://discourse.cakephp.org/u/dakota)\
**Post date:** [August 22, 2018, 12:08pm UTC](https://discourse.cakephp.org/t/table-names-altered-by-bake/4768/5 "2018-08-22T12:08:07Z")

</div>

> Bake apparently does a “SHOW TABLES” command to get a list of tables, then modifies those names to fit its conventions.

By default that is more or less exactly what it does, purely because Bake is built to follow the CakePHP conventions. To be more detailed, it gets a list of all DB tables, converts them into model names (based on the convention) and works from there.

Bake does allow you to bake the model layer (unfortunately only one model at a time) with custom table names by using the `--table` option to overwrite the default.

You can read up on the Cake conventions in the [book](https://book.cakephp.org/3.0/en/intro/conventions.html)
