Migrate up

@access public
512942
public function up() {
		$table = File::trait_get_database_table();

		$db = Database::get();
		$ids = $db->get_column('SELECT id FROM ' . $table, []);
		foreach ($ids as $id) {
			$file = File::get_by_id($id);
			$old_path = $this->get_old_path($file);
			if (!file_exists($old_path)) {
				continue;
			}
			$new_path = $file->get_path();

			// create directory if not exist
			$pathinfo = pathinfo($new_path);
			if (!is_dir($pathinfo['dirname'])) {
				mkdir($pathinfo['dirname'], 0755, true);
			}

			rename($old_path, $new_path);
		}

		/**
		 * Run this to cleanup empty directories
		 */
//		echo 'find ' . $path . ' -type d -empty -delete';
	}
1305387
public function up()
    {
        Schema::create('wink_tags', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('slug')->unique();
            $table->string('name');
            $table->timestamps();

            $table->index('created_at');
        });

        Schema::create('wink_posts_tags', function (Blueprint $table) {
            $table->uuid('post_id');
            $table->uuid('tag_id');

            $table->unique(['post_id', 'tag_id']);
        });

        Schema::create('wink_posts', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('slug')->unique();
            $table->string('title');
            $table->text('excerpt');
            $table->text('body');
            $table->boolean('published')->default(false);
            $table->dateTime('publish_date')->default('2018-10-10 00:00:00');
            $table->string('featured_image')->nullable();
            $table->string('featured_image_caption');
            $table->uuid('author_id')->index();
            $table->timestamps();
        });

        Schema::create('wink_authors', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('slug')->unique();
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->text('bio');
            $table->string('avatar')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });

        Schema::create('wink_pages', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('slug')->unique();
            $table->string('title');
            $table->text('body');
            $table->timestamps();
        });
    }
642468
public function up()
    {

        $date = new Carbon;

        $themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
        $updateAction = DB::table('admin_actions')->select('id')->where('controller_id', '=', $themesController->id)->where('action', '=', 'update')->first();

        DB::table('admin_actions')->insert(
            array(
                array(
                    'controller_id' => $themesController->id,
                    'action' => 'forms',
                    'inherit' => 0,
                    'edit_based' => 0,
                    'name' => 'Change Form Rules',
                    'about' => null,
                    'created_at' => $date,
                    'updated_at' => $date
                )
            )
        );

        $lastInsertId = DB::getPdo()->lastInsertId();

        DB::table('user_roles_actions')->insert(
            array(
                array(
                    'role_id' => 2,
                    'action_id' => $updateAction->id,
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'role_id' => 2,
                    'action_id' => $lastInsertId,
                    'created_at' => $date,
                    'updated_at' => $date
                )
            )
        );

        DB::table('admin_actions')->where('controller_id', '=', $themesController->id)->where('action', '=', 'update')->update(['inherit' => 0]);
        DB::table('admin_actions')->where('controller_id', '=', $themesController->id)->where('action', '=', 'index')->update(['name' => 'Show Theme Management']);

    }
