Working proposal apply code, fixed schema (need reset - artisan migrate:fresh)
This commit is contained in:
@@ -17,6 +17,7 @@ class CreateRevisionsTable extends Migration
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->unsignedInteger('ancestor_id')->index()->nullable(); // parent revision
|
||||
$table->unsignedInteger('proposal_id')->index()->nullable(); // parent revision
|
||||
|
||||
$table->unsignedInteger('row_count'); // cached nbr of rows
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@ class CreateProposalsTable extends Migration
|
||||
$table->foreign('author_id')->references('id')->on('users')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
// add FK to revisions to point to the source proposal
|
||||
Schema::table('revisions', function (Blueprint $table) {
|
||||
$table->foreign('proposal_id')->references('id')->on('proposals')
|
||||
->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRevisionProposalPivotTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('revision_proposal_pivot', function (Blueprint $table) {
|
||||
$table->unsignedInteger('proposal_id')->index();
|
||||
$table->unsignedInteger('revision_id')->index();
|
||||
|
||||
$table->foreign('proposal_id')->references('id')->on('proposals')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('revision_id')->references('id')->on('revisions')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('revision_proposal_pivot');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user