Skip to content

Commit fb2714f

Browse files
committed
Publish migration via Spatie package
1 parent a34311e commit fb2714f

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create(config('translation-manager.table'), static function (Blueprint $table): void {
12+
$table->id();
13+
$table->string('file');
14+
$table->string('name');
15+
$table->string('group_key');
16+
$table->string('locale', 16);
17+
$table->text('translation');
18+
$table->integer('order')->nullable();
19+
$table->timestamps();
20+
});
21+
}
22+
23+
public function down(): void
24+
{
25+
Schema::dropIfExists(config('translation-manager.table'));
26+
}
27+
};

src/TranslationManagerServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ public function configurePackage(Package $package): void
1818
->hasConfigFile()
1919
->hasViews()
2020
->hasTranslations()
21+
->hasMigration('create_translations_table')
2122
->hasRoute('web')
2223
->hasCommands([
2324
PushToStorage::class,
2425
PushToDatabase::class,
2526
PullFromDatabase::class,
2627
PullFromStorage::class,
2728
]);
28-
29-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
3029
}
3130
}

tests/TestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ protected function getPackageProviders($app): array
1212
TranslationManagerServiceProvider::class,
1313
];
1414
}
15+
16+
protected function defineDatabaseMigrations()
17+
{
18+
$this->loadLaravelMigrations();
19+
20+
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
21+
}
1522
}

0 commit comments

Comments
 (0)