1354145
public function up()
    {
        $postgis = DB::table('pg_proc')->where('proname', 'postgis_full_version')->first();
        if(!$postgis) dd('The postgis extension is not installed. Run `CREATE EXTENSION postgis;` to install');

        Schema::create('dids', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->uuid('user_id')->index();
            $table->string('text')->index();
            $table->uuid('source_id')->index();
            $table->point('geo')->nullable();
            $table->json('location')->nullable();
            $table->timestamps();

            $table->index('created_at');
            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('source_id')->references('id')->on('sources');
        });

        // if using pgsql create a full text search index and the uuid timestamp function
        if(DB::connection()->getDriverName() == 'pgsql'){
            DB::statement('ALTER TABLE dids ADD searchable tsvector NULL');
            DB::statement('CREATE INDEX dids_searchable_index ON dids USING GIST (searchable)');
            DB::statement('CREATE TRIGGER ts_searchable 
                BEFORE INSERT OR UPDATE ON dids 
                FOR EACH ROW EXECUTE PROCEDURE 
                    tsvector_update_trigger(\'searchable\', \'pg_catalog.english\', \'text\')'
            );

            DB::statement('
                CREATE OR REPLACE FUNCTION uuid_v1_timestamp (_uuid "uuid")
                RETURNS TIMESTAMP WITH TIME zone AS $$
                
                    SELECT
                        to_timestamp(
                            (
                                (\'x\' || lpad(h, 16, \'0\'))::bit(64)::bigint::DOUBLE PRECISION -
                                122192928000000000
                            ) / 10000000
                        )
                    FROM (
                        SELECT
                            SUBSTRING (u FROM 16 FOR 3) ||
                            SUBSTRING (u FROM 10 FOR 4) ||
                            SUBSTRING (u FROM 1 FOR 8) AS h
                        FROM (VALUES (_uuid::text)) s (u)
                    ) s
                    ;
                
                $$ LANGUAGE SQL immutable;
            ');
        }

        DB::statement('CREATE index uuid_timestamp_ndx ON dids (uuid_v1_timestamp(id));');
    }
1276497
public function up()
    {
        if (Config::get('database')['default'] === 'mysql') {
            DB::statement('alter table ab_events change column instance_id instance_id integer(11)');
            DB::statement('alter table ab_events change column experiments_id experiments_id integer(11)');
    
            DB::statement('alter table ab_goal change column instance_id instance_id integer(11)');
        } else if (Config::get('database')['default'] === 'pgsql') {
            DB::statement('alter table ab_events alter column instance_id type integer using (instance_id::integer)');
            DB::statement('alter table ab_events alter column experiments_id type integer using (experiments_id::integer)');
            
            DB::statement('alter table ab_goal alter column instance_id type integer using (instance_id::integer)');
        }
    }
506205
public function up()
    {
        Schema::create('settings', function (Blueprint $table) {

            $table->increments('id');
            $table->string('module_name', 30);
            $table->enum('action', ['setting', 'xfield', 'creat', 'edit'])->default('setting');
            $table->string('section', 20)->default('main');
            $table->string('fieldset', 20)->default('general');
            $table->string('name', 30);
            $table->string('type', 20)->default('string');
            $table->string('value');
            $table->text('params')->nullable(); // multiline or json, or dinamic values
            $table->text('class')->length(255)->nullable();
            $table->text('html_flags')->length(500)->nullable();
            $table->string('title', 125)->nullable();
            $table->text('descr')->length(500)->nullable();

            // If need to monitor an additional field. I.e.: create and delete him.
            $table->boolean('as_xfield')->nullable();

            $table->index('action');
            $table->index('module_name');
            $table->unique(['name', 'module_name']);
            // $table->foreign('module_id', DB::getTablePrefix() . 'settings_module_id_fk')->references('id')->on('modules')
            $table->foreign('module_name')->references('name')->on('modules')
                  ->onDelete('cascade')->onUpdate('cascade');

            $table->timestamps();
        });
    }
471236
public function up()
    {
        //looks like these two didn't work in previous migrations
        dbexec('DROP TABLE `#__content_rating`');
        dbexec("DELETE FROM `#__components` WHERE `option` IN  ('com_media', 'com_menus', 'com_modules')");

        //add github gist plugin
        dbexec("INSERT INTO `#__plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES (49, 'Content Filter - GithubGist', 'gist', 'contentfilter', 0, 0, 0, 0, 0, 0, '0000-00-00 00:00:00', '')");

        //remove the syntax plugin
        dbexec("DELETE FROM `#__plugins` WHERE `element` IN ('syntax', 'ptag') ");

        //remove anahita from nodes and edges table names
        if (!dbexists('SHOW TABLES LIKE "#__nodes"')) {
            dbexec('RENAME TABLE #__anahita_nodes TO #__nodes');
        }

        if (!dbexists('SHOW TABLES LIKE "#__edges"')) {
            dbexec('RENAME TABLE #__anahita_edges TO #__edges');
        }

        //UTF-8 conversions
        dbexec('ALTER DATABASE CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__edges` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__nodes` CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE name name VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE name name VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE alias alias VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE alias alias VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE body body MEDIUMBLOB');
        dbexec('ALTER TABLE `#__nodes` CHANGE body body MEDIUMTEXT CHARACTER SET utf8mb4');

        dbexec('ALTER TABLE `#__nodes` CHANGE excerpt excerpt TEXT CHARACTER SET utf8mb4');

        dbexec('ALTER TABLE `#__nodes` CHANGE person_given_name person_given_name VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE person_given_name person_given_name VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE person_family_name person_family_name VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE person_family_name person_family_name VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__migrator_migrations` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__migrator_versions` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__opensocial_profiles` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__opensocial_profiles` CHARACTER SET utf8');

        //move these to related components
        dbexec('ALTER TABLE `#__invites_tokens` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__opensocial_profiles` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_coupons` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_packages` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_transactions` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_vats` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__todos_todos` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__topics_topics` CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__users` CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__users` CHANGE name name VARBINARY(255)');
        dbexec('ALTER TABLE `#__users` CHANGE name name VARCHAR(255) CHARACTER SET utf8');

        //updating comments

        $timeThen = microtime(true);
        $db = AnService::get('anahita:database');

        //change comment formats from html to string
        $entities = dbfetch('SELECT id, body FROM `#__nodes` WHERE type LIKE "ComBaseDomainEntityComment%" ');

        dboutput("Updating comments. This WILL take a while ...\n");

        foreach ($entities as $entity) {
            $id = $entity['id'];
            $body = strip_tags($entity['body']);

            $db->update('nodes', array('body' => $body), ' WHERE id='.$id);
        }

        dboutput("Comments updated!\n");

        $timeDiff = microtime(true) - $timeThen;
        dboutput("TIME: ($timeDiff)"."\n");
    }
336022
public function migrateUp()
    {
        $this->builder->create(
            $this->table,
            function ($table) {
                $table->bigIncrements('id');

                $table->bigInteger('domain_id')->unsigned()->index();
                $table->string('url')->index();
                $table->string('host');

                $table->timestamps();
                $table->index('created_at');
                $table->index('updated_at');
            }
        );
    }
482809
public function up()
    {
        DB::statement('create index sites_default on sites(`default`)');
        DB::statement('create index album_asset_asset_id on album_asset(asset_id)');
        DB::statement('create index assets_created_at_asc on assets(created_at asc)');
        DB::statement('create index assets_created_at_desc on assets(created_at desc)');
        DB::statement('create index albums_deleted_at on albums(deleted_at)');
        DB::statement('create index albums_name_asc_deleted_at on albums(name asc, deleted_at)');

        try {
            DB::statement('alter table assets drop index asset_v_rid');
        } catch (\Exception $e) {
        }
    }
1118034
public function up() {
		$db = Database::get();

		$database = $db->get_one('SELECT DATABASE()');

		$indexes = ['completed', 'frozen', 'failed'];

		foreach ($indexes as $index) {
			if ($db->get_one('SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS WHERE 1 AND TABLE_SCHEMA = "' . $database . '" AND TABLE_NAME="transaction" AND INDEX_NAME="' . $index . '"') === null) {
				$db->query('ALTER TABLE `transaction` ADD INDEX `' . $index . '` (`' . $index . '`)');
			}
		}
	}
845816
public function up()
    {
        Schema::create('admin_password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token')->index();
            $table->timestamp('created_at');
        });

        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token')->index();
            $table->timestamp('created_at');
        });

        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->text('description')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('admin_users', function (Blueprint $table) {
            $table->increments('id');
            $table->tinyInteger('is_super_admin')->nullable();
            $table->integer('role_id')->unsigned()->default(null);
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->string('email')->unique();
            $table->string('password');
            $table->string('language')->nullable()->default('en');
            $table->string('image_path')->nullable()->default(null);
            $table->rememberToken();
            $table->timestamps();

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

        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('first_name');
            $table->string('last_name');
            $table->string('email')->unique();
            $table->string('password');
            $table->string('image_path')->nullable();
            $table->string('company_name')->nullable();
            $table->string('phone')->nullable();
            $table->enum('status', ['GUEST', 'LIVE'])->default('LIVE');
            $table->string('activation_token')->nullable()->default(null);
            $table->rememberToken();
            $table->timestamps();
        });

        Schema::create('countries', function (Blueprint $table) {
            $table->increments('id');
            $table->string('code');
            $table->string('name');
            $table->string('phone_code')->nullable()->default(null);
            $table->string('currency_code')->nullable()->default(null);
            $table->string('lang_code')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('site_currencies', function (Blueprint $table) {
            $table->increments('id');
            $table->string('code');
            $table->string('name');
            $table->float('conversion_rate');
            $table->enum('status',['ENABLED','DISABLED'])->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('addresses', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->enum('type', ['SHIPPING', 'BILLING']);
            $table->string('first_name')->nullable()->default(null);
            $table->string('last_name')->nullable()->default(null);
            $table->string('address1')->nullable()->default(null);
            $table->string('address2')->nullable()->default(null);
            $table->string('postcode')->nullable()->default(null);
            $table->string('city')->nullable()->default(null);
            $table->string('state')->nullable()->default(null);
            $table->integer('country_id')->unsigned()->nullable()->default(null);
            $table->string('phone')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
        });

        Schema::create('oauth_auth_codes', function (Blueprint $table) {
            $table->string('id', 100)->primary();
            $table->integer('user_id');
            $table->integer('client_id');
            $table->text('scopes')->nullable();
            $table->boolean('revoked');
            $table->dateTime('expires_at')->nullable();
        });

        Schema::create('oauth_access_tokens', function (Blueprint $table) {
            $table->string('id', 100)->primary();
            $table->integer('user_id')->index()->nullable();
            $table->integer('client_id');
            $table->string('name')->nullable();
            $table->text('scopes')->nullable();
            $table->boolean('revoked');
            $table->timestamps();
            $table->dateTime('expires_at')->nullable();
        });

        Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
            $table->string('id', 100)->primary();
            $table->string('access_token_id', 100)->index();
            $table->boolean('revoked');
            $table->dateTime('expires_at')->nullable();
        });

        Schema::create('oauth_clients', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->index()->nullable();
            $table->string('name');
            $table->string('secret', 100);
            $table->text('redirect');
            $table->boolean('personal_access_client');
            $table->boolean('password_client');
            $table->boolean('revoked');
            $table->timestamps();
        });

        Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('client_id')->index();
            $table->timestamps();
        });

        Schema::create('pages', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('slug')->nullable()->default(null);
            $table->text('content')->nullable()->default(null);
            $table->string('meta_title')->nullable();
            $table->string('meta_description')->nullable();
            $table->timestamps();
        });

        Schema::create('wishlists', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('permissions', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->timestamps();
        });

        Schema::create('permission_role', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('permission_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->timestamps();

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

        Schema::create('states', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('country_id')->unsigned();
            $table->string('code');
            $table->string('name');
            $table->timestamps();

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

        Schema::table('orders', function (Blueprint $table) {
            $table->integer('user_id')->unsigned()->nullable();
            $table->integer('shipping_address_id')->unsigned()->nullable();
            $table->integer('billing_address_id')->unsigned()->nullable();

            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('shipping_address_id')->references('id')->on('addresses');
            $table->foreign('billing_address_id')->references('id')->on('addresses');
        });

        
        $path = __DIR__ .'/../../assets/countries.json';
        $json = json_decode(file_get_contents($path), true);
        foreach ($json as $code => $country) {
            
            Country::create(['code' => strtolower($code), 
                            'name' => $country['name'],
                            'phone_code' => $country['phone'],
                            'currency_code' => $country['currency'],
                            'lang_code' => (isset($country['languages'][0]) && $country['languages']) ?? null,
                            ]);
        }

        Schema::create('menus', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('parent_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('route')->nullable()->default(null);
            $table->string('params')->nullable()->default(null);

            $table->timestamps();
        });

        $countryModel = Country::whereCode('NZ')->first();
        $siteCurrency = SiteCurrency::create([
            'name'              => 'NZ Dollars',
            'code'              => 'NZD',
            'conversion_rate'   => 1,
            'status'            => 'ENABLED'
        ]);

        Configuration::create([
            'configuration_key' => 'general_site_currency',
            'configuration_value' => $siteCurrency->id,
            ]);

        Configuration::create([
            'configuration_key' => 'tax_default_country',
            'configuration_value' => $countryModel->id,
            ]);

        Configuration::create([
            'configuration_key' => 'tax_enabled',
            'configuration_value' => 1,
        ]);

        Configuration::create([
            'configuration_key' => 'tax_percentage',
            'configuration_value' => 15,
        ]);

        Configuration::create([
            'configuration_key' => 'general_site_title', 
            'configuration_value' => 'AvoRed an Laravel Ecommerce'
        ]);
        Configuration::create([
            'configuration_key' => 'general_site_description',
            'configuration_value' => 'AvoRed is a free open-source e-commerce application development platform written in PHP based on Laravel. Its an ingenuous and modular e-commerce that is easily customizable according to your needs, with a modern responsive mobile friendly interface as default'            
        ]);
        Configuration::create([
            'configuration_key' => 'general_site_description', 
            'configuration_value' => 'AvoRed Laravel Ecommerce
        ']);
        

    }
537493
public function migrateUp()
    {
        try {
            $this->builder->table(
                $this->table,
                function ($table) {
                    $table->string('value')->nullable()->change();
                }
            );
        } catch (\Exception $e) {
            dd($e->getMessage());
        }
    }
534121
public function up()
	{
		Schema::create($this->getTable(), function (Blueprint $table) {
			$table->engine = "innoDB";
			$table->unsignedBigInteger('id', true);
			$table->enum('port', [
				Enum::MELLAT,
				Enum::SADAD,
				Enum::ZARINPAL,
				Enum::PAYLINE,
				Enum::JAHANPAY,
				Enum::PARSIAN,
				Enum::PASARGAD,
				Enum::SAMAN,
				Enum::ASANPARDAKHT,
				Enum::PAYPAL,
				Enum::PAYIR
			]);
			$table->decimal('price', 15, 2);
			$table->string('ref_id', 100)->nullable();
			$table->string('tracking_code', 50)->nullable();
			$table->string('card_number', 50)->nullable();
			$table->enum('status', [
				Enum::TRANSACTION_INIT,
				Enum::TRANSACTION_SUCCEED,
				Enum::TRANSACTION_FAILED,
			])->default(Enum::TRANSACTION_INIT);
			$table->string('ip', 20)->nullable();
			$table->timestamp('payment_date')->nullable();
			$table->nullableTimestamps();
			$table->softDeletes();
		});
	}
1373343
public function up()
    {

        $date = new Carbon;
        DB::table('admin_controllers')->insert(
            array(
                array(
                    'controller' => 'search',
                    'role_name' => 'Search log',
                    'role_order' => 4,
                    'role_section' => 3,
                    'created_at' => $date,
                    'updated_at' => $date
                )
            )
        );
        $controller_id = DB::getPdo()->lastInsertId();
        DB::table('admin_actions')->insert(
            array(
                array(
                    'controller_id' => $controller_id,
                    'action' => 'index',
                    'inherit' => -1,
                    'edit_based' => 0,
                    'name' => 'View Search Log',
                    'about' => null,
                    'created_at' => $date,
                    'updated_at' => $date
                )
            )
        );

    }
1245511
public function up()
    {
        Schema::table('z_users', function (Blueprint $table) {
            $table->string('gender', 8)->nullable(); // Male, Female
            $table->string('mobile')->nullable();
            $table->tinyInteger('is_active')->default(1);
            $table->timestamp('last_login_at')->nullable();
            $table->integer('login_times')->default(0);
            $table->integer('avatar_id')->nullable();
            $table->softDeletes();
        });
        Schema::table('z_roles', function (Blueprint $table) {
            $table->string('label');
        });
        Schema::table('z_permissions', function (Blueprint $table) {
            $table->string('label');
        });
    }
112988
public function migrateUp()
    {
        $this->builder->table(
            $this->table,
            function ($table) {
                $table->string('medium')->nullable()->index();
                $table->string('source')->nullable()->index();
                $table->string('search_terms_hash')->nullable()->index();
            }
        );

        $this->builder->table($this->foreign, function ($table) {
            $table->foreign('referer_id', 'tracker_referers_referer_id_fk')
                ->references('id')
                ->on('tracker_referers')
                ->onUpdate('cascade')
                ->onDelete('cascade');
        });
    }
196994
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');

        if (!Schema::hasColumn('user_config', 'alt_auth_db_service_id')) {
            Schema::table('user_config', function (Blueprint $t) use ($onDelete){
                $t->integer('alt_auth_db_service_id')->unsigned()->nullable();
                $t->foreign('alt_auth_db_service_id')->references('id')->on('service')->onDelete($onDelete);
                $t->string('alt_auth_table')->nullable();
                $t->string('alt_auth_username_field')->nullable();
                $t->string('alt_auth_password_field')->nullable();
                $t->string('alt_auth_email_field')->nullable();
                $t->string('alt_auth_other_fields')->nullable();
                $t->string('alt_auth_filter')->nullable();
            });
        }
    }