Migrate Laravel's default migrations.

@param  array|string  $database

@return void
175929
protected function loadLaravelMigrations($database = []): void
    {
        $options = \is_array($database) ? $database : ['--database' => $database];

        $options['--path'] = 'migrations';

        $migrator = new MigrateProcessor($this, $options);

        $migrator->up();

        $this->app[ConsoleKernel::class]->setArtisan(null);

        $this->beforeApplicationDestroyed(function () use ($migrator) {
            $migrator->rollback();
        });
    }
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, '');"
        ));
    }
191146
public function up()
    {
        $this->create('migrations', function ($table) {
            // Place table rows here
            $table->increments('id');
            $table->string('migration');
            $table->integer('migrated');
            $table->timestamps();
        });
    }
581688
public function runInstall(Model $entity, ?string $database): void
    {
        $database = $this->asConnection($entity, $database);
        $table = $this->resolveMigrationTableName($entity);
        $migrator = $this->resolveMigrator($table);
        $repository = $migrator->getRepository();

        $migrator->setConnection($database);

        if (! $repository->repositoryExists()) {
            $repository->createRepository();

            $this->note("<info>Migration table {$table} created successfully.</info>");
        }

        $migrator->resetConnection();
    }
961707
public function startDatabase($database)
    {
        assert($this->_platform instanceof SQLAnywherePlatform);
        $this->_execSql($this->_platform->getStartDatabaseSQL($database));
    }
491479
public function setDatabase($database)
    {
        $this->_options[ConnectionOptions::OPTION_DATABASE] = $database;
        $this->_database                                    = $database;

        $this->updateHttpHeader();
    }
238038
public function up()
    {
        \Schema::create('config', function (Blueprint $table) {
            $table->engine = 'InnoDB';

            $table->increments('id');
            $table->string('namespace')
                  ->default('');
            $table->string('key');
            $table->string('value');
            $table->enum('type', ['int', 'bool', 'string']);
            $table->unsignedInteger('modified_by_user_id');
            $table->timestamp('modified_at');

            $table->unique(['namespace', 'key']);
        });
    }
1167564
public function up() {
		$db = Database::get();
		$table = File::trait_get_database_table();
		$tables = $db->get_column("SHOW TABLES LIKE '" . $table . "'", []);
		if (count($tables) == 0) {
			$db->query("
				CREATE TABLE IF NOT EXISTS `" . $table . "` (
				   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
				   `name` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
				   `unique_name` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
				   `md5sum` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
				   `mime_type` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
				   `size` int(11) NOT NULL,
				   `created` datetime NOT NULL,
				   `deleted` datetime NOT NULL,
					PRIMARY KEY (`id`)
				) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
			", []);
		}


	}
478543
public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%gr_lang}}', [
            'id' => Schema::TYPE_PK,
            'url' => Schema::TYPE_STRING . '(255) NOT NULL',
            'local' => Schema::TYPE_STRING . '(255) NOT NULL',
            'name' => Schema::TYPE_STRING . '(255) NOT NULL',
            'default' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 0',
            'date_update' => Schema::TYPE_INTEGER . ' NOT NULL',
            'date_create' => Schema::TYPE_INTEGER . ' NOT NULL',
        ], $tableOptions);

        $this->batchInsert('gr_lang', ['url', 'local', 'name', 'default', 'date_update', 'date_create'], [
            ['en', 'en-EN', 'English', 0, time(), time()],
            ['ru', 'ru-RU', 'Русский', 1, time(), time()],
        ]);
    }
1332825
public function up()
    {
        $connection = config('admin.database.connection') ?: config('database.default');

        $table = config('admin.extensions.config.table', 'admin_config');

        Schema::connection($connection)->create($table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('value');
            $table->text('description')->nullable();
            $table->timestamps();
        });
    }
1066193
public function up()
    {
        $connection = config('admin.database.connection') ?: config('database.default');

        $table = config('admin.extensions.reporter.table', 'laravel_exceptions');

        Schema::connection($connection)->create($table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('type');
            $table->string('code');
            $table->string('message');
            $table->string('file');
            $table->integer('line');
            $table->text('trace');
            $table->string('method');
            $table->string('path');
            $table->text('query');
            $table->text('body');
            $table->text('cookies');
            $table->text('headers');
            $table->string('ip');
            $table->timestamps();
        });
    }
