作者:mark3
项目:yii2-site-mn
/**
* 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');
}
作者:traykov
项目:yii2-taxonom
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');
}
}
作者:aivavi
项目:yii
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();
}
作者:infinitydevph
项目:yii2-table-builde
/**
* Create table in database
*/
public function runCreateTable()
{
$this->dropTable();
if ($this->hideMigrationOutput) {
ob_start();
}
/** @var Connection $_conn */
$_conn = Yii::$app->{$this->db};
if (!$_conn->schema->getTableSchema($this->tableName)) {
$this->migrationClass->createTable($this->tableNameRaw, $this->columns);
if (is_array($this->primaryKeys) && sizeof($this->primaryKeys)) {
try {
$this->migrationClass->addPrimaryKey("{$this->tableNameRaw}_pk", $this->tableNameRaw, $this->primaryKeys);
} catch (\yii\db\Exception $exp) {
}
}
}
if ($this->hideMigrationOutput) {
ob_clean();
ob_flush();
}
}
作者:radiata-cm
项目:radiat
public function init()
{
require_once Yii::getAlias($this->originalMigrationPath) . DIRECTORY_SEPARATOR . $this->originalMigrationName . '.php';
$this->originalMigration = new $this->originalMigrationName();
parent::init();
}
作者:agungsuprayitn
项目:sm
function actionTableusercompany()
{
$id_company = "FIELD1";
$company_name = "FIELD2";
$company_logo = "FIELD3";
$company_color = "FIELD4";
$company_image = "FIELD5";
$migration = new Migration();
$query = $migration->createTable('TABLE34', [$id_company => 'pk', $company_name => 'string', $company_logo => 'string', $company_color => 'string', $company_image => 'string']);
}
作者:singles
项目:singles
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->db->driverName === 'mysql') {
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
}
作者:VeerU
项目:rest-servic
/**
* @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);
}
作者:ssjss
项目:yii2.0.6-with-annotat
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (Yii::$app->db->driverName === 'mysql') {
$this->tableOptions = 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci';
}
}
作者:lav4
项目:yii2-translated-behavior-dem
public function init()
{
parent::init();
Yii::setAlias('@webroot', '@frontend/web');
Yii::setAlias('@web', '/');
Yii::$app->set('assetManager', $this->assetManager);
}
作者:jarrus9
项目:yii2-use
/**
* 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.');
}
}
作者:johnitv
项目:mg075hynlo5793r5g
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");
}
}
作者:vipantoni
项目:yii2-firebirdd
/**
* @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);
}
作者:zw
项目:yii2_restfu
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;
}
}
作者:artkos
项目:yii2-attachmen
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;
}
作者:yii2mo
项目:bas
/**
* {@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;
}
}
作者:nkovac
项目:yii2-table-builde
/**
* 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 = '';
}
}
}
作者:sirrolan
项目:yii2-mige
/**
* @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();
}
作者:chabberwoc
项目:halo-de
/**
* @inheritdoc
*/
public function init()
{
parent::init();
switch (Yii::$app->db->driverName) {
case 'mysql':
case 'pgsql':
$this->tableOptions = null;
break;
default:
throw new \RuntimeException('Your database is not supported!');
}
}
作者:fangfac
项目:yii2-concor
/**
* Builds and executes a SQL statement for creating a new index.
* @param string $name the name of the index. The name will be properly quoted by the method.
* @param string $table the table that the new index will be created for. The table name will be properly quoted by the method.
* @param string $column the column(s) that should be included in the index. If there are multiple columns, please separate them
* by commas or use an array. The column names will be properly quoted by the method.
* @param boolean $unique whether to add UNIQUE constraint on the created index.
*/
public function createIndex($name, $table, $column, $unique = false)
{
if (in_array($this->db->getDriverName(), array('mysql', 'mysqli')) && $table != strtolower($table)) {
echo " > create (via alter table)" . ($unique ? ' unique' : '') . " index {$name} on {$table} (" . implode(',', (array) $column) . ") ...";
$time = microtime(true);
$sql = 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD ' . ($unique ? 'UNIQUE INDEX' : 'INDEX') . ' ' . $this->db->quoteTableName($name) . ' (' . $this->db->getQueryBuilder()->buildColumns($column) . ')';
$this->db->createCommand($sql)->execute();
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
} else {
parent::createIndex($name, $table, $column, $unique);
}
}