v1.5.11 - Event, News & Reservation deletion in sql db - And deletion of files in uploads when you go onto home pages and they're not used in DB

This commit is contained in:
Anders
2021-04-19 09:11:51 +02:00
parent b024d6e821
commit 40d082291f
7 changed files with 113 additions and 11 deletions
@@ -18,7 +18,7 @@ class CreateNewsTable extends Migration
$table->string("name");
$table->string('subname');
$table->longText("content");
$table->date('news_expiration_date')->nullable();
$table->dateTime('news_expiration_date')->nullable();
$table->foreignId('resource_id')->nullable()->constrained('resources', 'id');
$table->integer("arrangement_id")->nullable(); //Gets ID from given event, menu, guide or news
$table->foreignid("type_id")->nullable()->constrained("news_types", "id");
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RemoveEvent extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_event` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
DELETE FROM events WHERE HOUR(TIMEDIFF(NOW(), events.date)) >= 24 AND date(events.date) < CURDATE()");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RemoveNews extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_news` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
DELETE FROM news WHERE news_expiration_date < NOW();");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RemoveReservation extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_reservation` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
DELETE FROM washing_reservations WHERE time <= DATE_SUB(NOW(), INTERVAL 1 HOUR)");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}