0

So I've got my server running on local machine. Everything is working there and I just wanted to extend the possibility of the server by adding an Agency model. Then I put all of the files to the dev server, to make it available online - and when I try to go to "agencies" (domain.com/agencies/) - Missing Database Table Error shows up.

Everything works fine on my computer. I've checked 5 times if all of the names in the database are correct. I've checked the database.cfg in the cakephp but it must be good - everything else is working there.

Please help!

Update

Clearing models cache didn't help

Here is the code of the model:

<?php
class Agency extends AppModel{
var $name = 'Agency';

var $validate = array(
    'id' => array(
        'blank' => array(
            'rule' => array('blank'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => true,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'company' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'website_url' => array(
        'url' => array(
            'rule' => array('url'),
            //'message' => 'Your custom message here',
            'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'status' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'profession_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            'message' => 'Please select at least 1 profession',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'seniority_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'industry_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'sector_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'zone_id' => array(
        'multiple' => array(
            'rule' => array('multiple', array('min' => 1)),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'size' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    )
);

var $hasAndBelongsToMany = array(
    'Profession' => array(
        'className' => 'Profession',
        'joinTable' => 'agencies_professions',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'profession_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Seniority' => array(
        'className' => 'Seniority',
        'joinTable' => 'agencies_seniorities',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'seniority_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Industry' => array(
        'className' => 'Industry',
        'joinTable' => 'agencies_industries',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'industry_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Sector' => array(
        'className' => 'Sector',
        'joinTable' => 'agencies_sectors',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'sector_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    ),
    'Zone' => array(
        'className' => 'Zone',
        'joinTable' => 'agencies_zones',
        'foreignKey' => 'agency_id',
        'associationForeignKey' => 'zone_id',
        'unique' => true,
        //'conditions' => '',
        //'fields' => '',
        //'order' => ''
    )
);

 var $hasMany= array(
    'Office' => array(
        'className' => 'Office',
        'foreignKey' => 'office_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
 );
}

Update

The debug was set to 2 from the very beginning because it is a dev server.

Update

It is not a matter of lower/upper case names.

7
  • Do you have an "agencies" table in your database? Commented Sep 14, 2011 at 20:50
  • If the agencies table does exist; try clearing your model cache located at APP/tmp/cache/models - that often clears up strange behaviour Commented Sep 14, 2011 at 21:31
  • Yes I do have this table in my database. I did clear model cache too :) Nothing solves the problem. Commented Sep 14, 2011 at 22:07
  • post the exact message; I (guess) you have created AgenciesController, Agency model and the appropriate views? Commented Sep 14, 2011 at 22:53
  • Ofcourse I did - here is the message: Missing Database Table Error: Database table agencies for model Agency was not found. Commented Sep 14, 2011 at 23:09

2 Answers 2

1

Whenever you make any changes to your database, please make sure that your app/config/core.php file debug value is 2. Configure::write('debug', 2);

If it is 0 database changes will not be detected.

This is because in production Cake caches the database structure so that it doesn't have to query the db again at every page load. This is rarely a problem because you should develop with debug level set to 2 anyway.

So whenever you change your database just make it 2 once.

Sign up to request clarification or add additional context in comments.

1 Comment

In the app/config/core.php file it is already set to Configure::write('debug', 2);
0

Problem solved. The database I was adding new tables was not the one connected to the dev server, but to the main site.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.