Migrate curriculum.
480757
private function migrateCurriculum()
    {
        foreach ($this->departments() as $department) {
            $this->setDepartment($department);
            $this->showMigratingInfo($department,1);
            $this->migrateDepartment($department);
            foreach ($this->studies($department) as $study) {
                $this->setStudy($study);
                $this->showMigratingInfo($study,2);
                $this->migrateStudy($study);
                $this->addStudyToDeparment();
                foreach ($this->courses($study) as $course) {
                    $this->setCourse($course);
                    $this->showMigratingInfo($course,3);
                    $this->migrateCourse($course);
                    $this->addCourseToStudy();
                    foreach ($this->modules($course) as $module) {
                        $this->setModule($module);
                        $this->showMigratingInfo($module, 4);
                        $this->migrateModule($module);
                        $this->addModuleToCourse();
                        foreach ($this->submodules($module) as $submodule) {
                            $this->setSubmodule($submodule);
                            $this->showMigratingInfo($submodule, 5);
                            $this->migrateSubmodule($submodule);
                            $this->addSubModuleToModule();
                        }
                    }
                }
            }
        }
    }
1350716
public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');

            $table->string('title');
            $table->string('slug');
            $table->string('category')->nullable();
            $table->text('excerpt')->nullable();
            $table->longText('content')->nullable();
            $table->longText('featured_media')->nullable();
            $table->timestamp('published_at')->nullable();

            $table->integer('author_user_id')->unsigned()->nullable();

            $table->foreign('author_user_id')
                ->references('id')
                ->on('users')
                ->onDelete('cascade')
                ->onUpdate('cascade');

            $table->nullableTimestamps();
            $table->softDeletes();
        });
    }
540360
public function up()
    {
        Schema::create('mc_conversations', function (Blueprint $table) {
            $table->increments('id');
            $table->boolean('private')->default(true);
            $table->text('data')->nullable();
            $table->timestamps();
        });

        Schema::create('mc_messages', function (Blueprint $table) {
            $table->increments('id');
            $table->text('body');
            $table->integer('conversation_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->string('type')->default('text');
            $table->timestamps();

            $table->foreign('user_id')
                ->references($this->userModelPrimaryKey)
                ->on($this->userModelTable)
                ->onDelete('cascade');

            $table->foreign('conversation_id')
                ->references('id')
                ->on('mc_conversations')
                ->onDelete('cascade');
        });

        Schema::create('mc_conversation_user', function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->integer('conversation_id')->unsigned();
            $table->primary(['user_id', 'conversation_id']);
            $table->timestamps();

            $table->foreign('conversation_id')
                ->references('id')->on('mc_conversations')
                ->onDelete('cascade');

            $table->foreign('user_id')
                ->references($this->userModelPrimaryKey)
                ->on($this->userModelTable)
                ->onDelete('cascade');
        });

        Schema::create('mc_message_notification', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('message_id')->unsigned();
            $table->integer('conversation_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->boolean('is_seen')->default(false);
            $table->boolean('is_sender')->default(false);
            $table->boolean('flagged')->default(false);
            $table->timestamps();
            $table->softDeletes();

            $table->index(['user_id', 'message_id']);

            $table->foreign('message_id')
                ->references('id')->on('mc_messages')
                ->onDelete('cascade');

            $table->foreign('conversation_id')
                ->references('id')->on('mc_conversations')
                ->onDelete('cascade');

            $table->foreign('user_id')
                ->references($this->userModelPrimaryKey)
                ->on($this->userModelTable)
                ->onDelete('cascade');
        });
    }
165122
public function up()
    {
        Schema::rename('imageables', 'images');

        Schema::table('images', function (Blueprint $table) {
            /*
             * `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
             * `imageable_id` int(11) NOT NULL,
             * `imageable_type` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
             * `file` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
             * `orientation` int(11) NOT NULL,
             * `created_at` timestamp NULL DEFAULT NULL,
             * `updated_at` timestamp NULL DEFAULT NULL,
             */
            $table->renameColumn('imageable_id', 'resource_id');
            $table->renameColumn('imageable_type', 'resource_model');
            $table->string('image_type', 100)->after('imageable_type');
            $table->renameColumn('file', 'original_image');
            $table->unsignedSmallInteger('retina_factor')->nullable()->after('file');

            $table->dropColumn('orientation');
        });
    }
755140
public function up()
    {
        // Check if the table exists
        if (Schema::hasTable('translations')) {
            if (Schema::hasColumn('translations', 'translatable_type')) {
                $items = DB::select('select * from translations');
                foreach ($items as $item) {
                    // Points to new namespace Redooor\\Redminportal\\App\\Models\\
                    $new_type_array = explode('\\', $item->translatable_type);
                    $last_model = array_pop($new_type_array);
                    $new_type = 'Redooor\\Redminportal\\App\\Models\\' . $last_model;
                    DB::table('translations')->where('id', $item->id)
                        ->update([
                        'translatable_type' => $new_type
                    ]);
                }
            }
        }
    }
