-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a local channels clear which will delete no longer valid channels…
… to the command `slack:channels:update` if there is an issue with the daemon. Ensure slack_user id is unique and drop duplicate values
- Loading branch information
elfaus
committed
Sep 1, 2016
1 parent
23461b5
commit a2949c8
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/database/migrations/2016_09_01_221300_alter_slackbot_users_unique.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\Schema; | ||
use Seat\Slackbot\Models\SlackUser; | ||
|
||
class AlterSlackbotUsersUnique extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
$last_user = ''; | ||
$users = SlackUser::all(); | ||
|
||
foreach ($users as $user) { | ||
if ($user->slack_id == $last_user) { | ||
$user->delete(); | ||
|
||
} | ||
$last_user = $user->slack_id; | ||
} | ||
|
||
Schema::table('slack_users', function (Blueprint $table) { | ||
$table->unique('slack_id'); | ||
}); | ||
} | ||
} |