Skip to content

Commit

Permalink
fixed migration script names and paths (still issues while running
Browse files Browse the repository at this point in the history
migrations)
  • Loading branch information
pkerspe committed Dec 18, 2014
1 parent ba58e3b commit 82f9f2e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Prefered way is by using composer:
"schallschlucker/yii2-simple-cms": ">=0.1",
}


After installation run migration for database table creation:

php yii migrate --migrationPath=@schallschlucker/simplecms/migrations

## License

yii2-simple-cms is released under the Apache License 2.0. See the bundled [LICENSE.md](LICENSE.md) for details.
4 changes: 3 additions & 1 deletion migrations/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ public function init() {
throw new \RuntimeException ( 'Your database is not yet supported!' );
}
}
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,41 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace schallschlucker\simplecms\migrations;

use yii\db\Schema;
use yii\base\InvalidConfigException;
use schallschlucker\simplecms\migrations\Migration;

/**
*
* @author Paul Kerspe
*/
class simplecms_init extends Migration {
class m141217_232437_simplecms_init extends Migration {


/**
*
* @var string
*/
protected $tableOptions;

/**
* @inheritdoc
*/
public function init() {
parent::init ();

switch (\Yii::$app->db->driverName) {
case 'mysql' :
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
break;
default :
throw new \RuntimeException ( 'Your database is not yet supported!' );
}
}


public function up() {
// mysql create sql (suing this approach over createTable call, since ENUM Types where missing in Schema from Yii2
$this->execute ( "CREATE TABLE `cms_content_media` (
Expand Down Expand Up @@ -115,6 +142,7 @@ public function up() {
'createdby_userid' => Schema::TYPE_INT . "(11) unsigned NOT NULL COMMENT 'user id of the user who created the page content element'"
], $this->tableOptions );
}

public function down() {
$this->dropTable ( '{{%cms_content_media}}' );
$this->dropTable ( '{{%cms_content_media_variation}}' );
Expand All @@ -123,4 +151,5 @@ public function down() {
$this->dropTable ( '{{%cms_menu_item}' );
$this->dropTable ( '{{%cms_page_content}' );
}
}
}
?>

0 comments on commit 82f9f2e

Please sign in to comment.