-
-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
230 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,6 @@ export default [ | |
allowGuest: false, | ||
}), | ||
'start', | ||
98 | ||
95 | ||
), | ||
]; |
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
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
50 changes: 50 additions & 0 deletions
50
extensions/messages/migrations/2025_01_31_000000_add_number_to_dialog_messages.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,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Schema\Builder; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->table('dialog_messages', function (Blueprint $table) { | ||
$table->unsignedBigInteger('number')->nullable()->after('content'); | ||
}); | ||
|
||
$numbers = []; | ||
|
||
$schema->getConnection() | ||
->table('dialogs') | ||
->orderBy('id') | ||
->each(function (object $dialog) use ($schema, &$numbers) { | ||
$numbers[$dialog->id] = 0; | ||
|
||
$schema->getConnection() | ||
->table('dialog_messages') | ||
->where('dialog_id', $dialog->id) | ||
->orderBy('id') | ||
->each(function (object $message) use ($schema, &$numbers) { | ||
$schema->getConnection() | ||
->table('dialog_messages') | ||
->where('id', $message->id) | ||
->update(['number' => ++$numbers[$message->dialog_id]]); | ||
}); | ||
|
||
unset($numbers[$dialog->id]); | ||
}); | ||
|
||
$schema->table('dialog_messages', function (Blueprint $table) { | ||
$table->unsignedBigInteger('number')->nullable(false)->change(); | ||
}); | ||
}, | ||
'down' => function (Builder $schema) { | ||
$schema->table('dialog_messages', function (Blueprint $table) { | ||
$table->dropColumn('number'); | ||
}); | ||
} | ||
]; |
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
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
Oops, something went wrong.