🗂
memo_migration
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// フロアテーブル
Schema::create('floors', function (Blueprint $table) {
$table->id();
$table->string('code')->unique(); // フロアコード(例:videoa)
$table->string('name');
$table->string('service_name');
$table->string('service_code');
$table->string('site_name');
$table->string('site_code');
$table->timestamps();
});
// 商品テーブル
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->foreignId('floor_id')->constrained('floors');
$table->string('content_id'); // 元のcontent_id
$table->string('product_id');
$table->string('title');
$table->string('volume')->nullable();
$table->integer('number')->nullable();
$table->integer('review_count')->nullable();
$table->decimal('review_average', 3, 2)->nullable();
$table->string('url')->nullable();
$table->string('affiliate_url')->nullable();
$table->string('image_url_list')->nullable();
$table->string('image_url_small')->nullable();
$table->string('image_url_large')->nullable();
$table->string('tachiyomi_url')->nullable();
$table->string('tachiyomi_affiliate_url')->nullable();
$table->string('sample_movie_url_476_306')->nullable();
$table->string('sample_movie_url_560_360')->nullable();
$table->string('sample_movie_url_644_414')->nullable();
$table->string('sample_movie_url_720_480')->nullable();
$table->boolean('sample_movie_pc_flag')->default(false);
$table->boolean('sample_movie_sp_flag')->default(false);
$table->string('price')->nullable();
$table->string('list_price')->nullable();
$table->timestamp('date')->nullable();
$table->timestamps();
// ユニーク制約
$table->unique(['floor_id', 'content_id']);
});
// アクターテーブル
Schema::create('actors', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('ruby')->nullable();
$table->string('ruby1')->nullable();
$table->string('ruby2')->nullable();
$table->string('ruby3')->nullable();
$table->integer('bust')->nullable();
$table->string('cup')->nullable();
$table->integer('waist')->nullable();
$table->integer('hip')->nullable();
$table->integer('height')->nullable();
$table->date('birthday')->nullable();
$table->string('blood_type')->nullable();
$table->string('hobby')->nullable();
$table->string('prefectures')->nullable();
$table->string('image_url_small')->nullable();
$table->string('image_url_large')->nullable();
$table->string('list_url_digital')->nullable();
$table->string('list_url_monthly_premium')->nullable();
$table->string('list_url_mono')->nullable();
$table->string('my_review')->nullable();
$table->date('debut')->nullable();
$table->string('roma_name')->nullable();
$table->string('top_image')->nullable();
$table->string('newest_main_item')->nullable();
$table->timestamps();
});
// 著者テーブル
Schema::create('authors', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('ruby')->nullable();
$table->string('list_url')->nullable();
$table->string('my_review')->nullable();
$table->timestamps();
});
// ジャンルテーブル
Schema::create('genres', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('ruby')->nullable();
$table->string('list_url')->nullable();
$table->timestamps();
});
// メーカーテーブル
Schema::create('makers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('ruby')->nullable();
$table->string('list_url')->nullable();
$table->timestamps();
});
// シリーズテーブル
Schema::create('series', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('ruby')->nullable();
$table->string('list_url')->nullable();
$table->string('my_review')->nullable();
$table->timestamps();
});
// 商品とアクターの中間テーブル
Schema::create('item_actor', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
$table->foreignId('actor_id')->constrained('actors')->onDelete('cascade');
$table->timestamps();
});
// 商品と著者の中間テーブル
Schema::create('item_author', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
$table->foreignId('author_id')->constrained('authors')->onDelete('cascade');
$table->timestamps();
});
// 商品とジャンルの中間テーブル
Schema::create('item_genre', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
$table->foreignId('genre_id')->constrained('genres')->onDelete('cascade');
$table->timestamps();
});
// 商品とメーカーの中間テーブル
Schema::create('item_maker', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
$table->foreignId('maker_id')->constrained('makers')->onDelete('cascade');
$table->timestamps();
});
// 商品とシリーズの中間テーブル
Schema::create('item_series', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
$table->foreignId('series_id')->constrained('series')->onDelete('cascade');
$table->timestamps();
});
// 商品のサンプル画像テーブル
Schema::create('item_sample_images', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
$table->string('image_url');
$table->string('size')->nullable(); // small, large など
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('item_sample_images');
Schema::dropIfExists('item_series');
Schema::dropIfExists('item_maker');
Schema::dropIfExists('item_genre');
Schema::dropIfExists('item_author');
Schema::dropIfExists('item_actor');
Schema::dropIfExists('series');
Schema::dropIfExists('makers');
Schema::dropIfExists('genres');
Schema::dropIfExists('authors');
Schema::dropIfExists('actors');
Schema::dropIfExists('items');
Schema::dropIfExists('floors');
}
};
Discussion