mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Update migration
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
@@ -11,25 +11,21 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_excluded_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('users_id');
|
||||
$table->unsignedInteger('categories_id');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('users_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('categories_id')
|
||||
->references('id')
|
||||
->on('categories')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->unique(['users_id', 'categories_id']);
|
||||
$table->index('users_id');
|
||||
});
|
||||
// Use raw SQL to ensure exact column type matching with existing tables
|
||||
DB::statement("
|
||||
CREATE TABLE `user_excluded_categories` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`users_id` int(10) unsigned NOT NULL,
|
||||
`categories_id` int(10) unsigned NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `ux_user_excluded_categories` (`users_id`, `categories_id`),
|
||||
KEY `ix_user_excluded_categories_users_id` (`users_id`),
|
||||
CONSTRAINT `FK_uec_users` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `FK_uec_categories` FOREIGN KEY (`categories_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user