Rename account_provider

This commit is contained in:
Deon George 2023-05-10 16:37:43 +09:00
parent 17ebbb71e8
commit 11b554daad
2 changed files with 40 additions and 2 deletions

View File

@ -89,8 +89,8 @@ class Account extends Model implements IDs
public function providers()
{
return $this->belongsToMany(ProviderOauth::class,'account_provider')
->where('account_provider.site_id',$this->site_id)
return $this->belongsToMany(ProviderOauth::class,'account__provider')
->where('account__provider.site_id',$this->site_id)
->withPivot('ref','synctoken','created_at','updated_at');
}

View File

@ -0,0 +1,38 @@
<?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');
}
};