Migrate up

@access public
517753
public function up() {
		$db = Database::get();

		// check if the columns for crop functionality are present
		$columns = $db->get_all("SHOW COLUMNS FROM `picture`;");
		foreach ($columns as $column) {
			if ($column['Field'] == 'crop_width' || $column['Field'] == 'crop_height') {
				return;
			}
		}

		// add the columns needed for crop feature
		$db->query("ALTER TABLE `picture`
					ADD `crop_width` INT(11) NOT NULL,
					ADD `crop_height` INT(11) NOT NULL,
					ADD `crop_offset_left` INT(11) NOT NULL,
					ADD `crop_offset_top` INT(11) NOT NULL");
	}
1091274
public function up()
    {
        // CAUTION: only works and tested on MySQL
        // Legacy support, default type MyISAM doesn't support foreign key
        // Convert table to InnoDB
        if (Schema::hasTable('products')) {
            DB::statement('ALTER TABLE products ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('categories')) {
            DB::statement('ALTER TABLE categories ENGINE = InnoDB');
        }

        if (Schema::hasTable('pricelists')) {
            DB::statement('ALTER TABLE pricelists ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('medias')) {
            DB::statement('ALTER TABLE medias ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('modules')) {
            DB::statement('ALTER TABLE modules ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('memberships')) {
            DB::statement('ALTER TABLE memberships ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('coupons')) {
            DB::statement('ALTER TABLE coupons ENGINE = InnoDB');
        }
    }
126390
public function up()
    {
        //======
        // USERS
        //======
        // Either uncomment the section below to create the users table if it
        // was not already done before, or use it as an example for your own
        // migration.
//        // Create users table
//        Schema::create('users', function (Blueprint $table) {
//            $table->increments('id');
//            $table->string('first_name');
//            $table->string('last_name');
//            $table->string('username')->unique();
//            $table->string('email')->unique();
//            $table->string('password', 60);
//            $table->rememberToken();
//            $table->timestamps();
//        });

        // USERS: Add the auth_type column.
        Schema::table('users', function (Blueprint $table) {
            $table->string('auth_type')->nullable();
        });

        //=======
        // GROUPS
        //=======
        // Either uncomment the section below to create the groups table if it
        // was not already done before, or use it as an example for your own
        // migration.
//        // Create table for storing groups
//        Schema::create('groups', function (Blueprint $table) {
//            $table->increments('id');
//            $table->string('name')->unique();
//            $table->string('display_name')->nullable();
//            $table->string('description')->nullable();
//            $table->timestamps();
//        });
//
//        // Create table for associating groups to users (Many-to-Many)
//        Schema::create('group_user', function (Blueprint $table) {
//            $table->integer('user_id')->unsigned();
//            $table->integer('group_id')->unsigned();
//
//            $table->foreign('user_id')->references('id')->on('users')
//                ->onUpdate('cascade')->onDelete('cascade');
//            $table->foreign('group_id')->references('id')->on('groups')
//                ->onUpdate('cascade')->onDelete('cascade');
//
//            $table->primary(['user_id', 'group_id']);
//        });

        // GROUPS: Add the resync_on_login column.
        Schema::table('groups', function (Blueprint $table) {
            $table->boolean('resync_on_login')->default(false);
        });


    }
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();
		});
	}
645417
public function up() {

        $table = $this->table('roles');
        $table
                ->addColumn('name', 'string', [
                    'limit'   => '50',
                    'null'    => '',
                    'default' => '0',
                ])
                ->addColumn('login_redirect', 'string', [
                    'limit'   => '256',
                    'null'    => true,
                    'default' => '',
                ])
                ->addColumn('created', 'datetime', [
                    'limit'   => '',
                    'null'    => '',
                    'default' => '0000-00-00 00:00:00',
                ])
                ->addColumn('modified', 'datetime', [
                    'limit'   => '',
                    'null'    => '',
                    'default' => '0000-00-00 00:00:00',
                ])
                ->create();


        $table = $this->table('users');
        $table
                ->addColumn('role_id', 'integer', [
                    'limit'  => '11',
                    'signed' => '',
                    'null'   => true,
                ])
                ->addColumn('email', 'string', [
                    'limit'   => '255',
                    'null'    => '',
                    'default' => '',
                ])
                ->addColumn('active', 'integer', [
                    'limit'   => '11',
                    'null'    => '',
                    'default' => 0,
                ])
                ->addColumn('activation_key', 'string', [
                    'limit'   => '200',
                    'null'    => '',
                    'default' => '',
                ])
                ->addColumn('password', 'string', [
                    'limit'   => '255',
                    'null'    => '',
                    'default' => '',
                ])
                ->addColumn('created', 'datetime', [
                    'limit'   => '',
                    'null'    => true,
                    'default' => '0000-00-00 00:00:00',
                ])
                ->addColumn('modified', 'datetime', [
                    'limit'   => '',
                    'null'    => true,
                    'default' => '0000-00-00 00:00:00',
                ])
                ->create();

    }
532683
public function migrateUp()
    {
        $this->builder->table(
            $this->table,
            function ($table) {
                $table->bigInteger('language_id')->unsigned()->nullable()->index();
            }
        );
    }
500474
public function migrateUp()
    {
        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->mediumText('log_new')->nullable()->after('was_ok');
        });

        Database::statement('update tddd_runs set log_new = log;');

        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->dropColumn('log');
            $table->renameColumn('log_new', 'log');
        });
    }
