Working proposal apply code, fixed schema (need reset - artisan migrate:fresh)

This commit is contained in:
2018-08-11 18:42:12 +02:00
parent 8efc31d820
commit f2910f977f
12 changed files with 168 additions and 69 deletions
@@ -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');
}
}