本文整理汇总了PHP中yii\db\Migration类的典型用法代码示例。如果您正苦于以下问题:PHP Migration类的具体用法?PHP Migration怎么用?PHP Migration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Migration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
/**
* Update ip-geo-base data
*
* @throws \yii\base\Exception
*/
public function actionUpdate()
{
$migrate = new Migration();
$migrate->dropForeignKey('fk-geobase_contact-geobase_city_id', 'geobase_contact');
$ipGeoBase = new IpGeoBase();
$ipGeoBase->updateDB();
$migrate->addForeignKey('fk-geobase_contact-geobase_city_id', 'geobase_contact', 'geobase_city_id', 'geobase_city', 'id', 'CASCADE', 'CASCADE');
}
示例2: install
public function install()
{
parent::install();
$migration = new Migration();
$migration->createTable($this->getTable(), ['id' => Schema::TYPE_PK, 'object_id' => Schema::TYPE_INTEGER, 'term_id' => Schema::TYPE_BIGINT, 'value' => Schema::TYPE_STRING]);
if ($migration->db->driverName === 'mysql') {
$migration->addForeignKey('fk_' . $this->getTable() . '_' . $this->getRefTableName(), $this->getTable(), 'object_id', $this->getRefTableName(), 'id', 'CASCADE');
$migration->addForeignKey('fk_' . $this->getTable() . '_' . TaxonomyTerms::tableName(), $this->getTable(), 'term_id', TaxonomyTerms::tableName(), 'id', 'CASCADE');
}
}
示例3: setUp
public function setUp()
{
$this->migrateControllerClass = MigrateController::className();
$this->migrationBaseClass = Migration::className();
$this->mockApplication(['components' => ['db' => ['class' => 'yii\\db\\Connection', 'dsn' => 'sqlite::memory:']]]);
$this->setUpMigrationPath();
parent::setUp();
}
示例4: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->db->driverName === 'mysql') {
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
}
示例5: createTable
/**
* @inheritdoc
*/
public function createTable($table, $columns, $options = null)
{
if ($options === null && $this->db->driverName === 'mysql') {
$options = "CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB";
}
parent::createTable($table, $columns, $options);
}
示例6: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (Yii::$app->db->driverName === 'mysql') {
$this->tableOptions = 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci';
}
}
示例7: init
public function init()
{
parent::init();
Yii::setAlias('@webroot', '@frontend/web');
Yii::setAlias('@web', '/');
Yii::$app->set('assetManager', $this->assetManager);
}
示例8: init
/**
* Initialize migrations.
* Calls parent init method, then loads current authManager instance.
*
* @return DbManager
* @throws yii\base\InvalidConfigException
*/
public function init()
{
parent::init();
$this->authManager = Yii::$app->getAuthManager();
if (!$this->authManager instanceof DbManager) {
throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.');
}
}
示例9: init
public function init()
{
parent::init();
if ($this->db->driverName === 'mysql') {
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
} else {
throw new InvalidConfigException($this->db->driverName . " is not support");
}
}
示例10: createTable
/**
* @inheritdoc
*/
public function createTable($name, $columns, $options = null)
{
$baseTableName = $this->db->getSchema()->getRawTableName($name);
if ($this->db->getSchema()->getTableSchema($baseTableName, true) !== null) {
echo " > table {$name} already exists ...\n";
return;
}
parent::createTable($name, $columns, $options);
}
示例11: init
public function init()
{
parent::init();
if ($this->db->driverName === 'mysql') {
//Mysql 表选项
$engine = $this->useTransaction ? 'InnoDB' : 'MyISAM';
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=' . $engine;
}
}
示例12: init
public function init()
{
parent::init();
/** @var Manager $attachment */
$attachment = Manager::getInstance();
if (!$attachment instanceof Manager) {
throw new InvalidConfigException('Attachment Manager component not defined');
}
$this->attachmentTable = $attachment->attachmentFileTable;
}
示例13: init
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
switch (Yii::$app->db->driverName) {
case 'mysql':
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
break;
default:
$this->tableOptions = null;
}
}
示例14: init
/**
* Initializes the migration.
* This method will set tableOptions to use InnoDB if the db driver is mysql.
*/
public function init()
{
parent::init();
if ($this->tableOptions === true) {
if ($this->db->driverName === 'mysql') {
$this->tableOptions = 'ENGINE=InnoDB';
} else {
$this->tableOptions = '';
}
}
}
示例15: init
/**
* @throws \yii\base\InvalidConfigException
*/
public function init()
{
if (is_null($this->_tableName)) {
throw new InvalidConfigException('$_tableName must be set!');
}
if ($this->db->driverName === 'mysql' && $this->_tableOptions !== false) {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$this->_tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
parent::init();
}