367368
public function up()
    {
        Schema::create('hc_resource_grab_property', function (Blueprint $table) {
            $table->increments('count');
            $table->uuid('id')->unique();
            $table->datetime('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->datetime('updated_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->datetime('deleted_at')->nullable();

            $table->uuid('thumbnail_id');
            $table->uuid('resource_id');

            $table->uuid('source_id');
            $table->string('source_type');

            $table->integer('x')->nullable();
            $table->integer('y')->nullable();
            $table->double('zoom')->nullable();

            $table->foreign('resource_id')->references('id')->on('hc_resource')->onUpdate('CASCADE')->onDelete('CASCADE');
            $table->foreign('thumbnail_id')->references('id')->on('hc_resource_thumbnail')->onUpdate('CASCADE')->onDelete('CASCADE');
        });
    }
80224
public function up()
	{
		/*Schema::create('ACCT_User', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('firstname',60);
			$table->string('lastname',60);
			$table->string('email');
			//$table->boolean('is_active');
			//$table->boolean('is_admin');
			//$table->string('timezone', 60)->nullable();
			//$table->unsignedInteger('main_db_id')->nullable();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});*/


		Schema::create('ACCT_Setting', function(Blueprint $table)
		{
			$table->increments('id');
			$table->smallInteger('initial_year')->nullable();
			$table->char('voucher_numeration_type', 1)->nullable();//Periodo,Period:P and Periodo y tipo de partida, Period and Voucher Type: A
			$table->boolean('create_opening_period')->default(false);
			$table->boolean('create_closing_period')->default(false);

			//PDF Journal Voucher
			$table->boolean('cost_center_is_visible')->default(false);
			$table->string('revised_by', 100)->nullable();
			$table->string('authorized_by', 100)->nullable();

			$table->boolean('is_configured')->default(false);

			//Foreign Keys
			$table->unsignedInteger('account_chart_type_id')->index()->nullable();
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});

		Schema::create('ACCT_Fiscal_Year', function(Blueprint $table)
		{
			$table->increments('id');
			$table->smallInteger('year')->index();
			$table->date('start_date');
			$table->date('end_date');
			$table->boolean('is_closed')->default(false);

			//Foreign Keys
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});

		Schema::create('ACCT_Period', function(Blueprint $table)
		{
			$table->increments('id');
			$table->smallInteger('month');
			$table->date('start_date');
			$table->date('end_date');
			$table->boolean('is_closed')->default(false);

			//Foreign Keys
			$table->unsignedInteger('fiscal_year_id')->index();
			$table->foreign('fiscal_year_id')->references('id')->on('ACCT_Fiscal_Year');

			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});


		Schema::create('ACCT_Account_Type', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name');
			$table->string('lang_key',100)->nullable();
			$table->char('key', 1)->nullable();
			$table->char('pl_bs_category', 1)->index();//Pérdidas y Ganancias (Cuenta de ingresos) -- B, Pérdidas y Ganancias (Cuenta de gastos) -- C, Balance (Cuenta de activo)  -- D, Balance (Cuenta de pasivo) -- E

			$table->char('deferral_method', 1)->nullable();

			//Foreign Keys
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});

		Schema::create('ACCT_Account', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('key');
			$table->string('name');
			$table->char('balance_type', 1);//Deudor,Receivable:D and Acreedor,Payable: A
			$table->boolean('is_group')->index()->default(false);
			$table->boolean('is_general_ledger_account')->index()->default(false);

			//Foreign Keys
			$table->unsignedInteger('account_type_id')->index();
			$table->foreign('account_type_id')->references('id')->on('ACCT_Account_Type');
			$table->unsignedInteger('parent_account_id')->index()->nullable();
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});

		Schema::table('ACCT_Account', function(Blueprint $table)
		{
			//Foreign Key
			$table->foreign('parent_account_id')->references('id')->on('ACCT_Account');
		});

		Schema::create('ACCT_Cost_Center', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('key');
			$table->string('name');
			//$table->char('type', 1);//Group (G) or Ledger (L)
			$table->boolean('is_group')->index()->default(false);

			//Foreign Keys
			$table->unsignedInteger('parent_cc_id')->index()->nullable();
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});

		Schema::table('ACCT_Cost_Center', function(Blueprint $table)
		{
			//Foreign Key
			$table->foreign('parent_cc_id')->references('id')->on('ACCT_Cost_Center');
		});

		Schema::create('ACCT_Voucher_Type', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name');
			$table->string('abbreviation', 10);
			$table->string('lang_key',100)->nullable();
			$table->char('key', 1)->nullable();//Opening Entry: O, Closing Entry: C

			//Foreign Keys
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes
		});

		Schema::create('ACCT_Journal_Voucher', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('number')->index();
			$table->date('date');
			$table->string('manual_reference')->nullable();
			$table->text('remark');
			$table->string('system_reference_type', 40)->index()->nullable();
			$table->string('system_reference_field', 40)->index()->nullable();
			$table->unsignedInteger('system_reference_id')->index()->nullable();
			$table->boolean('is_editable')->default(false);
			$table->char('status', 1)->index();//A = No Cuadrada, B = Cuadrada

			//document
			$table->date('document_date')->nullable();
			$table->unsignedInteger('document_type_id')->index()->nullable();
			$table->string('document_number', 40)->index()->nullable();
			$table->double('document_amount', 13, 2);
			$table->unsignedInteger('supplier_id')->index()->nullable();
			$table->unsignedInteger('client_id')->index()->nullable();
			$table->unsignedInteger('employee_id')->index()->nullable();

			//Foreign Keys
			$table->unsignedInteger('voucher_type_id')->index();
			$table->foreign('voucher_type_id')->references('id')->on('ACCT_Voucher_Type');
			$table->unsignedInteger('period_id')->index();
			$table->foreign('period_id')->references('id')->on('ACCT_Period');
			$table->unsignedInteger('created_by');
			//$table->foreign('created_by')->references('id')->on('ACCT_User');
			$table->unsignedInteger('organization_id')->index();

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes

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

		Schema::create('ACCT_Journal_Entry', function(Blueprint $table)
		{
			$table->increments('id');
			//$table->float('number');
			$table->double('debit', 13, 2);
			$table->double('credit', 13, 2);
			$table->string('remark')->nullable();
			$table->string('system_reference_type', 40)->index()->nullable();
			$table->string('system_reference_field', 40)->index()->nullable();
			$table->unsignedInteger('system_reference_id')->index()->nullable();

			//Foreign Keys
			$table->unsignedInteger('journal_voucher_id')->index()->nullable();
			$table->foreign('journal_voucher_id')->references('id')->on('ACCT_Journal_Voucher');
			$table->unsignedInteger('cost_center_id');
			$table->foreign('cost_center_id')->references('id')->on('ACCT_Cost_Center');
			$table->unsignedInteger('account_id');
			$table->foreign('account_id')->references('id')->on('ACCT_Account');
			//$table->unsignedInteger('organization_id');

			//Timestamps
			$table->timestamps(); //Adds created_at and updated_at columns
			$table->softDeletes(); //Adds deleted_at column for soft deletes

			$table->index('deleted_at');
		});
	}
