rmrevin/yii2-power-migration

Migration Extension for Yii2.

Maintainers

👁 rmrevin

Package info

github.com/rmrevin/yii2-power-migration

Wiki

Type:yii2-extension

pkg:composer/rmrevin/yii2-power-migration

Statistics

Installs: 161

Dependents: 0

Suggesters: 0

Stars: 5

Open Issues: 0

1.1.2 2015-05-18 17:44 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 8c6808372dfb131157ec8011c6fdbf2e7d18cbf3

migrationmigrateyii2

This package is not auto-updated.

Last update: 2026-06-21 03:28:51 UTC


README

Features

Installation

In composer.json:

{
 "require": {
 "rmrevin/yii2-power-migration": "~1.1"
 }
}

Configuration

/config/console.php

<?
return [
	// ...
	'controllerMap' => [
		// ...
		'migrate' => [
 'class' => yii\console\controllers\MigrateController::class,
 'templateFile' => '@vendor/rmrevin/yii2-power-migration/template.php',
 ],
	],
	// ...
];

Usage

<?

use yii\db\Schema;
use rmrevin\yii\db\migration;

class m140317_055355_file extends migration\PowerMigration
{

 public function instructions()
 {
 return [
 'createTableFile',
 'createTableFileLink',
 ];
 }

 public function createTableFile_up()
 {
 $this->createTable('{{%file}}', [
 'id' => Schema::TYPE_PK,
 'mime' => Schema::TYPE_STRING . ' NOT NULL',
 'size' => Schema::TYPE_BIGINT . ' NOT NULL DEFAULT 0',
 'name' => Schema::TYPE_STRING . ' NOT NULL',
 'origin_name' => Schema::TYPE_STRING . ' NOT NULL',
 'sha1' => Schema::TYPE_STRING . '(40) NOT NULL',
 'image_bad' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0',
 ]);
 }

 public function createTableFile_down()
 {
 $this->dropTable('{{%file}}');
 }
 
 public function createTableFileLink_up()
 {
 $this->createTable('{{%file_link}}', [
 'file_id' => Schema::TYPE_PK,
 'url' => Schema::TYPE_STRING . ' NOT NULL',
 ]);
 }

 public function createTableFileLink_down()
 {
 $this->dropTable('{{%file_link}}');
 }
}