added create_news migration
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('news', function (Blueprint $table) {
|
||||||
|
// Создаем поля для составного ключа
|
||||||
|
// unsignedInteger соответствует int(11) unsigned
|
||||||
|
$table->unsignedInteger('id');
|
||||||
|
$table->integer('from_id');
|
||||||
|
|
||||||
|
$table->unsignedInteger('copy_post_id')->nullable();
|
||||||
|
$table->string('header', 255)->nullable();
|
||||||
|
$table->text('long_text')->nullable();
|
||||||
|
$table->dateTime('date')->nullable();
|
||||||
|
$table->string('img_src', 255)->nullable();
|
||||||
|
$table->string('post_type', 255)->nullable();
|
||||||
|
$table->unsignedTinyInteger('author_type')->nullable();
|
||||||
|
|
||||||
|
// Установка составного первичного ключа
|
||||||
|
$table->primary(['id', 'from_id']);
|
||||||
|
|
||||||
|
// Индексы
|
||||||
|
$table->index('post_type', 'idx_type');
|
||||||
|
$table->index('from_id', 'idx_from_id');
|
||||||
|
$table->index('date', 'idx_date');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('news');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user