Skip to content

Commit 798d8d0

Browse files
committed
Move package migration to workbench migration as .php.stub failed test and it required when publish migrations
1 parent d877c91 commit 798d8d0

10 files changed

+107
-5
lines changed

src/WorkflowStorageServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public function configurePackage(Package $package): void
1919
->name('laravel-workflow-storage')
2020
->hasConfigFile()
2121
->hasMigrations([
22-
'01_create_workflows_table',
23-
'02_create_workflow_states_table',
24-
'03_create_workflow_transitions_table',
25-
'04_create_workflow_state_transitions_table',
22+
'create_workflows_table',
23+
'create_workflow_states_table',
24+
'create_workflow_transitions_table',
25+
'create_workflow_state_transitions_table',
2626
])
2727
->hasCommand(WorkflowStorageListCommand::class);
2828
}

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function setUp(): void
3131

3232
});
3333

34-
$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); // load the package migrations
34+
//$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); // load the package migrations
3535
}
3636

3737
protected function getPackageProviders($app)
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()
10+
{
11+
Schema::create('workflows', function (Blueprint $table) {
12+
$table->id();
13+
$table->string('name');
14+
$table->string('marking_store_attribute')->nullable()->comment('name of marking store attribute');
15+
$table->string('type')->default('workflow')->comment('workflow or state_machine');
16+
$table->text('description')->nullable();
17+
$table->json('supports')->nullable()->comment('support models');
18+
$table->json('metadata')->nullable()->comment('metadata');
19+
$table->timestamps();
20+
});
21+
}
22+
23+
public function down()
24+
{
25+
Schema::dropIfExists('workflows');
26+
}
27+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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()
10+
{
11+
Schema::create('workflow_states', function (Blueprint $table) {
12+
$table->id();
13+
$table->string('name');
14+
$table->tinyInteger('initial_state')->default(0)->comment('initial state');
15+
$table->tinyInteger('final_state')->default(0)->comment('final state');
16+
$table->foreignId('workflow_id')->constrained('workflows')->onDelete('cascade');
17+
$table->json('metadata')->nullable()->comment('metadata');
18+
$table->timestamps();
19+
});
20+
}
21+
22+
public function down()
23+
{
24+
Schema::dropIfExists('workflow_states');
25+
}
26+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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()
10+
{
11+
Schema::create('workflow_transitions', function (Blueprint $table) {
12+
$table->id();
13+
$table->string('name');
14+
$table->foreignId('to_state_id')->constrained('workflow_states')->onDelete('cascade');
15+
$table->foreignId('workflow_id')->constrained('workflows')->onDelete('cascade');
16+
$table->json('metadata')->nullable()->comment('meta data');
17+
$table->timestamps();
18+
});
19+
}
20+
21+
public function down()
22+
{
23+
Schema::dropIfExists('workflow_transitions');
24+
}
25+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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()
10+
{
11+
Schema::create('workflow_state_transitions', function (Blueprint $table) {
12+
$table->id();
13+
$table->foreignId('transition_id')->constrained('workflow_transitions')->onDelete('cascade');
14+
$table->foreignId('from_state_id')->constrained('workflow_states')->onDelete('cascade');
15+
$table->unique(['transition_id', 'from_state_id'], 'wf_transition_from_state_unique');
16+
$table->timestamps();
17+
});
18+
}
19+
20+
public function down()
21+
{
22+
Schema::dropIfExists('workflow_state_transitions');
23+
}
24+
};

0 commit comments

Comments
 (0)