From a635cbdc497dea98fc74d419ff307fc7c5abe109 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 8 Jul 2023 18:37:31 +0200 Subject: [PATCH] Add DB Models/Migrations --- src/app/Models/Card.php | 11 +++++++ src/app/Models/Deck.php | 11 +++++++ src/app/Models/Tag.php | 11 +++++++ .../2023_07_08_142515_create_decks_table.php | 33 +++++++++++++++++++ .../2023_07_08_152018_create_tags_table.php | 27 +++++++++++++++ .../2023_07_08_152030_create_cards_table.php | 27 +++++++++++++++ ...3_07_08_161526_create_decks_tags_table.php | 33 +++++++++++++++++++ 7 files changed, 153 insertions(+) create mode 100644 src/app/Models/Card.php create mode 100644 src/app/Models/Deck.php create mode 100644 src/app/Models/Tag.php create mode 100644 src/database/migrations/2023_07_08_142515_create_decks_table.php create mode 100644 src/database/migrations/2023_07_08_152018_create_tags_table.php create mode 100644 src/database/migrations/2023_07_08_152030_create_cards_table.php create mode 100644 src/database/migrations/2023_07_08_161526_create_decks_tags_table.php diff --git a/src/app/Models/Card.php b/src/app/Models/Card.php new file mode 100644 index 0000000..19e23ca --- /dev/null +++ b/src/app/Models/Card.php @@ -0,0 +1,11 @@ +id(); + $table->string('name'); + $table->integer('card_count'); + $table->string('cover_path'); + $table->string('backside_path'); + $table->string('type')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('decks'); + } +}; diff --git a/src/database/migrations/2023_07_08_152018_create_tags_table.php b/src/database/migrations/2023_07_08_152018_create_tags_table.php new file mode 100644 index 0000000..85f6a52 --- /dev/null +++ b/src/database/migrations/2023_07_08_152018_create_tags_table.php @@ -0,0 +1,27 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tags'); + } +}; diff --git a/src/database/migrations/2023_07_08_152030_create_cards_table.php b/src/database/migrations/2023_07_08_152030_create_cards_table.php new file mode 100644 index 0000000..06eba07 --- /dev/null +++ b/src/database/migrations/2023_07_08_152030_create_cards_table.php @@ -0,0 +1,27 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('cards'); + } +}; diff --git a/src/database/migrations/2023_07_08_161526_create_decks_tags_table.php b/src/database/migrations/2023_07_08_161526_create_decks_tags_table.php new file mode 100644 index 0000000..0cb73b4 --- /dev/null +++ b/src/database/migrations/2023_07_08_161526_create_decks_tags_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBiginteger('decks_id')->unsigned(); + $table->unsignedBiginteger('tags_id')->unsigned(); + + $table->foreign('decks_id')->references('id')->on('decks')->onDelete('cascade'); + $table->foreign('tags_id')->references('id')->on('tags')->onDelete('cascade'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('decks_tags'); + } +};