561387
public function up()
    {
        if (Schema::hasTable('service_type')) {
            $output = new \Symfony\Component\Console\Output\ConsoleOutput();
            $output->writeln('Scanning database for old sql_db service type...');
            $ids = DB::table('service')->where('type', 'sql_db')->pluck('id');
            if (!empty($ids)) {
                $configs = DB::table('sql_db_config')->whereIn('service_id', $ids)->get();
                $output->writeln('|--------------------------------------------------------------------');
                foreach ($configs as $entry) {
                    /** @type array $entry */
                    $entry = (array)$entry;
                    $newType = '';
                    $config = static::adaptConfig($entry, $newType);
                    $config = json_encode($config);
                    $id = array_get($entry, 'service_id');
                    $output->writeln('| Service ID: ' . $id . ' New Config: ' . $config);
                    DB::table('service')->where('id', $id)->update(['type' => $newType]);
                    DB::table('sql_db_config')->where('service_id', $id)->update(['connection' => $config]);
                }
                $output->writeln('|--------------------------------------------------------------------');
            }

            $output->writeln('Scanning database for old script service type...');
            $ids = DB::table('service')->where('type', 'script')->pluck('id');
            if (!empty($ids)) {
                $configs = DB::table('script_config')->whereIn('service_id', $ids)->pluck('type', 'service_id');
                $output->writeln('|--------------------------------------------------------------------');
                foreach ($configs as $id => $driver) {
                    $newType = $driver;
                    $output->writeln('| ID: ' . $id . ' New Type: ' . $newType);
                    DB::table('service')->where('id', $id)->update(['type' => $newType]);
                }
                $output->writeln('|--------------------------------------------------------------------');
            }
        }
    }
552592
public function up()
    {
        Schema::create(\Config::get('registry.table', 'system_registries'), function(Blueprint $table)
        {
            $table->string('key');
            $table->text('value');

            $table->primary('key');
        });
    }
368929
public function up()
	{
		Schema::create('user', function(Blueprint $table)
		{
			$table->increments('id_user');
			$table->string('name');
			$table->string('username')->unique();
			$table->string('password', 60);
			$table->rememberToken();
			$table->timestamps();
		});
		
		DB::table('user')->insert(
			['name' => 'Administrator', 'username' => 'admin', 'password' => bcrypt('admin'), 
				'created_at' => date('Y-m-d'), 'updated_at' => date('Y-m-d')]
		);
	}
573983
public function initDatabase()
    {
        $this->call('migrate');

        if (Administrator::count() == 0) {
            $this->call('db:seed', ['--class' => \Lia\Auth\Database\AdminTablesSeeder::class]);
        }
    }
