diff --git a/app/Models/Account.php b/app/Models/Account.php index ff977d4..903c1ed 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -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'); } diff --git a/database/migrations/2023_05_10_172738_rename_account_provider.php b/database/migrations/2023_05_10_172738_rename_account_provider.php new file mode 100644 index 0000000..83e7a58 --- /dev/null +++ b/database/migrations/2023_05_10_172738_rename_account_provider.php @@ -0,0 +1,38 @@ +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'); + } +};