<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddForignKeys extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('id_number2', 100)->virtualAs('meta->"$.id_number"')->after('meta')->index();
        });
        // Schema::table('user_modules', function (Blueprint $table) {
        //     $table->dropForeign('user_modules_module_id_foreign');
        //     $table->dropForeign('user_modules_user_id_foreign');
        // });
        // Schema::table('page_descriptions', function (Blueprint $table) {
        //     $table->dropForeign('page_descriptions_language_id_foreign');
        //     $table->dropForeign('page_descriptions_page_id_foreign');
        // });
        // Schema::table('loop_groups', function (Blueprint $table) {
        //     $table->dropForeign('loop_groups_loop_id_foreign');
        // });

        // Schema::table('loop_group_users', function (Blueprint $table) {
        //     $table->dropForeign('loop_group_users_loop_group_id_foreign');
        //     $table->dropForeign('loop_group_users_user_id_foreign');
        // });

        // Schema::table('loop_group_user_paids', function (Blueprint $table) {
        //     $table->dropForeign('loop_group_user_paids_loop_group_user_id_foreign');
        // });

        // Schema::table('verifications', function (Blueprint $table) {
        //     $table->dropForeign('verifications_user_id_foreign');
        // });

        // Schema::table('user_modules', function (Blueprint $table) {
        //     $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        //     $table->foreign('module_id')->references('id')->on('modules')->onDelete('cascade');
        // });

        // Schema::table('page_descriptions', function (Blueprint $table) {
        //     $table->foreign('page_id')->references('id')->on('pages')->onDelete('cascade')->onUpdate('cascade');
        //     $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade')->onUpdate('cascade');
        // });

        // Schema::table('loop_groups', function (Blueprint $table) {
        //     $table->foreign('loop_id')->references('id')->on('loops')->onDelete('cascade')->onUpdate('cascade');
        // });

        // Schema::table('loop_group_users', function (Blueprint $table) {
        //     $table->foreign('loop_group_id')->references('id')->on('loop_groups')->onDelete('cascade')->onUpdate('cascade');
        //     $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
        // });

        // Schema::table('loop_group_user_paids', function (Blueprint $table) {
        //     $table->foreign('loop_group_user_id')->references('id')->on('loop_group_users')->onDelete('cascade')->onUpdate('cascade');
        // });

        // Schema::table('verifications', function (Blueprint $table) {
        //     $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        // });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
