/** * Setup test databases. */ protected function setUp() { $this->executeSqlFile('models/ForeignKeyTest.sql'); Column::$db = ForeignKey::$db = Index::$db = Routine::$db = Row::$db = Schema::$db = Table::$db = Trigger::$db = View::$db = $this->createDbConnection('tabletest'); }
protected function setUp() { $this->executeSqlFile('models/SchemaTest.sql'); Schema::$db = $this->createDbConnection('information_schema'); }
/** * Drop a schema. */ public function actionDrop() { $response = new AjaxResponse(); $response->refresh = true; $response->executeJavaScript('sideBar.loadSchemata()'); $schemata = (array) $_POST['schemata']; $droppedSchemata = $droppedSqls = array(); Schema::$db = Yii::app()->getDb(); foreach ($schemata as $schema) { $schemaObj = Schema::model()->findByPk($schema); $schemaObj->throwExceptions = true; try { $sql = $schemaObj->delete(); $droppedSchemata[] = $schema; $droppedSqls[] = $sql; } catch (DbException $ex) { $response->addNotification('error', Yii::t('core', 'errorDropSchema', array('{schema}' => $schema)), $ex->getText(), $ex->getSql()); } } $count = count($droppedSchemata); if ($count > 0) { $response->addNotification('success', Yii::t('core', 'successDropSchema', array($count, '{schema}' => $droppedSchemata[0], '{schemaCount}' => $count)), $count > 1 ? implode(', ', $droppedSchemata) : null, implode("\n", $droppedSqls)); } $this->sendJSON($response); }