827429
public function up()
    {
        Schema::create('languages', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('code')->nullable()->default(null);
            $table->tinyInteger('is_default')->default(0);
            $table->timestamps();
        });

        Schema::create('categories', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('parent_id')->nullable()->default(null);
            $table->string('name');
            $table->string('slug');
            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);

            $table->timestamps();
        });

        Schema::create('category_filters', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id')->unsigned()->nullable()->default(null);
            $table->enum('type', ['ATTRIBUTE', 'PROPERTY'])->nullable()->default(null);
            $table->integer('filter_id');
            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
        });

        Schema::create('products', function(Blueprint $table) {
            $table->increments('id');
            $table->enum('type', ['BASIC', 'VARIATION', 'DOWNLOADABLE', 'VARIABLE_PRODUCT'])->default('BASIC');

            $table->string('name')->nullable()->default(null);
            $table->string('slug')->nullable()->default(null);
            $table->string('sku')->nullable()->default(null);
            $table->text('description')->nullable()->default(null);
            $table->tinyInteger('status')->nullable()->default(null);
            $table->tinyInteger('in_stock')->nullable()->default(null);
            $table->tinyInteger('track_stock')->nullable()->default(null);
            $table->decimal('qty', 10, 6)->nullable();
            $table->tinyInteger('is_taxable')->nullable()->default(null);
            $table->decimal('price', 10, 6)->nullable()->default(null);
            $table->decimal('cost_price', 10, 6)->nullable()->default(null);

            $table->float('weight')->nullable()->default(null);
            $table->float('width')->nullable()->default(null);
            $table->float('height')->nullable()->default(null);
            $table->float('length')->nullable()->default(null);

            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);
            $table->timestamps();
        });

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

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

        Schema::create('product_downloadable_urls', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned();
            $table->string('demo_path')->nullable()->default(null);
            $table->string('main_path')->nullable()->default(null);
            $table->string('token');
            $table->timestamps();

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

        Schema::create('product_images', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned();
            $table->text('path');
            $table->boolean('is_main_image')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('order_statuses', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->tinyInteger('is_default')->default(0);
            $table->timestamps();
        });

        OrderStatus::insert([
            ['name' => 'New', 'is_default' => 1],
            ['name' => 'Pending Payment', 'is_default' => 0],
            ['name' => 'Processing', 'is_default' => 0],
            ['name' => 'Shipped', 'is_default' => 0],
            ['name' => 'Delivered', 'is_default' => 0],
            ['name' => 'Canceled', 'is_default' => 0],
        ]);

        Schema::create('orders', function(Blueprint $table) {
            $table->increments('id');

            $table->string('shipping_option');
            $table->string('payment_option');
            $table->integer('order_status_id')->unsigned();
            $table->string('currency_code')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('order_status_id')->references('id')->on('order_statuses');
        });

        Schema::create('order_histories', function(Blueprint $table) {
            $table->increments('id');

            $table->integer('order_id')->unsigned()->nullable()->default(null);
            $table->integer('order_status_id')->unsigned()->nullable()->default(null);

            $table->timestamps();

            $table->foreign('order_status_id')->references('id')->on('order_statuses');
            $table->foreign('order_id')->references('id')->on('orders');
        });

        Schema::create('order_product', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned();
            $table->integer('order_id')->unsigned();
            $table->integer('qty');
            $table->decimal('price', 11, 6);
            $table->decimal('tax_amount', 11, 6);
            $table->json('product_info')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('order_return_requests', function(Blueprint $table) {
            $table->increments('id');

            $table->integer('order_id')->unsigned()->nullable()->default(null);
            $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');

            $table->enum('status', ['PENDING', 'IN_PROGRESSS', 'APPROVED', 'REJECTED'])->nullable()->default(null);
            $table->text('comment')->nullable()->default(null);

            $table->timestamps();
        });

        Schema::create('order_return_products', function(Blueprint $table) {
            $table->increments('id');

            $table->integer('order_return_request_id')->unsigned()->nullable()->default(null);
            $table->foreign('order_return_request_id')->references('id')->on('order_return_requests')->onDelete('cascade');

            $table->integer('product_id')->unsigned()->nullable()->default(null);
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');

            $table->integer('qty');
            $table->text('reason')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('properties', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('identifier')->unique();
            $table->enum('data_type', ['INTEGER', 'DECIMAL', 'DATETIME', 'VARCHAR', 'BOOLEAN', 'TEXT'])->nullable()->default(null);
            $table->enum('field_type', ['TEXT', 'TEXTAREA', 'CKEDITOR', 'SELECT', 'FILE', 'DATETIME', 'CHECKBOX', 'RADIO', 'SWITCH']);
            $table->tinyInteger('use_for_all_products')->default(0);
            $table->tinyInteger('is_visible_frontend')->nullable()->default(1);
            $table->integer('sort_order')->nullable()->default(0);
            $table->timestamps();
        });

        Schema::create('property_dropdown_options', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->string('display_text');
            $table->timestamps();
            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
        });

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

            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });
        Schema::create('product_property_varchar_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->string('value')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('product_property_datetime_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamp('value')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('product_property_integer_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('value')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('product_property_decimal_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->decimal('value')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('product_property_text_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->text('value')->nullable()->default(null);
            $table->timestamps();

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

        Schema::create('product_property_boolean_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->tinyInteger('value')->nullable()->default(null);
            $table->timestamps();

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

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

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

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

        Schema::create('attribute_dropdown_options', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('attribute_id')->unsigned();
            $table->string('display_text');
            $table->timestamps();
            $table->foreign('attribute_id')
                ->references('id')->on('attributes')->onDelete('cascade');
        });

        Schema::create('product_attribute_integer_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('attribute_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('value')->nullable()->default(null);
            $table->timestamps();

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

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

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

        Schema::create('order_product_variations', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('attribute_id')->unsigned();
            $table->integer('attribute_dropdown_option_id')->unsigned()->nullable()->default(null);
            $table->timestamps();

            $table->foreign('order_id')->references('id')->on('orders');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
            ;
            $table->foreign('attribute_id')->references('id')->on('attributes');
            $table->foreign('attribute_dropdown_option_id')->references('id')->on('attribute_dropdown_options');
        });

        Schema::create('configurations', function(Blueprint $table) {
            $table->increments('id');
            $table->string('configuration_key')->nullable()->default(null);
            $table->string('configuration_value', 999)->nullable()->default(null);
            $table->timestamps();
        });

        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()->default(null);
            $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->timestamp('email_verified_at')->nullable();
            $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')->nullable()->default(null);
            $table->string('last_name')->nullable()->default(null);
            $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', 'DELETE_IN_PROGRESS'])->default('LIVE');
            $table->string('tax_no')->nullable()->default(null);
            $table->timestamp('email_verified_at')->nullable();
            $table->timestamp('delete_due_date')->nullable()->default(null);
            $table->enum('registered_channel', ['WEBSITE', 'FACEBOOK', 'TWITTER', 'GOOGLE'])->default('WEBSITE');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();
                
        });

        Schema::create('user_groups', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->tinyInteger('is_default')->default(0);
            $table->timestamps();
        });

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

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

        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('currency_symbol')->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('symbol');
            $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->string('track_code')->nullable()->default(null);

            $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 $country) {
            Country::create([
                'code' => strtolower(array_get($country, 'alpha2Code')),
                'name' => array_get($country, 'name'),
                'phone_code' => array_get($country, 'callingCodes.0'),
                'currency_code' => array_get($country, 'currencies.0.code'),
                'currency_symbol' => array_get($country, 'currencies.0.symbol'),
                'lang_code' => array_get($country, 'languages.0.name'),
            ]);
        }

        Schema::create('menu_groups', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('identifier')->nullable()->default(null);
            $table->tinyInteger('is_default')->nullable()->default(0);
            $table->timestamps();
        });

        Schema::create('menus', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('menu_group_id')->unsigned();
            $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->integer('sort_order')->default(0);
            $table->timestamps();

            $table->foreign('menu_group_id')->references('id')->on('menu_groups')->onDelete('cascade');
        });

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

        Schema::create('tax_rates', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('description')->nullable()->default(null);
            $table->float('rate', 10, 6);
            $table->integer('country_id')->unsigned();
            $table->integer('state_id')->unsigned()->nullable()->default(null);
            $table->integer('postcode')->nullable()->default(null);
            $table->enum('rate_type', ['PERCENTAGE', 'FIXED'])->default('PERCENTAGE');
            $table->enum('applied_with', ['SHIPPING', 'BILLING', 'STORE'])->default('SHIPPING');
            $table->timestamps();
        });


        Schema::create('category_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('category_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name');
            $table->string('slug');
            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);

            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('attribute_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('attribute_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('identifier')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('attribute_id')->references('id')->on('attributes')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('attribute_dropdown_option_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('attribute_dropdown_option_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('display_text');
            $table->timestamps();

            $table->foreign('attribute_dropdown_option_id', 'adt')
                ->references('id')
                ->on('attribute_dropdown_options')
                ->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('property_translations', function(Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('property_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('identifier')->unique()->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('property_dropdown_option_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('property_dropdown_option_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('display_text');
            $table->timestamps();

            $table->foreign('property_dropdown_option_id', 'pdt')
                ->references('id')
                ->on('property_dropdown_options')
                ->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('page_translations', function(Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('page_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('slug')->unique()->nullable()->default(null);
            $table->text('content')->nullable()->default(null);
            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('page_id')->references('id')->on('pages')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });


        $countryModel = Country::whereCode('nz')->first();
        $countryModel->update(['is_active' => 1]);
        $siteCurrency = SiteCurrency::create([
            'name' => 'NZ Dollars',
            'code' => 'NZD',
            'symbol' => '$',
            '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
        ']);

        $accountMenuGroup = MenuGroup::create([
            'name' => 'My Account',
            'identifier' => 'my-account'
        ]);

        Menu::create([
            'name' => 'Account Overview',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.home',
        ]);
        Menu::create([
            'name' => 'Edit Account',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.edit',
        ]);
        Menu::create([
            'name' => 'Upload Image',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.upload-image',
        ]);
        Menu::create([
            'name' => 'My Orders',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.order.list',
        ]);
        Menu::create([
            'name' => 'My Addresses',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.address.index',
        ]);
        Menu::create([
            'name' => 'My Wishlist',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.wishlist.list',
        ]);
        Menu::create([
            'name' => 'Change Password',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.change-password',
        ]);
        Menu::create([
            'name' => 'Logout',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'logout',
        ]);
        
        $menuGroup = MenuGroup::create([
            'name' => 'Main Menu',
            'identifier' => 'main-menu',
            'is_default' => 1
        ]);

        
        Menu::create([
            'name' => 'My Account',
            'menu_group_id' => $menuGroup->id,
            'route' => 'my-account.home',
            'sort_order' => 400
        ]);
        Menu::create([
            'name' => 'Cart',
            'menu_group_id' => $menuGroup->id,
            'route' => 'cart.view',
            'sort_order' => 500
        ]);
        Menu::create([
            'name' => 'Checkout',
            'menu_group_id' => $menuGroup->id,
            'route' => 'checkout.index',
            'sort_order' => 600
        ]);
    }
950116
public function up()
    {
        Schema::create('elements', function ($table) {
            $table->engine = 'InnoDB';

            $table->string('key');
            $table->string('type');
            $table->mediumtext('value')->nullable();
            $table->string('locale');

            $table->primary(['key', 'locale']);
            $table->index(['locale', 'key']);
        });
    }