diff --git a/app/Models/Template.php b/app/Models/Template.php new file mode 100644 index 0000000..73c0a87 --- /dev/null +++ b/app/Models/Template.php @@ -0,0 +1,7 @@ +id(); + $table->string('name')->unique(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('template_categories'); + } +}; diff --git a/database/migrations/2024_12_29_124458_create_templates_table.php b/database/migrations/2024_12_29_124458_create_templates_table.php new file mode 100644 index 0000000..4d09628 --- /dev/null +++ b/database/migrations/2024_12_29_124458_create_templates_table.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId('category_id')->constrained('template_categories')->cascadeOnDelete(); + $table->foreignId('owner_id')->nullable()->constrained('users')->nullOnDelete(); + $table->boolean('is_private')->default(false); + $table->unsignedTinyInteger('priority')->default(0); + $table->string('title'); + $table->longText('content'); + $table->string('tags')->nullable(); + $table->timestamps(); + + $table->index(['is_private', 'priority', 'title']); + $table->index(['category_id', 'is_private', 'priority', 'title']); + $table->index(['owner_id', 'is_private', 'priority', 'title']); + }); + } + + public function down(): void + { + Schema::dropIfExists('templates'); + } +};