add proper migration for currentfiles view

This commit is contained in:
j3d1 2020-01-18 00:25:30 +01:00
parent dbc4a84d3f
commit 8a3b51a1ed

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCurrentfilesView extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
DB::statement('create view currentfiles as
select `f`.`iid` AS `iid`, `f`.`hash` AS `hash`
from `files` `f`
where `f`.`created_at` = (select max(`files`.`created_at`)
from `files`
group by `files`.`iid`
having `files`.`iid` = `f`.`iid`);');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}