@private

Setup migrations
494601
function _initMigrations() {
  return new Umzug({
    storage: 'sequelize',
    storageOptions: {
      sequelize: this.sequelize,
    },
    migrations: {
      params: [this.sequelize.getQueryInterface(), Sequelize],
      path: path.join(__dirname, 'migrations'),
      pattern: /\.js$/,
    },
  });
}
478326
public function up()
    {
        //
        Schema::create('modules', function (Blueprint $table) 
        {
            $table->increments('id')->comment('ID');
            $table->string('name')->nullable()->comment(hst_lang('hstcms::public.name'));
            $table->text('description')->comment();
            $table->string('slug', 50)->default('')->comment();
            $table->string('version', 50)->comment();
            $table->string('enabled', 10)->comment();
            $table->integer('times')->nullable()->comment(hst_lang('hstcms::public.times'));
        });
    }
552592
public function up()
    {
        Schema::create(\Config::get('registry.table', 'system_registries'), function(Blueprint $table)
        {
            $table->string('key');
            $table->text('value');

            $table->primary('key');
        });
    }
116752
public function up()
    {
        Schema::table('users', function(Blueprint $table) {
            $table->renameColumn('name', 'username');
            $table->boolean('confirmed')->default(0);
            $table->string('confirmation_code')->nullable();
        });
    }
1288956
public function up()
    {
        // Create table for storing roles
        Schema::create('data_types', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('slug')->unique();
            $table->string('display_name_singular');
            $table->string('display_name_plural');
            $table->string('icon')->nullable();
            $table->string('model_name')->nullable();
            $table->string('description')->nullable();
            $table->boolean('generate_permissions')->default(false);
            $table->timestamps();
        });

        // Create table for storing roles
        Schema::create('data_rows', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('data_type_id')->unsigned();
            $table->string('field');
            $table->string('type');
            $table->string('display_name')->nullable();
            $table->boolean('required')->default(false);
            $table->boolean('browse')->default(true);
            $table->boolean('read')->default(true);
            $table->boolean('edit')->default(true);
            $table->boolean('add')->default(true);
            $table->boolean('delete')->default(true);
            $table->text('details')->nullable();

            $table->foreign('data_type_id')->references('id')->on('data_types')
                ->onUpdate('cascade')->onDelete('cascade');
        });
    }
1353512
public function up()
    {
        Schema::create('scaffoldinterfaces', function (Blueprint $table) {
            $table->increments('id');
            $table->String('package');
            $table->String('migration');
            $table->String('model');
            $table->String('controller');
            $table->String('views');
            $table->String('tablename');
            $table->timestamps();
        });
    }
191146
public function up()
    {
        $this->create('migrations', function ($table) {
            // Place table rows here
            $table->increments('id');
            $table->string('migration');
            $table->integer('migrated');
            $table->timestamps();
        });
    }
134188
public function up()
    {
        // We need a better way of handling data migrations...
        $system = app(System::class);
        $prefix = $system->getTablePrefix();
        DB::update("INSERT INTO {$prefix}schedules (name, message, scheduled_at, created_at, updated_at) SELECT name, message, scheduled_at, created_at, updated_at FROM {$prefix}incidents WHERE scheduled_at IS NOT NULL");

        DB::table('incidents')->whereNotNull('scheduled_at')->delete();

        Schema::table('incidents', function (Blueprint $table) {
            $table->dropColumn('scheduled_at');
        });
    }
