Skip to content

Commit

Permalink
Fix an incorrect foreign key constraint with connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Apr 24, 2023
1 parent 283bfb5 commit 66185b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SocialLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SocialLogin extends Plugin
// Properties
// =========================================================================

public string $schemaVersion = '1.0.0';
public string $schemaVersion = '1.0.1';
public bool $hasCpSettings = true;


Expand Down
1 change: 0 additions & 1 deletion src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function createTables(): void

public function addForeignKeys(): void
{
$this->addForeignKey(null, '{{%social_login_connections}}', 'id', '{{%elements}}', 'id', 'CASCADE', null);
$this->addForeignKey(null, '{{%social_login_connections}}', 'userId', '{{%users}}', 'id', 'CASCADE', null);
}

Expand Down
25 changes: 25 additions & 0 deletions src/migrations/m230425_000000_fix_fk_connections.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
namespace verbb\sociallogin\migrations;

use Craft;
use craft\db\Migration;
use craft\helpers\MigrationHelper;

class m230425_000000_fix_fk_connections extends Migration
{
// Public Methods
// =========================================================================

public function safeUp(): bool
{
MigrationHelper::dropForeignKeyIfExists('{{%social_login_connections}}', 'id');

return true;
}

public function safeDown(): bool
{
echo "m230425_000000_fix_fk_connections cannot be reverted.\n";
return false;
}
}

0 comments on commit 66185b4

Please sign in to comment.