Настругал миграций

This commit is contained in:
Dhaverd 2024-11-21 01:23:42 +08:00
parent 321419c0f0
commit 31ab6932fe
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?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::table('wishes', function (Blueprint $table) {
$table->unsignedBigInteger('book_user_id')->nullable();
$table->foreign('book_user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('wishes', function (Blueprint $table) {
$table->dropColumn('book_user_id');
});
}
};

View File

@ -0,0 +1,28 @@
<?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::table('users', function (Blueprint $table) {
$table->string('name')->unique(true)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('name')->unique(false)->change();
});
}
};