Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Oct 19, 2024
1 parent e3f9695 commit 17ec156
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions extensions/messages/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"flarum-extension": {
"title": "Messages",
"category": "feature",
"optional-dependencies": [
"flarum/tags"
],
"icon": {
"name": "fas fa-envelope-open",
"color": "#ffffff",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@

use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return Migration::createTable(
'dialog_message_mentions_tag',
function (Blueprint $table) {
function (Blueprint $table, Builder $schema) {
$table->unsignedInteger('dialog_message_id');
$table->unsignedInteger('mentions_tag_id');
$table->dateTime('created_at')->nullable()->useCurrent();

$table->primary(['dialog_message_id', 'mentions_tag_id']);
$table->foreign('dialog_message_id')->references('id')->on('dialog_messages')->cascadeOnDelete();
$table->foreign('mentions_tag_id')->references('id')->on('tags')->cascadeOnDelete();

if ($schema->hasTable('tags')) {
$table->foreign('mentions_tag_id')->references('id')->on('tags')->cascadeOnDelete();
}
}
);
8 changes: 4 additions & 4 deletions framework/core/src/Database/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static function createTable(string $name, callable $definition): array
{
return [
'up' => function (Builder $schema) use ($name, $definition) {
$schema->create($name, function (Blueprint $table) use ($definition) {
$definition($table);
$schema->create($name, function (Blueprint $table) use ($definition, $schema) {
$definition($table, $schema);
});
},
'down' => function (Builder $schema) use ($name) {
Expand All @@ -40,8 +40,8 @@ public static function createTableIfNotExists(string $name, callable $definition
return [
'up' => function (Builder $schema) use ($name, $definition) {
if (! $schema->hasTable($name)) {
$schema->create($name, function (Blueprint $table) use ($definition) {
$definition($table);
$schema->create($name, function (Blueprint $table) use ($definition, $schema) {
$definition($table, $schema);
});
}
},
Expand Down

0 comments on commit 17ec156

Please sign in to comment.