diff --git a/database/migrations/2021_03_04_095453_add_foreign_keys.php b/database/migrations/2021_03_04_095453_add_foreign_keys.php new file mode 100644 index 0000000..b8226e1 --- /dev/null +++ b/database/migrations/2021_03_04_095453_add_foreign_keys.php @@ -0,0 +1,104 @@ +bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('robot_scans', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('dns_scans', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('visual_diffs', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('cron_pings', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('uptime_scans', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('certificate_scans', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + + Schema::table('crawled_pages', function (Blueprint $table) { + $table->bigInteger('website_id')->unsigned()->index()->change(); + $table->foreign('website_id')->references('id')->on('websites')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('open_graph_scans', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('robot_scans', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('dns_scans', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('visual_diffs', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('cron_pings', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('uptime_scans', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('certificate_scans', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + + Schema::table('crawled_pages', function (Blueprint $table) { + $table->integer('website_id')->change(); + $table->dropForeign('website_id'); + }); + } +}