Issue
I'm trying to get Cakephp to bake a controller, and I'm given an error:
Error: Table core_tablets for model CoreTablet was not found in datasource dev.
Background Information
- I'm using Lappstack for my Apache, PHP, and Postgresql
- Postgresql 9.0.3 database
- PHP 5.3
- Apache 2
- Cakephp 2.3.1
What I am able to do
- I am able to bake a model. I've created a model for each of the controllers so far.
- The webapp works fine. I've built Models, Controllers, and Views from scratch and everything works.
- Connect to DB from web app, remotely using pgadmin3, and psql
Full Cakephp Bake error
Enter a number from the list above,
type in the name of another controller, or 'q' to exit
[q] > CoreTablets
---------------------------------------------------------------
Baking CoreTabletsController
---------------------------------------------------------------
Would you like to build your controller interactively? (y/n)
[y] > n
Would you like to create some basic class methods
(index(), add(), view(), edit())? (y/n)
[n] > y
Would you like to create the basic class methods for admin routing? (y/n)
[n] >
Error: Table core_tablets for model CoreTablet was not found in datasource dev.
#0 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Model/Model.php(3231): Model->setSource('core_tablets')
#1 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Model/Model.php(1319): Model->getDataSource()
#2 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Model/Model.php(1402): Model->schema()
#3 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Model/Model.php(1390): Model->hasField('title', false)
#4 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Model/Model.php(879): Model->hasField(Array)
#5 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/Command/Task/ControllerTask.php(301): Model->__get('displayField')
#6 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/Command/Task/ControllerTask.php(189): ControllerTask->bakeActions('CoreTablets', NULL, true)
#7 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/Command/Task/ControllerTask.php(62): ControllerTask->_interactive()
#8 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/Command/BakeShell.php(114): ControllerTask->execute()
#9 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/Shell.php(392): BakeShell->main()
#10 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/ShellDispatcher.php(200): Shell->runCommand(NULL, Array)
#11 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/lib/Cake/Console/ShellDispatcher.php(68): ShellDispatcher->dispatch()
#12 /home/myusername/lappstack-1.2-5/apache2/htdocs/cpm_v2_dev/app/Console/cake.php(37): ShellDispatcher::run(Array)
#13 {main}
Config file: app/config/database.php
public $default = array(
'datasource' => 'Database/Postgres',
'persistent' => false,
'host' => '127.0.0.1',
'port' => '5433',
'login' => 'notrealusername',
'password' => 'notrealpassword',
'database' => 'notrealdatabase',
'prefix' => '',
'schema' => 'notrealschema',
//'encoding' => 'utf8',
);
public $dev = array(
'datasource' => 'Database/Postgres',
'persistent' => false,
'host' => '127.0.0.1',
'port' => '5433',
'login' => 'notrealusername',
'password' => 'notrealpassword',
'database' => 'notrealdatabase',
'prefix' => '',
'schema' => 'notrealschema',
//'encoding' => 'utf8',
);
The host used to be the external IP address, which worked fine but I changed it to 127.0.0.1 since other articles have mentioned bake plays nicer with 127.0.0.1.
Research
I've found two related Stackoverflow articles, but they don't seem to solve my issue.
Changing the IP address didn't seem to help. cake console 2.2.1: Bake errors
This is using a sqlite database which is an actual file. I'm using postgresql and this won't work. Bake tool cannot see tables in SQLite3 database