Made documentation on migrations

This commit is contained in:
neerholt 2021-03-04 09:19:13 +01:00
parent 2e6671bf7b
commit 119732114f
8 changed files with 108 additions and 11 deletions

View File

@ -1,12 +1,24 @@
<?php <?php
//require bootstrap aka our database connection
require_once "../../bootstrap.php"; require_once "../../bootstrap.php";
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create game_data table with the rows as id, gameLink, isWebBased and timestamp
Capsule::schema()->create("game_data", function (Blueprint $table){ Capsule::schema()->create("game_data", function (Blueprint $table){
$table->id(); $table->id();
$table->string("gameLink"); $table->string("gameLink");
$table->boolean("isWebBased"); $table->boolean("isWebBased");
$table->timestamps(); $table->timestamps();
}); });
/*
Syntex to create table in database
$table->string("texts");
$table => valuable;
string => datatype;
("texts") => name for the row in the database;
*/

View File

@ -1,9 +1,11 @@
<?php <?php
//require bootstrap aka our database connection
require_once "../../bootstrap.php"; require_once "../../bootstrap.php";
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create game_jams table with the rows as id, name, startTime, endTime, keyWord, description and timestamp
Capsule::schema()->create("game_jams", function (Blueprint $table){ Capsule::schema()->create("game_jams", function (Blueprint $table){
$table->id(); $table->id();
$table->string("name"); $table->string("name");
@ -13,3 +15,14 @@ Capsule::schema()->create("game_jams", function (Blueprint $table){
$table->text("description")->nullable(); $table->text("description")->nullable();
$table->timestamps(); $table->timestamps();
}); });
/*
Syntex to create table in database
$table->string("texts");
$table => valuable;
string => datatype;
("texts") => name for the row in the database;
nullable => is allowed to not have a value in the database;
*/

View File

@ -1,9 +1,11 @@
<?php <?php
//require bootstrap aka our database connection
require_once "../../bootstrap.php"; require_once "../../bootstrap.php";
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create groups table with the rows as id, groupName, groupAmount, fkGameJam, votes, fkPassword, fkGameData and timestamp
Capsule::schema()->create("groups", function (Blueprint $table){ Capsule::schema()->create("groups", function (Blueprint $table){
$table->id(); $table->id();
$table->string("groupName"); $table->string("groupName");
@ -14,3 +16,17 @@ Capsule::schema()->create("groups", function (Blueprint $table){
$table->foreignId("fkGameData")->nullable()->constrained("game_data"); $table->foreignId("fkGameData")->nullable()->constrained("game_data");
$table->timestamps(); $table->timestamps();
}); });
/*
Syntex to create table in database
$table->string("texts");
$table => valuable;
string => datatype;
("texts") => name for the row in the database;
nullable => is allowed to not have a value in the database;
foreignId => foreignId key row name in the database;
constrained => targeted table name;
*/

View File

@ -1,12 +1,27 @@
<?php <?php
//require bootstrap aka our database connection
require_once "../../bootstrap.php"; require_once "../../bootstrap.php";
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create key_words table with the rows as id, keyWord, fkGroup and timestamp
Capsule::schema()->create("key_words", function (Blueprint $table){ Capsule::schema()->create("key_words", function (Blueprint $table){
$table->id(); $table->id();
$table->string('keyWord'); $table->string('keyWord');
$table->foreignId("fkGroup")->constrained("groups"); $table->foreignId("fkGroup")->constrained("groups");
$table->timestamps(); $table->timestamps();
}); });
/*
Syntex to create table in database
$table->string("texts");
$table => valuable;
string => datatype;
("texts") => name for the row in the database
foreignId => foreignId key row name in the database;
constrained => targeted table name;
*/

View File

@ -1,12 +1,25 @@
<?php <?php
//require bootstrap aka our database connection
require_once "../../bootstrap.php"; require_once "../../bootstrap.php";
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create password table with the rows as id, password, rememberToken and timestamps
Capsule::schema()->create("password", function (Blueprint $table){ Capsule::schema()->create("password", function (Blueprint $table){
$table->id(); $table->id();
$table->string('password'); $table->string('password');
$table->rememberToken(); $table->rememberToken();
$table->timestamps(); $table->timestamps();
}); });
/*
Syntex to create table in database
$table->string("texts");
$table => valuable;
string => datatype;
("texts") => name for the row in the database
*/

View File

@ -1,7 +1,20 @@
<?php <?php
//Path /Backend/Database/databaseMigration.php
require "GameJam.php"; /*
require "GameData.php"; * databaseMigration is used to auto crate the various tables in the database.
require "Password.php"; * To call/run the databaseMigration visited the "Path".
require "Group.php"; * There is a reason to why we call GameJam first, the reason being
require "KeyWord.php"; * that GameJam doesn't have any foreign key in the table, we can't
* create a table that depends on a foreign key, so we create all the tables
* without a foreign key in it, after that we are able to create the tables
* with foreign keys in it.
*
* See the Database Diagram for detailed understand.
*/
require "GameJam.php"; //GameJam has no foreign key
require "GameData.php"; //GameData has no foreign key
require "Password.php"; //Password has no foreign key
require "Group.php"; //Group has foreign keys to the GameJam, GameData and Password tables hence we create it as one of the last tables in the database
require "KeyWord.php"; //Group has foreign keys to the Group

View File

@ -1,10 +1,23 @@
<?php <?php
//require bootstrap aka our database connection
require_once "../../bootstrap.php"; require_once "../../bootstrap.php";
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create has_voted table with the rows as id and timestamp
Capsule::schema()->create("has_voted", function (Blueprint $table){ Capsule::schema()->create("has_voted", function (Blueprint $table){
$table->id(); $table->id();
$table->timestamps(); $table->timestamps();
}); });
/*
Syntex to create table in database
$table->string("texts");
$table => valuable;
string => datatype;
("texts") => name for the row in the database
*/

View File

@ -6,3 +6,5 @@ require "../bootstrap.php";
$gameJam = GameJam::firstOrCreate([ $gameJam = GameJam::firstOrCreate([
'name' => "First game jam ever!", 'startTime' => "2021-03-03T12:40", 'endTime' => "2021-04-03T12:40", 'description' => "Det her et en beskrivelse" 'name' => "First game jam ever!", 'startTime' => "2021-03-03T12:40", 'endTime' => "2021-04-03T12:40", 'description' => "Det her et en beskrivelse"
]); ]);