increments('id'); $table->timestamps(); // note that a revision may be shared by multiple tables, thus a proposal may also apply to different tables $table->unsignedInteger('table_id')->index(); // table this proposal was written for $table->unsignedInteger('revision_id')->index(); // parent revision (applying it to a different revisions may cause conflicts) $table->unsignedInteger('author_id')->index(); $table->text('note'); $table->jsonb('changes'); // the actual meat of the changeset is stored here // block the delete - we must first decrement Row refs and then the proposals manually $table->foreign('revision_id')->references('id')->on('revisions') ->onDelete('restrict'); // deleting the table must NOT delete the proposals, as they may be applicable to forks sharing the revision $table->foreign('table_id')->references('id')->on('tables') ->onDelete('set null'); // block the delete - we must first decrement Row refs and then the proposals manually $table->foreign('author_id')->references('id')->on('users') ->onDelete('restrict'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('proposals'); } }