Skip to content

Commit

Permalink
Merge pull request #31 from ulobby/new-migration-stubs
Browse files Browse the repository at this point in the history
🐛 Fix for #27  (new migration stubs)
  • Loading branch information
berteltorp authored and SimonThordal committed Mar 18, 2021
1 parent 74a566a commit fa857e6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
13 changes: 10 additions & 3 deletions src/Migrations/MigrationCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Vinelab\NeoEloquent\Migrations;

use Illuminate\Database\Migrations\MigrationCreator as IlluminateMigrationCreator;
use Illuminate\Support\Str;

class MigrationCreator extends IlluminateMigrationCreator
{
Expand All @@ -18,13 +17,21 @@ class MigrationCreator extends IlluminateMigrationCreator
*/
protected function populateStub($name, $stub, $label)
{
$stub = str_replace('DummyClass', Str::studly($name), $stub);
$stub = str_replace(
['DummyClass', '{{ class }}', '{{class}}'],
$this->getClassName($name),
$stub
);

// Here we will replace the label place-holders with the label specified by
// the developer, which is useful for quickly creating a labels creation
// or update migration from the console instead of typing it manually.
if (!is_null($label)) {
$stub = str_replace('DummyLabel', $label, $stub);
$stub = str_replace(
['DummyTable', '{{ table }}', '{{table}}'],
$table,
$stub
);
}

return $stub;
Expand Down
9 changes: 4 additions & 5 deletions src/Migrations/stubs/create.stub → src/Migrations/stubs/migration.create.stub
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
use Vinelab\NeoEloquent\Schema\Blueprint;
use Vinelab\NeoEloquent\Migrations\Migration;

class DummyClass extends Migration {

class {{ class }} extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Neo4jSchema::label('DummyLabel', function(Blueprint $label)
Neo4jSchema::label('{{ table }}', function(Blueprint $label)
{
//
});
Expand All @@ -25,7 +25,6 @@ class DummyClass extends Migration {
*/
public function down()
{
Neo4jSchema::dropIfExists('DummyLabel');
Neo4jSchema::dropIfExists('{{ table }}');
}

}
5 changes: 2 additions & 3 deletions src/Migrations/stubs/blank.stub → src/Migrations/stubs/migration.stub
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use Vinelab\NeoEloquent\Schema\Blueprint;
use Vinelab\NeoEloquent\Migrations\Migration;

class DummyClass extends Migration {

class {{ class }} extends Migration
{
/**
* Run the migrations.
*
Expand All @@ -24,5 +24,4 @@ class DummyClass extends Migration {
{
//
}

}
11 changes: 4 additions & 7 deletions src/Migrations/stubs/update.stub → src/Migrations/stubs/migration.update.stub
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
use Vinelab\NeoEloquent\Schema\Blueprint;
use Vinelab\NeoEloquent\Migrations\Migration;

class DummyClass extends Migration {

class {{ class }} extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Neo4jSchema::label('DummyLabel', function(Blueprint $label)
{
Neo4jSchema::label('{{ table }}', function(Blueprint $label) {
//
});
}
Expand All @@ -25,10 +24,8 @@ class DummyClass extends Migration {
*/
public function down()
{
Neo4jSchema::label('DummyLabel', function(Blueprint $label)
{
Neo4jSchema::label('{{ table }}', function(Blueprint $label) {
//
});
}

}

0 comments on commit fa857e6

Please sign in to comment.