Skip to content

Commit 4ea9802

Browse files
author
miladimos
committed
combine migration files in one file
1 parent 0c4bf07 commit 4ea9802

File tree

7 files changed

+65
-147
lines changed

7 files changed

+65
-147
lines changed

database/migrations/create_files_table.stub.php renamed to database/migrations/2021_07_25_232905_create_filemanager_tables.php

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateFilesTable extends Migration
7+
class CreateFilemanagerTables extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -13,10 +13,25 @@ class CreateFilesTable extends Migration
1313
*/
1414
public function up()
1515
{
16+
Schema::create('directories', function (Blueprint $table) {
17+
$table->id();
18+
$table->uuid('uuid')->uniuqe();
19+
$table->foreignID('parent_id')->nullable();
20+
// $table->foreignID('group_id')->nullable();
21+
$table->foreignID('user_id')->nullable();
22+
$table->string('title')->unique();
23+
$table->string('color_hex')->nullable();
24+
$table->string('path')->nullable();
25+
$table->string('description')->nullable();
26+
$table->char('status')->default('a');
27+
$table->timestamps();
28+
});
29+
1630
Schema::create('files', function (Blueprint $table) {
1731
$table->id();
1832
$table->uuid('uuid')->uniuqe();
19-
$table->morphs('fileable')->nullable();
33+
$table->string("fileable_type")->nullable();
34+
$table->unsignedBigInteger("fileable_id")->nullable();
2035
$table->foreignId('group_id')->nullable();
2136
$table->unsignedBigInteger('directory_id');
2237
$table->unsignedBigInteger('user_id')->nullable();
@@ -36,6 +51,24 @@ public function up()
3651
$table->unsignedInteger('priority_column')->nullable();
3752
$table->timestamps();
3853
});
54+
55+
56+
Schema::create('file_groups', function (Blueprint $table) {
57+
$table->id();
58+
$table->uuid('uuid')->uniuqe();
59+
$table->string('title')->unique();
60+
$table->string('description')->unique()->nullable();
61+
$table->boolean('active')->default(true);
62+
$table->timestamps();
63+
});
64+
65+
66+
Schema::create('file_group_pivot', function (Blueprint $table) {
67+
$table->id();
68+
$table->morphs('groupable');
69+
$table->foreignId('group_id');
70+
});
71+
3972
}
4073

4174
/**
@@ -45,6 +78,13 @@ public function up()
4578
*/
4679
public function down()
4780
{
81+
Schema::dropIfExists('directories');
82+
4883
Schema::dropIfExists('files');
84+
85+
Schema::dropIfExists('file_groups');
86+
87+
Schema::dropIfExists('file_group_pivot');
88+
4989
}
5090
}

database/migrations/create_directories_table.stub.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

database/migrations/create_file_group_pivot_table.stub.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

database/migrations/create_file_groups_table.stub.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Console/Commands/InstallPackageCommand.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public function handle()
3131
$this->publishConfig();
3232
}
3333

34+
// $this->publishMigration();
35+
// $this->info("migrations published.");
36+
//
37+
38+
3439
$this->info("FileManager Package Successfully Installed. Star me on Github :) \n");
3540
$this->info("\t\tGood Luck.");
3641
}
@@ -44,6 +49,15 @@ private function publishConfig()
4449
]);
4550
}
4651

52+
private function publishMigration()
53+
{
54+
$this->call('vendor:publish', [
55+
'--provider' => "Miladimos\FileManager\Providers\FileManagerServiceProvider",
56+
'--tag' => 'migrations',
57+
'--force' => true
58+
]);
59+
}
60+
4761
// //assets
4862
// if (File::exists(public_path('filemanager'))) {
4963
// $confirm = $this->confirm("filemanager directory already exist. Do you want to overwrite?");
@@ -74,15 +88,6 @@ private function publishConfig()
7488
// $this->call('migrate');
7589
// }
7690

77-
// private function publishMigration()
78-
// {
79-
// $this->call('vendor:publish', [
80-
// '--provider' => "Miladimos\FileManager\Providers\FileManagerServiceProvider",
81-
// '--tag' => 'migrations',
82-
// '--force' => true
83-
// ]);
84-
// }
85-
8691
// private function publishAssets()
8792
// {
8893
// $this->call('vendor:publish', [

src/Http/Controllers/DirectoryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Miladimos\FileManager\Models\Directory;
88
use Miladimos\FileManager\Services\DirectoryService;
99

10-
class directoryController extends Controller
10+
class DirectoryController extends Controller
1111
{
1212

1313
private $directoryService;

src/Providers/FileManagerServiceProvider.php

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public function register()
1515
{
1616
$this->mergeConfigFrom(__DIR__ . "/../../config/filemanager.php", 'filemanager');
1717

18+
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
19+
1820
$this->registerFacades();
1921

2022
}
@@ -24,7 +26,7 @@ public function boot()
2426

2527
if ($this->app->runningInConsole()) {
2628
$this->registerConfig();
27-
// $this->registerPublishesMigrations();
29+
// $this->registerPublishesMigrations();
2830
$this->registerCommands();
2931
$this->registerTranslations();
3032
$this->registerRoutes();
@@ -64,32 +66,11 @@ private function registerCommands()
6466

6567
private function registerPublishesMigrations()
6668
{
67-
68-
if (!class_exists('CreateDirectoriesTable')) {
69-
$this->publishes([
70-
__DIR__ . '/../database/migrations/create_directories_table.stub.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_directories_table.php'),
71-
// you can add any number of migrations here
72-
], 'migrations');
73-
}
74-
75-
if (!class_exists('CreateFilesTable')) {
76-
$this->publishes([
77-
__DIR__ . '/../database/migrations/create_files_table.stub.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_files_table.php'),
78-
// you can add any number of migrations here
79-
], 'migrations');
80-
}
81-
82-
// if (!class_exists('CreateFileGroupsTable')) {
83-
// $this->publishes([
84-
// __DIR__ . '/../database/migrations/create_file_groups_table.stub.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_file_groups_table.php'),
85-
// // you can add any number of migrations here
86-
// ], 'migrations');
87-
// }
88-
// if (!class_exists('CreateFileGroupPivotTable')) {
89-
// $this->publishes([
90-
// __DIR__ . '/../database/migrations/create_file_group_pivot_table.stub.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_file_group_pivot_table.php'),
91-
// // you can add any number of migrations here
92-
// ], 'migrations');
69+
// if (!class_exists('CreateFilemanagerTables')) {
70+
$this->publishes([
71+
__DIR__ . '/../../database/migrations/2021_07_25_232905_create_filemanager_tables.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_filemanger_tables.php'),
72+
// you can add any number of migrations here
73+
], 'migrations');
9374
// }
9475
}
9576

0 commit comments

Comments
 (0)