osb/database/migrations/2023_05_10_172738_rename_account_provider.php
2023-05-10 16:39:31 +09:00

39 lines
1.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('account_provider', function (Blueprint $table) {
$table->dropForeign(['account_id', 'site_id']);
$table->dropForeign(['provider_oauth_id', 'site_id']);
$table->dropIndex('account_provider_account_id_site_id_foreign');
$table->dropIndex('account_provider_provider_oauth_id_site_id_foreign');
});
DB::statement('ALTER TABLE account_provider RENAME TO account__provider');
Schema::table('account__provider', function (Blueprint $table) {
$table->foreign(['account_id', 'site_id'])->references(['id', 'site_id'])->on('accounts');
$table->foreign(['provider_oauth_id', 'site_id'])->references(['id', 'site_id'])->on('provider_oauth');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'cant go back');
}
};