mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
book cases added
This commit is contained in:
@@ -14,6 +14,10 @@ class CreateBookCasesTable extends Migration
|
||||
{
|
||||
Schema::create('book_cases', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->boolean('orange_pilled')
|
||||
->default(false);
|
||||
$table->unsignedInteger('orange_pilled_amount')
|
||||
->default(0);
|
||||
$table->string('title');
|
||||
$table->double('lat');
|
||||
$table->double('lon');
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOrangePillsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::disableForeignKeyConstraints();
|
||||
|
||||
Schema::create('orange_pills', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->foreignId('book_case_id')->constrained()->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->dateTime('date');
|
||||
$table->unsignedInteger('amount');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::enableForeignKeyConstraints();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('orange_pills');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$this->nullableMorphs($table, 'commentator', 'commentator_comments');
|
||||
$table->morphs('commentable');
|
||||
$table->foreignId('parent_id')->nullable()->constrained('comments')->onDelete('cascade');
|
||||
$table->longText('original_text');
|
||||
$table->longText('text');
|
||||
$table->json('extra')->nullable();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('reactions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$this->nullableMorphs($table, 'commentator', 'commentator_reactions');
|
||||
$table->foreignId('comment_id')->references('id')->on('comments')->cascadeOnDelete();
|
||||
$table->string('reaction')->collation('C.UTF-8');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('comment_notification_subscriptions', function(Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('commentable', 'cn_subscriptions_commentable');
|
||||
$table->morphs('subscriber', 'cn_subscriptions_subscriber');
|
||||
$table->string('type');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
protected function nullableMorphs(Blueprint $table, string $name, string $indexName): void
|
||||
{
|
||||
$table->string("{$name}_type")->nullable();
|
||||
$table->unsignedBigInteger("{$name}_id")->nullable();
|
||||
$table->index(["{$name}_type", "{$name}_id"], $indexName);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user