697602
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.
        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        $output = new ConsoleOutput();
        $output->writeln("Migration driver used: $driver");

        // User table
        Schema::create(
            'user',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->string('name');
                $t->string('first_name')->nullable();
                $t->string('last_name')->nullable();
                $t->dateTime('last_login_date')->nullable();
                $t->string('email')->unique();
                $t->text('password')->nullable();
                $t->boolean('is_sys_admin')->default(0);
                $t->boolean('is_active')->default(1);
                $t->string('phone', 32)->nullable();
                $t->string('security_question')->nullable();
                $t->text('security_answer')->nullable();
                $t->string('confirm_code')->nullable();
                $t->integer('default_app_id')->unsigned()->nullable();
                $t->rememberToken();
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // Password reset table
        Schema::create(
            'password_resets',
            function (Blueprint $t){
                $t->string('email')->index();
                $t->string('token')->index();
                $t->timestamp('created_date')->nullable();
            }
        );

        // Services
        Schema::create(
            'service',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->string('name', 40)->unique();
                $t->string('label', 80);
                $t->string('description')->nullable();
                $t->boolean('is_active')->default(0);
                $t->string('type', 40);
                $t->boolean('mutable')->default(1);
                $t->boolean('deletable')->default(1);
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // Service API Docs
        Schema::create(
            'service_doc',
            function (Blueprint $t){
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->integer('format')->unsigned()->default(0);
                $t->mediumText('content')->nullable();
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
            }
        );

        // Roles
        Schema::create(
            'role',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->string('name', 64)->unique();
                $t->string('description')->nullable();
                $t->boolean('is_active')->default(0);
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // Roles to Services Allowed Accesses
        Schema::create(
            'role_service_access',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->integer('role_id')->unsigned();
                $t->foreign('role_id')->references('id')->on('role')->onDelete('cascade');
                $t->integer('service_id')->unsigned()->nullable();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->string('component')->nullable();
                $t->integer('verb_mask')->unsigned()->default(0);
                $t->integer('requestor_mask')->unsigned()->default(0);
                $t->text('filters')->nullable();
                $t->string('filter_op', 32)->default('and');
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // Email Templates
        Schema::create(
            'email_template',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->string('name', 64)->unique();
                $t->string('description')->nullable();
                $t->text('to')->nullable();
                $t->text('cc')->nullable();
                $t->text('bcc')->nullable();
                $t->string('subject', 80)->nullable();
                $t->text('body_text')->nullable();
                $t->text('body_html')->nullable();
                $t->string('from_name', 80)->nullable();
                $t->string('from_email')->nullable();
                $t->string('reply_to_name', 80)->nullable();
                $t->string('reply_to_email')->nullable();
                $t->text('defaults')->nullable();
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        //Cors config table
        Schema::create(
            'cors_config',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->string('path')->unique();
                $t->string('origin')->nullable();
                $t->text('header')->nullable();
                $t->integer('method')->unsigned()->default(0);
                $t->integer('max_age')->unsigned()->default(0);
                $t->boolean('enabled')->default(true);
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // Applications
        Schema::create(
            'app',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->string('name', 64)->unique();
                $t->string('api_key')->nullable();
                $t->string('description')->nullable();
                $t->boolean('is_active')->default(0);
                $t->integer('type')->unsigned()->default(0);
                $t->text('path')->nullable();
                $t->text('url')->nullable();
                $t->integer('storage_service_id')->unsigned()->nullable();
                $t->foreign('storage_service_id')->references('id')->on('service')->onDelete('set null');
                $t->string('storage_container', 255)->nullable();
                $t->boolean('requires_fullscreen')->default(0);
                $t->boolean('allow_fullscreen_toggle')->default(1);
                $t->string('toggle_location', 64)->default('top');
                $t->integer('role_id')->unsigned()->nullable();
                $t->foreign('role_id')->references('id')->on('role')->onDelete('set null');
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // App relationship for user
        Schema::create(
            'user_to_app_to_role',
            function (Blueprint $t){
                $t->increments('id');
                $t->integer('user_id')->unsigned();
                $t->foreign('user_id')->references('id')->on('user')->onDelete('cascade');
                $t->integer('app_id')->unsigned();
                $t->foreign('app_id')->references('id')->on('app')->onDelete('cascade');
                $t->integer('role_id')->unsigned();
                $t->foreign('role_id')->references('id')->on('role')->onDelete('cascade');
            }
        );

        // JSON Web Token to system resources map
        Schema::create(
            'token_map',
            function (Blueprint $t){
                $t->integer('user_id')->unsigned();
                $t->foreign('user_id')->references('id')->on('user')->onDelete('cascade');
                $t->text('token');
                $t->integer('iat')->unsigned();
                $t->integer('exp')->unsigned();
            }
        );

        Schema::create(
            'file_service_config',
            function (Blueprint $t){
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->text('public_path')->nullable();
                $t->text('container')->nullable();
            }
        );

        Schema::create(
            'service_cache_config',
            function (Blueprint $t){
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->boolean('cache_enabled')->default(0);
                $t->integer('cache_ttl')->unsigned()->default(0);
            }
        );

        // System Configuration
        Schema::create(
            'system_config',
            function (Blueprint $t) use ($onDelete){
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->integer('default_app_id')->unsigned()->nullable();
                $t->foreign('default_app_id')->references('id')->on('app')->onDelete('set null');
                $t->integer('invite_email_service_id')->unsigned()->nullable();
                $t->foreign('invite_email_service_id')->references('id')->on('service')->onDelete($onDelete);
                $t->integer('invite_email_template_id')->unsigned()->nullable();
                $t->foreign('invite_email_template_id')->references('id')->on('email_template')->onDelete($onDelete);
                $t->integer('password_email_service_id')->unsigned()->nullable();
                $t->foreign('password_email_service_id')->references('id')->on('service')->onDelete($onDelete);
                $t->integer('password_email_template_id')->unsigned()->nullable();
                $t->foreign('password_email_template_id')->references('id')->on('email_template')->onDelete($onDelete);
            }
        );

        // create system customizations
        Schema::create(
            'system_custom',
            function (Blueprint $t) use ($onDelete){
                $t->string('name')->primary();
                $t->mediumText('value')->nullable();
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );

        // Lookups
        Schema::create(
            'lookup',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->integer('app_id')->unsigned()->nullable();
                $t->foreign('app_id')->references('id')->on('app')->onDelete('cascade');
                $t->integer('role_id')->unsigned()->nullable();
                $t->foreign('role_id')->references('id')->on('role')->onDelete('cascade');
                $t->integer('user_id')->unsigned()->nullable();
                $t->foreign('user_id')->references('id')->on('user')->onDelete('cascade');
                $t->string('name');
                $t->text('value')->nullable();
                $t->boolean('private')->default(0);
                $t->text('description')->nullable();
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );
    }
247697
function () {
                /*  determine parameters  */
                var params = $cs.params("migrate", arguments, {
                    comps:     { pos: "...", req: true    },
                    sync:      {             def: false   },
                    completed: {             def: $cs.nop }
                });

                /*  iterate over all components to migrate  */
                var n = 0;
                var parent = this;
                _cs.foreach(params.comps, function (comp) {
                    if (params.sync) {
                        /*  migrate synchronously  */
                        var state_old = comp.state();
                        comp.state({ state: "created", sync: true });
                        comp.detach();
                        comp.attach(parent);
                        comp.state(state_old);
                    }
                    else {
                        /*  migrate asynchronously  */
                        (function (comp, state_old) {
                            comp.state({ state: "created", sync: false, callback: function (/* state_new */) {
                                this.detach();
                                this.attach(parent);
                                this.state({ state: state_old, sync: false, callback: function (/* state_old */) {
                                    n--;
                                    if (n === 0)
                                        params.completed.call(null);
                                }});
                            }});
                        })(comp, comp.state());
                        n++;
                    }
                });
            }
212922
public function up()
    {
        Schema::create(config('settings.table', 'settings'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('code')->unique()->index();
            $table->enum('type', ['BOOLEAN', 'NUMBER', 'DATE', 'TEXT', 'SELECT', 'FILE', 'TEXTAREA']);
            $table->string('label');
            $table->longText('value')->nullable();
            $table->boolean('hidden');
            $table->timestamps();
        });
    }
1212262
public function up()
    {
        Schema::create('assets', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title', 150)->nullable()->index('asset_v_deleted_title_asc');
            $table->text('description', 65535)->nullable();
            $table->string('type', 5)->nullable();
            $table->integer('uploaded_by')->unsigned()->nullable()->index('uploaded_by');
            $table->integer('uploaded_time')->unsigned()->nullable();
            $table->integer('thumbnail_asset_id')->unsigned()->nullable();
            $table->string('credits')->nullable();
            $table->bigInteger('downloads')->unsigned()->nullable()->default(0)->index('assets_downloads');
        });

        Schema::create('asset_versions', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('asset_id')->unsigned();
            $table->smallInteger('width')->unsigned()->nullable();
            $table->smallInteger('height')->unsigned()->nullable();
            $table->string('filename', 150);
            $table->integer('filesize')->unsigned()->nullable()->default(0)->index('asset_versions_filesize');
            $table->integer('edited_at')->unsigned()->nullable();
            $table->integer('edited_by')
                ->unsigned()
                ->nullable()
                ->references('id')
                ->on('people')
                ->onUpdate('CASCADE')
                ->onDelete('set null');

            $table
                ->foreign('asset_id')
                ->references('id')
                ->on('assets')
                ->onUpdate('CASCADE')
                ->onDelete('CASCADE');

            $table->string('extension', 10);
            $table->string('mimetype', 255);
            $table->text('metadata')->nullable();
        });
    }
1211693
function up(){
        console.log(grunt.target);
        var key = (grunt.option('name') || ""),
            label = ( key || "EMPTY"),
            cmd = (migrateBinPath + " up " + key).trim();

        grunt.log.write('Running migration "UP" [' + label + ']...').ok();
        run(cmd);
    }
6355
public function up()
    {
        Schema::create('asset_downloads', function (Blueprint $table) {
            $table->bigInteger('id', true)->unsigned();
            $table->integer('asset_id')->unsigned()->index('asset_downloads_asset_id');
            $table->integer('time')->unsigned()->nullable();
            $table->integer('ip')->nullable();
            $table->index(['ip', 'asset_id', 'time'], 'asset_downloads_ip_asset_id_time');
        });
    }
1210903
public function up()
    {
        Schema::table('user_settings', function (Blueprint $table) {
            $table->integer('value')->nullable()->comment = "value set by user";
            $table->timestamp('set_at')->nullable();
        });
    }
1335057
public function migrateUp()
    {
        $this->builder->create(
            $this->table,
            function ($table) {
                $table->bigIncrements('id');

                $table->string('sha1', 40)->index();
                $table->text('statement');
                $table->double('time')->index();
                $table->integer('connection_id')->unsigned();

                $table->timestamps();
                $table->index('created_at');
                $table->index('updated_at');
            }
        );
    }
508577
public function up()
    {
        Schema::create('files', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->integer('folder_id')->unsigned()->nullable();
            $table->enum('type', ['a', 'v', 'd', 'i', 'o', 'f'])->nullable();
            $table->string('name')->nullable();
            $table->string('path')->nullable();
            $table->string('extension', 8)->nullable();
            $table->string('mimetype', 100)->nullable();
            $table->integer('width')->unsigned()->nullable();
            $table->integer('height')->unsigned()->nullable();
            $table->integer('filesize')->unsigned()->nullable();
            $table->integer('position')->unsigned()->default(0);
            $table->json('description');
            $table->json('alt_attribute');
            $table->timestamps();
            $table->foreign('folder_id')->references('id')->on('files');
        });
    }