diff --git a/README.md b/README.md index d11bc35..02d303b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/migrations/Migration.php b/migrations/Migration.php index 808ece7..3f7569a 100644 --- a/migrations/Migration.php +++ b/migrations/Migration.php @@ -35,4 +35,6 @@ public function init() { throw new \RuntimeException ( 'Your database is not yet supported!' ); } } -} \ No newline at end of file +} + +?> \ No newline at end of file diff --git a/migrations/simplecms_init.php b/migrations/m141217_232437_simplecms_init.php similarity index 95% rename from migrations/simplecms_init.php rename to migrations/m141217_232437_simplecms_init.php index 52880d6..2b7894a 100644 --- a/migrations/simplecms_init.php +++ b/migrations/m141217_232437_simplecms_init.php @@ -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` ( @@ -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}}' ); @@ -123,4 +151,5 @@ public function down() { $this->dropTable ( '{{%cms_menu_item}' ); $this->dropTable ( '{{%cms_page_content}' ); } -} \ No newline at end of file +} +?> \ No newline at end of file