Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- App::import('Model', 'CakeSchema');
- App::import('Model', 'ConnectionManager');
- include_once(APP.'plugins'.DS.'pluginname'.DS.'config'.DS.'schema'.DS.'schema.php');
- $db = ConnectionManager::getDataSource('default');
- //Get all available tables
- $tables = $db->listSources();
- $CakeSchema = new CakeSchema();
- $SubSchema = new PluginnameSchema();
- foreach ($SubSchema->tables as $table => $config) {
- if (!in_array($table, $tables)) {
- $db->execute($db->createSchema($SubSchema, $table));
- }
- }
- //Ignore the cache since the tables wont be inside the cache at this point
- @unlink(TMP . 'cache' . DS . 'models/cake_model_' . ConnectionManager::getSourceName($db). '_' . $db->config["database"] . '_list');
- $db->sources(true);
Add Comment
Please, Sign In to add comment