当前位置: 首页>>代码示例>>PHP>>正文


PHP db\Migration类代码示例

本文整理汇总了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');
 }
开发者ID:mark38,项目名称:yii2-site-mng,代码行数:13,代码来源:DefaultController.php

示例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');
     }
 }
开发者ID:traykovn,项目名称:yii2-taxonomy,代码行数:10,代码来源:PropertyTerm.php

示例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();
 }
开发者ID:aivavic,项目名称:yii2,代码行数:8,代码来源:MigrateControllerTest.php

示例4: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
 }
开发者ID:singleso,项目名称:singleso,代码行数:10,代码来源:Migration.php

示例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);
 }
开发者ID:VeerUP,项目名称:rest-service,代码行数:10,代码来源:Migration.php

示例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';
     }
 }
开发者ID:ssjssh,项目名称:yii2.0.6-with-annotate,代码行数:10,代码来源:Migration.php

示例7: init

 public function init()
 {
     parent::init();
     Yii::setAlias('@webroot', '@frontend/web');
     Yii::setAlias('@web', '/');
     Yii::$app->set('assetManager', $this->assetManager);
 }
开发者ID:lav45,项目名称:yii2-translated-behavior-demo,代码行数:7,代码来源:m160418_201842_page_data.php

示例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.');
     }
 }
开发者ID:jarrus90,项目名称:yii2-user,代码行数:15,代码来源:RbacMigration.php

示例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");
     }
 }
开发者ID:johnitvn,项目名称:mg075hynlo5793r5gt,代码行数:9,代码来源:BaseMigration.php

示例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);
 }
开发者ID:vipantonio,项目名称:yii2-firebirddb,代码行数:12,代码来源:FirebirdMigration.php

示例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;
     }
 }
开发者ID:zwq,项目名称:yii2_restful,代码行数:9,代码来源:Migration.php

示例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;
 }
开发者ID:artkost,项目名称:yii2-attachment,代码行数:10,代码来源:m141207_024254_create_attachment_table.php

示例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;
     }
 }
开发者ID:yii2mod,项目名称:base,代码行数:14,代码来源:Migration.php

示例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 = '';
         }
     }
 }
开发者ID:nkovacs,项目名称:yii2-table-builder,代码行数:15,代码来源:Migration.php

示例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();
 }
开发者ID:sirroland,项目名称:yii2-migen,代码行数:14,代码来源:Migration.php


注:本文中的yii\db\Migration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。