Skip to content

Commit

Permalink
user table rollback added
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Sep 27, 2023
1 parent db4e1a8 commit bdc68b0
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if (!Schema::hasTable('users')) {
throw new \ErrorException('`users` table is missing.');
}

Schema::table('users', function (Blueprint $table) {
$table->foreignId('parent_id')->nullable()->default(null)->after('id');
$table->string('mobile')->nullable()->after('name');
$table->string('login_id')->unique()->after('email');
$table->unsignedSmallInteger('wrong_password')->default(0)->after('password');
$table->string('pin')->after('wrong_password');
$table->unsignedSmallInteger('wrong_pin')->default(0)->after('pin');
$table->string('status')->nullable()->after('wrong_pin');
$table->string('language')->nullable()->after('status');
$table->string('currency')->nullable()->after('language');
$table->string('app_version')->default('1');
$table->string('fcm_token')->nullable()->after('remember_token');
$table->timestamp('mobile_verified_at')->nullable()->after('email_verified_at');
$table->foreignId('creator_id')->nullable()->after('mobile_verified_at');
$table->foreignId('editor_id')->nullable()->after('creator_id');
$table->foreignId('destroyer_id')->nullable()->after('editor_id');
$table->foreignId('restorer_id')->nullable()->after('destroyer_id');
$table->softDeletes()->after('updated_at');
$table->timestamp('restored_at')->nullable()->after('deleted_at');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('parent_id');
$table->dropColumn('mobile');
$table->dropColumn('login_id');
$table->dropColumn('wrong_password');
$table->dropColumn('pin');
$table->dropColumn('wrong_pin');
$table->dropColumn('status');
$table->dropColumn('language');
$table->dropColumn('currency');
$table->dropColumn('app_version');
$table->dropColumn('fcm_token');
$table->dropColumn('mobile_verified_at');
$table->dropColumn('creator_id');
$table->dropColumn('editor_id');
$table->dropColumn('destroyer_id');
$table->dropColumn('restorer_id');
$table->dropColumn('deleted_at');
$table->dropColumn('restored_at');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

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

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('profiles', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->unsigned();
$table->string('id_type')->nullable();
$table->string('id_no')->nullable();
$table->string('id_issue_country')->nullable();
$table->date('id_expired_at')->nullable();
$table->date('id_issue_at')->nullable();
$table->string('id_no_duplicate')->default('no');
$table->date('date_of_birth')->nullable();
$table->string('permanent_address')->nullable();
$table->foreignId('city_id')->nullable()->unsigned();
$table->foreignId('state_id')->nullable()->unsigned();
$table->foreignId('country_id')->nullable()->unsigned();
$table->string('post_code')->nullable();
$table->string('present_address')->nullable();
$table->foreignId('present_city_id')->nullable()->unsigned();
$table->foreignId('present_state_id')->nullable()->unsigned();
$table->foreignId('present_country_id')->nullable()->unsigned();
$table->string('present_post_code')->nullable();
$table->foreignId('approver_id')->nullable()->unsigned();
$table->string('blacklisted')->default('no');
$table->json('user_profile_data')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('state_id')->references('id')->on('states')->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('present_country_id')->references('id')->on('countries')->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('present_state_id')->references('id')->on('states')->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('present_city_id')->references('id')->on('cities')->onDelete('cascade')
->onUpdate('cascade');
$table->unsignedBigInteger('creator_id')->index()->nullable();
$table->unsignedBigInteger('editor_id')->index()->nullable();
$table->unsignedBigInteger('destroyer_id')->index()->nullable();
$table->timestamps();
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('profiles');
}
};

0 comments on commit bdc68b0

Please sign in to comment.