c3lf-system-3/database/migrations/2020_01_18_001554_add_currentfiles_view.php

36 lines
760 B
PHP

<?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()
{
//
}
}