-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed #196 by merging migrations to a single file
- Loading branch information
Showing
7 changed files
with
113 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/Franzose/ClosureTable/Generators/stubs/migrations/closuretable-innodb.php
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/Franzose/ClosureTable/Generators/stubs/migrations/closuretable.php
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
src/Franzose/ClosureTable/Generators/stubs/migrations/entity-innodb.php
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/Franzose/ClosureTable/Generators/stubs/migrations/entity.php
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
src/Franzose/ClosureTable/Generators/stubs/migrations/migration-innodb.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class {{entity_class}}Migration extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('{{entity_table}}', function (Blueprint $table) { | ||
$table->engine = 'InnoDB'; | ||
|
||
$table->increments('id'); | ||
$table->integer('parent_id')->unsigned()->nullable(); | ||
$table->integer('position', false, true); | ||
$table->integer('real_depth', false, true); | ||
$table->softDeletes(); | ||
|
||
$table->foreign('parent_id') | ||
->references('id') | ||
->on('{{entity_table}}') | ||
->onDelete('set null'); | ||
}); | ||
|
||
Schema::create('{{closure_table}}', function (Blueprint $table) { | ||
$table->engine = 'InnoDB'; | ||
|
||
$table->increments('closure_id'); | ||
$table->integer('ancestor', false, true); | ||
$table->integer('descendant', false, true); | ||
$table->integer('depth', false, true); | ||
|
||
$table->foreign('ancestor') | ||
->references('id') | ||
->on('{{entity_table}}') | ||
->onDelete('cascade'); | ||
|
||
$table->foreign('descendant') | ||
->references('id') | ||
->on('{{entity_table}}') | ||
->onDelete('cascade'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table('{{closure_table}}', function (Blueprint $table) { | ||
Schema::dropIfExists('{{closure_table}}'); | ||
}); | ||
|
||
Schema::table('{{entity_table}}', function (Blueprint $table) { | ||
Schema::dropIfExists('{{entity_table}}'); | ||
}); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/Franzose/ClosureTable/Generators/stubs/migrations/migration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class {{entity_class}}Migration extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('{{entity_table}}', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->integer('parent_id')->unsigned()->nullable(); | ||
$table->integer('position', false, true); | ||
$table->integer('real_depth', false, true); | ||
$table->softDeletes(); | ||
|
||
$table->foreign('parent_id') | ||
->references('id') | ||
->on('{{entity_table}}') | ||
->onDelete('set null'); | ||
}); | ||
|
||
Schema::create('{{closure_table}}', function (Blueprint $table) { | ||
$table->increments('closure_id'); | ||
|
||
$table->integer('ancestor', false, true); | ||
$table->integer('descendant', false, true); | ||
$table->integer('depth', false, true); | ||
|
||
$table->foreign('ancestor') | ||
->references('id') | ||
->on('{{entity_table}}') | ||
->onDelete('cascade'); | ||
|
||
$table->foreign('descendant') | ||
->references('id') | ||
->on('{{entity_table}}') | ||
->onDelete('cascade'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table('{{closure_table}}', function (Blueprint $table) { | ||
Schema::dropIfExists('{{closure_table}}'); | ||
}); | ||
|
||
Schema::table('{{entity_table}}', function (Blueprint $table) { | ||
Schema::dropIfExists('{{entity_table}}'); | ||
}); | ||
} | ||
} |