increments('id'); $table->timestamps(); $table->unsignedInteger('owner_id'); $table->unsignedInteger('parent_data_table_id')->nullable(); $table->string('title'); $table->string('license'); $table->foreign('owner_id') ->references('id')->on('users') ->onDelete('cascade'); $table->foreign('parent_data_table_id') ->references('id')->on('data_tables') ->onDelete('set null'); }); Schema::create('table_revisions', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->boolean('approved'); $table->unsignedInteger('data_table_id'); $table->unsignedInteger('parent_revision_id')->nullable(); $table->unsignedInteger('author_id')->nullable(); $table->longText('content'); $table->foreign('data_table_id') ->references('id')->on('data_tables') ->onDelete('cascade'); $table->foreign('parent_revision_id') ->references('id')->on('table_revisions') ->onDelete('set null'); $table->foreign('author_id') ->references('id')->on('users') ->onDelete('set null'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('table_revisions'); Schema::dropIfExists('data_tables'); } }