Skip to content

Commit

Permalink
reduce migrations files due to version 1.0.0 relase. Use schema builder
Browse files Browse the repository at this point in the history
for migrations #1108
  • Loading branch information
nadar committed Dec 19, 2016
1 parent d837922 commit 78f5304
Show file tree
Hide file tree
Showing 41 changed files with 139 additions and 633 deletions.
1 change: 1 addition & 0 deletions core/console/commands/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public function actionIndex()

if (Yii::$app->hasModule('cms')) {
// insert default page
$this->insert("cms_nav_container", ['id' => 1, 'name' => 'Default Container', 'alias' => 'default', 'is_deleted' => 0]);
$this->insert("cms_nav", ['nav_container_id' => 1, 'parent_nav_id' => 0, 'sort_index' => 0, 'is_deleted' => 0, 'is_hidden' => 0, 'is_offline' => 0, 'is_home' => 1, 'is_draft' => 0]);
$this->insert("cms_nav_item", ['nav_id' => 1, 'lang_id' => 1, 'nav_item_type' => 1, 'nav_item_type_id' => 1, 'create_user_id' => 1, 'update_user_id' => 1, 'timestamp_create' => time(), 'title' => 'Homepage', 'alias' => 'homepage']);
$this->insert('cms_nav_item_page', ['layout_id' => 1, 'create_user_id' => 1, 'timestamp_create' => time(), 'version_alias' => 'Initial', 'nav_item_id' => 1]);
Expand Down
6 changes: 5 additions & 1 deletion modules/admin/src/migrations/m141104_114809_admin_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ public function safeUp()
'firstname' => $this->string(255),
'lastname' => $this->string(255),
'title' => $this->smallInteger(1),
'email' => $this->string(12)->notNull()->unique(),
'email' => $this->string(120)->notNull()->unique(),
'password' => $this->string(255),
'password_salt' => $this->string(255),
'auth_token' => $this->string(255),
'is_deleted' => $this->boolean()->defaultValue(0),
'secure_token' => $this->string(40),
'secure_token_timestamp' => $this->integer(11)->defaultValue(0),
'force_reload' => $this->boolean()->defaultValue(0),
'settings' => $this->text(),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function safeUp()
'name' => $this->string(255),
'parent_id' => $this->integer(11),
'timestamp_create' => $this->integer(11),
'is_deleted' => $this->boolean()->defaultValue(0),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function safeUp()
'file_size' => $this->integer(11)->defaultValue(0), // in bytes
'upload_user_id' => $this->integer(11)->defaultValue(0),
'is_deleted' => $this->boolean()->defaultValue(0),
'passthrough_file' => $this->boolean()->defaultValue(0),
'passthrough_file_password' => $this->string(40),
'passthrough_file_stats' => $this->integer(11)->defaultValue(0),
'caption' => $this->text(),
'internal_note' => $this->text(),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public function safeUp()
'id' => $this->primaryKey(),
'file_id' => $this->integer(11),
'filter_id' => $this->integer(11),
'resolution_width' => $this->integer(11),
'resolution_height' => $this->integer(11),
]);
}

Expand Down
1 change: 1 addition & 0 deletions modules/admin/src/migrations/m150924_120914_admin_prop.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public function safeUp()
'id' => $this->primaryKey(),
'module_name' => $this->string(120),
'var_name' => $this->string(40)->notNull()->unique(),
'class_name' => $this->string(200)->notNull(),
]);
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions modules/admin/src/migrations/m151013_132217_login_secure_token.php

This file was deleted.

16 changes: 0 additions & 16 deletions modules/admin/src/migrations/m151020_065710_user_force_reload.php

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions modules/admin/src/migrations/m160602_125708_filemanagercaption.php

This file was deleted.

This file was deleted.

35 changes: 16 additions & 19 deletions modules/cms/src/admin/migrations/m141203_143052_cms_cat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@

use yii\db\Migration;

