2021-06-08 20:43:47 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
|
|
|
|
class CreateAttachmentsTable extends Migration
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Run the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function up()
|
|
|
|
|
{
|
2021-06-09 15:11:02 +08:00
|
|
|
if (Schema::hasTable('attachments')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-06-08 20:43:47 +08:00
|
|
|
Schema::create('attachments', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->unsignedMediumInteger('userid')->default(0);
|
|
|
|
|
$table->unsignedSmallInteger('width')->default(0);
|
|
|
|
|
$table->dateTime('added')->nullable();
|
|
|
|
|
$table->string('filename')->default('');
|
|
|
|
|
$table->char('dlkey', 32)->index('idx_delkey');
|
|
|
|
|
$table->string('filetype', 50)->default('');
|
|
|
|
|
$table->unsignedBigInteger('filesize')->default(0);
|
|
|
|
|
$table->string('location')->default('');
|
|
|
|
|
$table->mediumInteger('downloads')->default(0);
|
|
|
|
|
$table->boolean('isimage')->unsigned()->default(0);
|
|
|
|
|
$table->boolean('thumb')->unsigned()->default(0);
|
|
|
|
|
$table->index(['userid', 'id'], 'pid');
|
|
|
|
|
$table->index(['added', 'isimage', 'downloads'], 'dateline');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function down()
|
|
|
|
|
{
|
|
|
|
|
Schema::dropIfExists('attachments');
|
|
|
|
|
}
|
|
|
|
|
}
|