generated from fintechbd/package-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db4e1a8
commit bdc68b0
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
} | ||
}; |
65 changes: 65 additions & 0 deletions
65
database/migrations/2023_09_25_201631_create_user_profiles_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}; |