/**
* Cms Nav Container.
*
* The table has been renamed in later version and the ohter migrations has been removed, but the of the migration file
* is the same in order to keep the migration history.
*
* @author Basil Suter <basil@nadar.io>
*/
class m141203_143052_cms_cat extends Migration
{
public function up()
public function safeUp()
{
$this->createTable('cms_cat', [ // renameed to cms_nav_container
'id' => 'pk',
'name' => 'VARCHAR(180) NOT NULL',
'rewrite' => 'VARCHAR(80) NOT NULL', // renamed to alias
'default_nav_id' => 'INT(11) NOT NULL', // dropped in m151028_085932_add_is_home_in_nav
'is_default' => 'TINYINT(1) NOT NULL DEFAULT 0', // dropped in m151028_085932_add_is_home_in_nav
'is_deleted' => 'TINYINT(1) NOT NULL default 0',
]);

$this->insert('cms_cat', [ // renamed to cms_nav_container
'name' => 'Default Container',
'rewrite' => 'default', // renmaed to alias
'default_nav_id' => 1,
'is_default' => 1,
$this->createTable('cms_nav_container', [
'id' => $this->primaryKey(),
'name' => $this->string(180)->notNull(),
'alias' => $this->string(180)->notNull(),
'is_deleted' => $this->boolean()->defaultValue(0),
]);
}

public function down()
public function safeDown()
{
echo "m141203_143052_cms_cat cannot be reverted.\n";

return false;
$this->dropTable('cms_nav_container');
}
}
23 changes: 12 additions & 11 deletions modules/cms/src/admin/migrations/m141203_143059_cms_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@

class m141203_143059_cms_nav extends Migration
{
public function up()
public function safeUp()
{
$this->createTable('cms_nav', [
'id' => 'pk',
'cat_id' => 'int(11) NOT NULL DEFAULT 0', // renamed to nav_container_id
'parent_nav_id' => 'int(11) NOT NULL DEFAULT 0',
'sort_index' => 'int(11) NOT NULL DEFAULT 0',
'is_deleted' => 'tinyint(1) DEFAULT 0',
'is_hidden' => 'tinyint(1) DEFAULT 0',
'id' => $this->primaryKey(),
'nav_container_id' => $this->integer(11)->notNull(),
'parent_nav_id' => $this->integer(11)->notNull(),
'sort_index' => $this->integer(11)->notNull(),
'is_deleted' => $this->boolean()->defaultValue(0),
'is_hidden' => $this->boolean()->defaultValue(0),
'is_home' => $this->boolean()->defaultValue(0),
'is_offline' => $this->boolean()->defaultValue(0),
'is_draft' => $this->boolean()->defaultValue(0),
]);
}

public function down()
public function safeDown()
{
echo "m141203_143059_cms_nav cannot be reverted.\n";

return false;
$this->dropTable('cms_nav');
}
}
34 changes: 17 additions & 17 deletions modules/cms/src/admin/migrations/m141203_143111_cms_nav_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@

class m141203_143111_cms_nav_item extends Migration
{
public function up()
public function safeUp()
{
$this->createTable('cms_nav_item', [
'id' => 'pk',
'nav_id' => 'INT(11) NOT NULL',
'lang_id' => 'INT(11) NOT NULL',
'nav_item_type' => 'INT(11) NOT NULL',
'nav_item_type_id' => 'INT(11) NOT NULL',
//"is_inactive" => Schema::TYPE_SMALLINT,
'create_user_id' => 'INT(11) NOT NULL',
'update_user_id' => 'INT(11) NOT NULL',
'timestamp_create' => 'INT(11) NULL',
'timestamp_update' => 'INT(11) NULL',
'title' => 'VARCHAR(180) NOT NULL',
'rewrite' => 'VARCHAR(80) NOT NULL', // renamed to alias
'id' => $this->primaryKey(),
'nav_id' => $this->integer(11)->notNull(),
'lang_id' => $this->integer(11)->notNull(),
'nav_item_type' => $this->integer(11)->notNull(),
'nav_item_type_id' => $this->integer(11)->notNull(),
'create_user_id' => $this->integer(11)->notNull(),
'update_user_id' => $this->integer(11)->notNull(),
'timestamp_create' => $this->integer(11)->defaultValue(0),
'timestamp_update' => $this->integer(11)->defaultValue(0),
'title' => $this->string(180)->notNull(),
'alias' => $this->string(80)->notNull(),
'description' => $this->text(),
'keywords' => $this->text(),
'title_tag' => $this->string(255),
]);
}

public function down()
public function safeDown()
{
echo "m141203_143111_cms_nav_item cannot be reverted.\n";

return false;
$this->dropTable('cms_nav_item');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@

class m141208_134038_cms_nav_item_page extends Migration
{
public function up()
public function safeUp()
{
$this->createTable('cms_nav_item_page', [
'id' => 'pk',
'layout_id' => Schema::TYPE_INTEGER,
'id' => $this->primaryKey(),
'layout_id' => $this->integer(11)->notNull(),
'nav_item_id' => $this->integer(11)->notNull(),
'timestamp_create' => $this->integer(11)->notNull(),
'create_user_id' => $this->integer(11)->notNull(),
'version_alias' => $this->string(250),
]);
}

public function down()
public function safeDown()
{
echo "m141208_134038_cms_nav_item_page cannot be reverted.\n";

return false;
$this->dropTable('cms_nav_item_page');
}
}
16 changes: 7 additions & 9 deletions modules/cms/src/admin/migrations/m150106_095003_cms_layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@

class m150106_095003_cms_layout extends Migration
{
public function up()
public function safeUp()
{
$this->createTable('cms_layout', [
'id' => 'pk',
'name' => Schema::TYPE_STRING,
'json_config' => Schema::TYPE_TEXT,
'view_file' => Schema::TYPE_STRING,
'id' => $this->primaryKey(),
'name' => $this->string(255),
'json_config' => $this->text(),
'view_file' => $this->string(255),
]);
}

public function down()
public function safeDown()
{
echo "m150106_095003_cms_layout cannot be reverted.\n";

return false;
$this->dropTable('cms_layout');
}
}
Loading

0 comments on commit 78f5304

Please sign in to comment.