1248187
public function up()
    {
        Schema::table('hc_pages_translations', function (Blueprint $table) {
            $table->string('seo_title')->nullable();
            $table->string('seo_description')->nullable();
            $table->string('seo_keywords')->nullable();
            $table->unique(['record_id','language_code'], 'fk_hc_pages_translations_unique');
        });
    }
451233
public function up()
    {
        if ( ! Schema::hasTable('provinces')) {
            Schema::create('provinces', function(Blueprint $table) {
                $table->increments('id');
                $table->string('province', 50);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('counties')) {
            Schema::create('counties', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('province_id');
                $table->foreign('province_id')->references('id')->on('provinces')->onDelete('cascade');
                $table->string('county', 75);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('districts')) {
            Schema::create('districts', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('county_id');
                $table->foreign('county_id')->references('id')->on('counties')->onDelete('cascade');
                $table->string('district', 75);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('neighborhoods')) {
            Schema::create('neighborhoods', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('district_id');
                $table->foreign('district_id')->references('id')->on('districts')->onDelete('cascade');
                $table->string('neighborhood', 150);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('postal_codes')) {
            Schema::create('postal_codes', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('neighborhood_id');
                $table->foreign('neighborhood_id')->references('id')->on('neighborhoods')->onDelete('cascade');
                $table->char('postal_code', 6);

                $table->engine = 'InnoDB';
            });
        }
    }
852183
public function up()
    {
        Schema::table('incidents', function (Blueprint $table) {
            $table->timestamp('occurred_at')->nullable()->after('scheduled_at');
        });

        // We need a better way of handling data migrations...
        $system = app(System::class);
        $prefix = $system->getTablePrefix();

        DB::update("UPDATE {$prefix}incidents SET occurred_at = created_at");
    }
1143955
public function up()
	{
		Schema::create('media', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('ord')->unsigned();
			$table->integer('item_id');
			$table->integer('clone_of')->unsigned();
			$table->integer('category_id')->unsigned();
			$table->integer('type_id')->unsigned();
			$table->string('mime')->index('mime');
			$table->integer('user_id')->unsigned();
			$table->string('slug', 32);
			$table->boolean('hide');
			$table->string('file', 128);
			$table->string('location');
			$table->integer('width')->unsigned();
			$table->integer('height')->unsigned();
			$table->integer('fps')->unsigned();
			$table->bigInteger('size');
			$table->string('duration', 32);
			$table->boolean('approved')->default(0);
			$table->timestamps();
		});
	}
155076
public function up()
    {
        Schema::connection($this->connection)->create('provider', function (Blueprint $table) {
            $table->increments('id', true);
            $table->string('firstname');
            $table->string('lastname');
            $table->string('practice_name');
            $table->string('address');
            $table->string('town');
            $table->string('state')->nullable();
            $table->string('country')->nullable();
            $table->string('email')->nullable();
        });
    }
985684
def migrate(directory, message, sql, head, splice, branch_label, version_path,
            rev_id, x_arg):
    """"""
    _migrate(directory, message, sql, head, splice, branch_label, version_path,
             rev_id, x_arg)
688669
public function up()
    {
        Schema::table('email_log', function ($table) {
            if (!Schema::hasColumn('email_log', 'bcc')) {
                $table->string('to')->nullable()->change();
                $table->string('bcc')->after('to')->nullable();
            }
        });
    }
396888
public function up()
    {
        Schema::table('email_log', function ($table) {
            if (!Schema::hasColumn('email_log', 'id')) {
                $table->increments('id')->first();
                $table->string('from')->after('date')->nullable();
                $table->string('cc')->after('to')->nullable();
                $table->text('headers')->after('body')->nullable();
                $table->text('attachments')->after('headers')->nullable();
            }
        });
    }
1148439
public function up()
    {
        // Create table for storing roles
        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('display_name')->nullable();
            $table->string('description')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        // Create table for storing users
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('first_name');
            $table->string('last_name');
            $table->integer('country_id')->unsigned();
            $table->string('phone_number')->nullable();
            $table->string('username');
            $table->string('password');
            $table->string('email')->unique();
            $table->string('slug')->unique();
            $table->integer('points')->default(0);
            $table->timestamp('last_login')->nullable();
            $table->string('remember_token');
            $table->boolean('state')->default(1);
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('country_id')->references('id')->on('countries');
        });

        // Create table for associating roles to users (Many-to-Many)
        Schema::create('role_user', function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->integer('role_id')->unsigned();

            $table->foreign('user_id')->references('id')->on('users')
                ->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('role_id')->references('id')->on('roles')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->primary(['user_id', 'role_id']);
            $table->softDeletes();
        });

        // Create table for storing permissions
        Schema::create('permissions', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('display_name')->nullable();
            $table->string('description')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        // Create table for associating permissions to roles (Many-to-Many)
        Schema::create('permission_role', function (Blueprint $table) {
            $table->integer('permission_id')->unsigned();
            $table->integer('role_id')->unsigned();

            $table->foreign('permission_id')->references('id')->on('permissions')
                ->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('role_id')->references('id')->on('roles')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->primary(['permission_id', 'role_id']);
            $table->softDeletes();
        });
    }
1040048
public function up()
    {
        if(! Schema::hasTable('001_016_attachment'))
        {
            Schema::create('001_016_attachment', function (Blueprint $table) {
                $table->engine = 'InnoDB';
                
                $table->integer('id_016')->unsigned();
                $table->string('lang_id_016', 2);
                $table->string('resource_id_016', 30);                                  // resource which belong to this attachment
                $table->integer('object_id_016')->unsigned()->nullable();
                $table->integer('family_id_016')->unsigned()->nullable();
                $table->integer('library_id_016')->unsigned()->nullable();              // original element library
                $table->string('library_file_name_016', 1020)->nullable();
                $table->integer('sorting_016')->unsigned()->nullable();
                $table->string('url_016', 1020)->nullable();
                $table->string('name_016')->nullable();
                $table->string('file_name_016', 1020)->nullable();
                $table->string('mime_016')->nullable();
                $table->integer('size_016')->unsigned()->nullable();
                $table->tinyInteger('type_id_016')->unsigned();                         // 1 = image, 2 = file, 3 = video
                $table->string('type_text_016');
                $table->smallInteger('width_016')->unsigned()->nullable();
                $table->smallInteger('height_016')->unsigned()->nullable();
                $table->text('data_lang_016')->nullable();
                $table->text('data_016')->nullable();
                
                $table->foreign('lang_id_016', 'fk01_001_016_attachment')
                    ->references('id_001')
                    ->on('001_001_lang')
                    ->onDelete('restrict')
                    ->onUpdate('cascade');
                $table->foreign('resource_id_016', 'fk02_001_016_attachment')
                    ->references('id_007')
                    ->on('001_007_resource')
                    ->onDelete('cascade')
                    ->onUpdate('cascade');
                $table->foreign('family_id_016', 'fk03_001_016_attachment')
                    ->references('id_015')
                    ->on('001_015_attachment_family')
                    ->onDelete('restrict')
                    ->onUpdate('cascade');
                $table->foreign('library_id_016', 'fk04_001_016_attachment')
                    ->references('id_014')
                    ->on('001_014_attachment_library')
                    ->onDelete('set null')
                    ->onUpdate('cascade');

                $table->index(['object_id_016'], 'pk01_001_016_attachment');
                $table->primary(['id_016', 'lang_id_016'], 'ix01_001_016_attachment');
            });
        }
    }
818697
public function up ()
    {

        // categories table
        Schema::create(config('categories.categories_table_name') , function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->increments('id');
            $table->string('title' , 200);
            $table->string('slug' , 250);
            $table->string('description' , 180)->nullable();
            $table->string('model_type' , 200);
            $table->integer('count')->default(0);
            $table->integer('parent')->default(0);
            $table->text('meta')->nullable(); // for custom fields
            $this->makeOtherFields($table);
            $table->softDeletes();
            $table->timestamps();
        });

        // relation table
        Schema::create(config('categories.relation_table_name') , function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->integer('categorieable_id');
            $table->string('categorieable_type' , 200);
            $table->integer('categories_id')->unsigned()->index();
            $table->foreign('categories_id')->references('id')->on('categories')->onDelete('cascade');
        });

        // insert default category when migrating
        \Illuminate\Support\Facades\DB::table('categories')->insert([
            'id' => 1 ,
            'title' => config('categories.default_category.title') ,
            'slug' => config('categories.default_category.slug') ,
            'model_type' => 'NONE'
        ]);

    }
254374
public function up()
    {
        Schema::create('media', function (Blueprint $table) {
            $table->increments('id');
            $table->morphs('model');
            $table->string('collection_name');
            $table->string('name');
            $table->string('file_name');
            $table->string('mime_type')->nullable();
            $table->string('disk');
            $table->unsignedInteger('size');
            $table->json('manipulations');
            $table->json('custom_properties');
            $table->unsignedInteger('order_column')->nullable();
            $table->nullableTimestamps();
        });
    }