623955
public function up()
	{
		if(Schema::hasColumn('001_017_text', 'lang_017'))
		{
			$key = DB::select(DB::raw('SHOW KEYS FROM 001_017_text WHERE Key_name=\'fk01_001_017_text\''));

			if($key != null)
			{
				Schema::table('001_017_text', function (Blueprint $table) {
					$table->dropForeign('fk01_001_017_text');
					$table->dropIndex('fk01_001_017_text');
				});

				Schema::table('001_017_text', function (Blueprint $table) {
					// rename column, function renameColumn doesn't work
					DB::select(DB::raw('ALTER TABLE 001_017_text CHANGE lang_017 lang_id_017 VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
					$table->foreign('lang_id_017', 'fk01_001_017_text')->references('id_001')->on('001_001_lang')
						->onDelete('restrict')->onUpdate('cascade');
				});
			}
		}
	}
621734
public function up()
    {
        if (Schema::hasColumn('system_config', 'login_with_user_name')) {
            if ('sqlsrv' == DB::connection()->getDriverName()) {
                $defaultContraint = DB::selectOne("SELECT OBJECT_NAME([default_object_id]) AS name FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID('[dbo].[system_config]') AND [name] = 'login_with_user_name'");
                DB::statement("ALTER TABLE [dbo].[system_config] DROP CONSTRAINT $defaultContraint->name");
            }

            Schema::table('system_config', function (Blueprint $t) {
                $t->dropColumn('login_with_user_name');
            });
        }
    }
450656
public function up()
    {

        if (!Schema::hasTable('reg2005_accounts')) {
            //
            Schema::create('reg2005_accounts', function (Blueprint $table) {
                $table->increments('id');
                $table->text('login')->nullable();
                $table->text('password')->nullable();
                $table->text('protocol')->nullable();
                $table->text('address')->nullable();

                $table->decimal('USD', 10)->nullable()->default(0);
                $table->decimal('RUB', 10)->nullable()->default(0);
                $table->decimal('BTC', 14, 8)->nullable()->default(0);
                $table->decimal('EUR', 10)->nullable()->default(0);
                $table->decimal('KZT', 10)->nullable()->default(0);
                $table->decimal('GOLD', 10)->nullable()->default(0);

                $table->decimal('in_turnover_current_monthly', 10)->nullable()->default(0);
                $table->decimal('out_turnover_current_monthly', 10)->nullable()->default(0);

                $table->integer('no_active')->default(0);
                $table->integer('error_out_pays')->default(0);
                $table->text('type')->nullable();
                $table->text('site')->nullable();

                $table->integer('upd_history')->nullable()->default(0);

                $table->timestamp('last_history')->default('2016-01-01 00:00:00');
                $table->timestamp('last_use')->default(DB::raw('CURRENT_TIMESTAMP'));
                $table->timestamps();
            });

        }
    }
1340998
public function up()
    {
        Schema::create($this->prefixCmsTable('users'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('email');
            $table->string('password');
            $table->text('permissions')->nullable();
            $table->timestamp('last_login')->nullable();
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->boolean('is_superadmin')->default(false);
            $table->nullableTimestamps();

            $table->unique('email');
        });

        Schema::create($this->prefixCmsTable('activations'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->string('code');
            $table->boolean('completed')->default(0);
            $table->timestamp('completed_at')->nullable();
            $table->nullableTimestamps();

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('activations_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('persistences'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->string('code');
            $table->nullableTimestamps();

            $table->unique('code');

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('persistences_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('reminders'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->string('code');
            $table->boolean('completed')->default(0);
            $table->timestamp('completed_at')->nullable();
            $table->nullableTimestamps();

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('reminders_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('roles'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('slug');
            $table->string('name');
            $table->text('permissions')->nullable();
            $table->nullableTimestamps();

            $table->unique('slug');
        });

        Schema::create($this->prefixCmsTable('role_users'), function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->nullableTimestamps();

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

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('role_users_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');

            $table->foreign('role_id', 'fk_' . $this->prefixCmsTable('role_users_roles1'))
                  ->references('id')->on($this->prefixCmsTable('roles'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('throttle'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned()->nullable();
            $table->string('type');
            $table->string('ip')->nullable();
            $table->nullableTimestamps();

            $table->index('user_id');

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('throttle_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });
    }
784378
public function up()
    {
        /*

        CREATE TABLE `list_options` (
          `list_id` varchar(31) NOT NULL DEFAULT '',
          `option_id` varchar(31) NOT NULL DEFAULT '',
          `title` varchar(255) NOT NULL DEFAULT '',
          `seq` int(11) NOT NULL DEFAULT '0',
          `is_default` tinyint(1) NOT NULL DEFAULT '0',
          `option_value` float NOT NULL DEFAULT '0',
          `mapping` varchar(31) NOT NULL DEFAULT '',
          `notes` varchar(255) NOT NULL DEFAULT '',
          `codes` varchar(255) NOT NULL DEFAULT '',
          `toggle_setting_1` tinyint(1) NOT NULL DEFAULT '0',
          `toggle_setting_2` tinyint(1) NOT NULL DEFAULT '0',
          `activity` tinyint(4) NOT NULL DEFAULT '1',
          `subtype` varchar(31) NOT NULL DEFAULT ''
        )

         * */

        Schema::create('list_options', function (Blueprint $table) {
            $table->string('list_id');
            $table->string('option_id');
            $table->string('title');
            $table->integer('seq');
            $table->integer('is_default');
            $table->float('option_value');
            $table->string('mapping');
            $table->string('notes');
            $table->string('codes');
            $table->integer('toggle_setting_1');
            $table->integer('toggle_setting_2');
            $table->integer('activity');
            $table->string('subtype');
        });

        DB::statement(
            DB::raw( "INSERT INTO list_options (list_id,option_id,title,seq,is_default)
            VALUES  
            (\"county\",\"Cork\",\"Cork\",0,0),
            (\"county\",\"Galway\",\"Galway\",0,0),
            (\"county\",\"Mayo\",\"Mayo\",0,0),
            (\"county\",\"Donegal\",\"Donegal\",0,0),
            (\"county\",\"Kerry\",\"Kerry\",0,0),
            (\"county\",\"Tipperary\",\"Tipperary\",0,0),
            (\"county\",\"Clare\",\"Clare\",0,0),
            (\"county\",\"Tyrone\",\"Tyrone\",0,0),
            (\"county\",\"Antrim\",\"Antrim\",0,0),
            (\"county\",\"Limerick\",\"Limerick\",0,0),
            (\"county\",\"Roscommon\",\"Roscommon\",0,0),
            (\"county\",\"Down\",\"Down\",0,0),
            (\"county\",\"Wexford\",\"Wexford\",0,0),
            (\"county\",\"Meath\",\"Meath\",0,0),
            (\"county\",\"Londonderry\",\"Londonderry\",0,0),
            (\"county\",\"Kilkenny\",\"Kilkenny\",0,0),
            (\"county\",\"Wicklow\",\"Wicklow\",0,0),
            (\"county\",\"Offaly\",\"Offaly\",0,0),
            (\"county\",\"Cavan\",\"Cavan\",0,0),
            (\"county\",\"Waterford\",\"Waterford\",0,0),
            (\"county\",\"Westmeath\",\"Westmeath\",0,0),
            (\"county\",\"Sligo\",\"Sligo\",0,0),
            (\"county\",\"Laois\",\"Laois\",0,0),
            (\"county\",\"Kildare\",\"Kildare\",0,0),
            (\"county\",\"Fermanagh\",\"Fermanagh\",0,0),
            (\"county\",\"Leitrim\",\"Leitrim\",0,0),
            (\"county\",\"Armagh\",\"Armagh\",0,0),
            (\"county\",\"Monaghan\",\"Monaghan\",0,0),
            (\"county\",\"Longford\",\"Longford\",0,0),
            (\"county\",\"Dublin\",\"Dublin\",0,0),
            (\"county\",\"Carlow\",\"Carlow\",0,0),
            (\"county\",\"Louth\",\"Louth\",0,0);"
        ));


        DB::statement(
            DB::raw( "INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`) 
            VALUES 
            ('personal_relationship', 'ADOPT', 'Adopted Child', 10, 0, 0, '', 'ADOPT', '', 0, 0, 1, ''),
            ('personal_relationship', 'AUNT', 'Aunt', 20, 0, 0, '', 'AUNT', '', 0, 0, 1, ''),
            ('personal_relationship', 'CHILD', 'Child', 30, 0, 0, '', 'CHILD', '', 0, 0, 1, ''),
            ('personal_relationship', 'CHLDFOST', 'Foster Child', 80, 0, 0, '', 'CHLDFOST', '', 0, 0, 1, ''),
            ('personal_relationship', 'CHLDINLAW', 'Child in-law', 40, 0, 0, '', 'CHLDINLAW', '', 0, 0, 1, ''),
            ('personal_relationship', 'COUSN', 'Cousin', 50, 0, 0, '', 'COUSN', '', 0, 0, 1, ''),
            ('personal_relationship', 'DOMPART', 'Domestic Partner', 60, 0, 0, '', 'DOMPART', '', 0, 0, 1, ''),
            ('personal_relationship', 'FAMMEMB', 'Family Member', 70, 0, 0, '', 'FAMMEMB', '', 0, 0, 1, ''),
            ('personal_relationship', 'FRND', 'Unrelated Friend', 400, 0, 0, '', 'FRND', '', 0, 0, 1, ''),
            ('personal_relationship', 'GGRPRN', 'Great Grandparent', 120, 0, 0, '', 'GGRPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'GPARNT', 'Grandparent', 100, 0, 0, '', 'GPARNT', '', 0, 0, 1, ''),
            ('personal_relationship', 'GRNDCHILD', 'Grandchild', 90, 0, 0, '', 'GRNDCHILD', '', 0, 0, 1, ''),
            ('personal_relationship', 'GRPRN', 'Grandparent', 110, 0, 0, '', 'GRPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'HSIB', 'Half-Sibling', 130, 0, 0, '', 'HSIB', '', 0, 0, 1, ''),
            ('personal_relationship', 'MAUNT', 'MaternalAunt', 140, 0, 0, '', 'MAUNT', '', 0, 0, 1, ''),
            ('personal_relationship', 'MCOUSN', 'MaternalCousin', 150, 0, 0, '', 'MCOUSN', '', 0, 0, 1, ''),
            ('personal_relationship', 'MGGRPRN', 'MaternalGreatgrandparent', 170, 0, 0, '', 'MGGRPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'MGRPRN', 'MaternalGrandparent', 160, 0, 0, '', 'MGRPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'MUNCLE', 'MaternalUncle', 180, 0, 0, '', 'MUNCLE', '', 0, 0, 1, ''),
            ('personal_relationship', 'NBOR', 'Neighbor', 220, 0, 0, '', 'NBOR', '', 0, 0, 1, ''),
            ('personal_relationship', 'NCHILD', 'Natural Child', 190, 0, 0, '', 'NCHILD', '', 0, 0, 1, ''),
            ('personal_relationship', 'NIENEPH', 'Niece/Nephew', 230, 0, 0, '', 'NIENEPH', '', 0, 0, 1, ''),
            ('personal_relationship', 'NPRN', 'Natural Parent', 200, 0, 0, '', 'NPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'NSIB', 'Natural Sibling', 210, 0, 0, '', 'NSIB', '', 0, 0, 1, ''),
            ('personal_relationship', 'PAUNT', 'PaternalAunt', 260, 0, 0, '', 'PAUNT', '', 0, 0, 1, ''),
            ('personal_relationship', 'PCOUSN', 'PaternalCousin', 270, 0, 0, '', 'PCOUSN', '', 0, 0, 1, ''),
            ('personal_relationship', 'PGGRPRN', 'PaternalGreatgrandparent', 290, 0, 0, '', 'PGGRPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'PGRPRN', 'PaternalGrandparent', 280, 0, 0, '', 'PGRPRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'PRN', 'Parent', 240, 0, 0, '', 'PRN', '', 0, 0, 1, ''),
            ('personal_relationship', 'PRNINLAW', 'parent in-law', 250, 0, 0, '', 'PRNINLAW', '', 0, 0, 1, '');"
            ));

        DB::statement( DB::raw("INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`) VALUES
            ('sex', 'Female', 'Female', 1, 0, 0, '', '', '', 0, 0, 1, ''),
            ('sex', 'Male', 'Male', 2, 0, 0, '', '', '', 0, 0, 1, '');"
        ));
    }
937968
public function migrateUp()
    {
        Schema::table('tddd_testers', function (Blueprint $table) {
            $table->dropColumn('require_tee');

            $table->dropColumn('require_script');

            $table->text('pipers');
        });
    }
1092996
public function migrateUp()
    {
        try {
            $this->builder->table(
                $this->table,
                function ($table) {
                    $table->dropUnique('tracker_agents_name_unique');

                    $table->string('name_hash', 65)->nullable();
                }
            );

            Agent::all()->each(function ($agent) {
                $agent->name_hash = hash('sha256', $agent->name);

                $agent->save();
            });

            $this->builder->table(
                $this->table,
                function ($table) {
                    $table->unique('name_hash');
                }
            );
        } catch (\Exception $e) {
            dd($e->getMessage());
        }
    }
993854
public function up()
    {
        // Check if the 2 tables exist
        if (Schema::hasTable('tags') && Schema::hasTable('taggables')) {
            if (Schema::hasColumn('tags', 'tagable_id') && Schema::hasColumn('tags', 'tagable_type')) {
                $tags = DB::select('select * from tags');
                foreach ($tags as $tag) {
                    // Points to new namespace Redooor\\Redminportal\\App\\Models\\
                    $new_type_array = explode('\\', $tag->tagable_type);
                    $last_model = array_pop($new_type_array);
                    $new_type = 'Redooor\\Redminportal\\App\\Models\\' . $last_model;
                    DB::table('taggables')->insert([
                        'tag_id' => $tag->id,
                        'taggable_id' => $tag->tagable_id,
                        'taggable_type' => $new_type
                    ]);
                }
                Schema::table('tags', function ($table) {
                    $table->dropColumn(['tagable_id', 'tagable_type']);
                });
            }
        }
    }