From eb48d616a8252cbca6d828663dcae4bfcf96e6ec Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Fri, 8 Jan 2021 10:03:19 +0100 Subject: [PATCH 1/5] Table Migration --- .../2021_01_07_183923_create_rooms_table.php | 2 ++ .../2021_01_07_184250_create_devices_table.php | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/database/migrations/2021_01_07_183923_create_rooms_table.php b/database/migrations/2021_01_07_183923_create_rooms_table.php index 546fbfa..c5b1c8c 100644 --- a/database/migrations/2021_01_07_183923_create_rooms_table.php +++ b/database/migrations/2021_01_07_183923_create_rooms_table.php @@ -16,6 +16,8 @@ class CreateRoomsTable extends Migration Schema::create('rooms', function (Blueprint $table) { $table->id(); $table->string('name')->unique(); + $table->int('owner_id'); //TODO: Foregin key to user Table + $table->boolval('default'); $table->timestamps(); }); } diff --git a/database/migrations/2021_01_07_184250_create_devices_table.php b/database/migrations/2021_01_07_184250_create_devices_table.php index e743c72..7fb35be 100644 --- a/database/migrations/2021_01_07_184250_create_devices_table.php +++ b/database/migrations/2021_01_07_184250_create_devices_table.php @@ -15,6 +15,18 @@ class CreateDevicesTable extends Migration { Schema::create('devices', function (Blueprint $table) { $table->id(); + $table->int('room_id'); //TODO: Foregin key to Room Table + $table->string('type'); + $table->string('token'); + $table->datetime('heartbeat') + $table->string('mac'); + $table->string('firmware_hash'); + $table->string('ip_address'); + $table->string('sleep_time'); + $table->string('owner_id'); //TODO: Foregin key to user Table + $table->boolval('approved'); + $table->string('icon'); + $table->string('command'); $table->string('name')->unique(); $table->string('description')->nullable(); $table->timestamps(); From 7e5176d5f300885b7fdf68d3350e14371c21de32 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Fri, 8 Jan 2021 10:05:32 +0100 Subject: [PATCH 2/5] Migration Tweeks #1 --- .../migrations/2021_01_07_183923_create_rooms_table.php | 2 +- .../migrations/2021_01_07_184250_create_devices_table.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/database/migrations/2021_01_07_183923_create_rooms_table.php b/database/migrations/2021_01_07_183923_create_rooms_table.php index c5b1c8c..f516447 100644 --- a/database/migrations/2021_01_07_183923_create_rooms_table.php +++ b/database/migrations/2021_01_07_183923_create_rooms_table.php @@ -14,7 +14,7 @@ class CreateRoomsTable extends Migration public function up() { Schema::create('rooms', function (Blueprint $table) { - $table->id(); + $table->id()->unique(); $table->string('name')->unique(); $table->int('owner_id'); //TODO: Foregin key to user Table $table->boolval('default'); diff --git a/database/migrations/2021_01_07_184250_create_devices_table.php b/database/migrations/2021_01_07_184250_create_devices_table.php index 7fb35be..a6b5ffc 100644 --- a/database/migrations/2021_01_07_184250_create_devices_table.php +++ b/database/migrations/2021_01_07_184250_create_devices_table.php @@ -14,14 +14,14 @@ class CreateDevicesTable extends Migration public function up() { Schema::create('devices', function (Blueprint $table) { - $table->id(); + $table->id()->unique(); $table->int('room_id'); //TODO: Foregin key to Room Table $table->string('type'); - $table->string('token'); + $table->string('token')->unique(); $table->datetime('heartbeat') $table->string('mac'); $table->string('firmware_hash'); - $table->string('ip_address'); + $table->string('ip_address')->unique(); $table->string('sleep_time'); $table->string('owner_id'); //TODO: Foregin key to user Table $table->boolval('approved'); From 35293ac1b9ab8b386f3c36674cfc9533c9339bca Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Fri, 8 Jan 2021 10:08:21 +0100 Subject: [PATCH 3/5] Migration Tweeks #2 --- .../2021_01_07_184250_create_devices_table.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/database/migrations/2021_01_07_184250_create_devices_table.php b/database/migrations/2021_01_07_184250_create_devices_table.php index a6b5ffc..54be862 100644 --- a/database/migrations/2021_01_07_184250_create_devices_table.php +++ b/database/migrations/2021_01_07_184250_create_devices_table.php @@ -16,19 +16,19 @@ class CreateDevicesTable extends Migration Schema::create('devices', function (Blueprint $table) { $table->id()->unique(); $table->int('room_id'); //TODO: Foregin key to Room Table - $table->string('type'); - $table->string('token')->unique(); - $table->datetime('heartbeat') - $table->string('mac'); - $table->string('firmware_hash'); - $table->string('ip_address')->unique(); - $table->string('sleep_time'); $table->string('owner_id'); //TODO: Foregin key to user Table + $table->string('token')->unique(); $table->boolval('approved'); - $table->string('icon'); - $table->string('command'); $table->string('name')->unique(); $table->string('description')->nullable(); + $table->string('type'); + $table->string('icon'); + $table->string('mac_address'); + $table->string('ip_address')->unique(); + $table->string('firmware_hash'); + $table->string('sleep_time'); + $table->datetime('heartbeat') + $table->string('command'); $table->timestamps(); }); } From 27e9ef9f27f45339e39244cc873a79ed6ce9466d Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Fri, 8 Jan 2021 10:10:27 +0100 Subject: [PATCH 4/5] Git ignore: VS Code Config Foler --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index c502328..c75494f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,8 @@ Homestead.yaml npm-debug.log yarn-error.log .idea/ + + + + +.vscode From e38421ca2fd0fcc7eb4688d303b4b0b226fec64b Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Sun, 10 Jan 2021 19:30:45 +0100 Subject: [PATCH 5/5] Foregin Keys --- database/migrations/2021_01_07_183923_create_rooms_table.php | 1 + .../migrations/2021_01_07_184250_create_devices_table.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/database/migrations/2021_01_07_183923_create_rooms_table.php b/database/migrations/2021_01_07_183923_create_rooms_table.php index f516447..4231b1b 100644 --- a/database/migrations/2021_01_07_183923_create_rooms_table.php +++ b/database/migrations/2021_01_07_183923_create_rooms_table.php @@ -19,6 +19,7 @@ class CreateRoomsTable extends Migration $table->int('owner_id'); //TODO: Foregin key to user Table $table->boolval('default'); $table->timestamps(); + $table->forgein('owner_id')->references('user_id')->on('users'); }); } diff --git a/database/migrations/2021_01_07_184250_create_devices_table.php b/database/migrations/2021_01_07_184250_create_devices_table.php index 54be862..43e41d6 100644 --- a/database/migrations/2021_01_07_184250_create_devices_table.php +++ b/database/migrations/2021_01_07_184250_create_devices_table.php @@ -27,8 +27,10 @@ class CreateDevicesTable extends Migration $table->string('ip_address')->unique(); $table->string('firmware_hash'); $table->string('sleep_time'); - $table->datetime('heartbeat') + $table->datetime('heartbeat'); $table->string('command'); + $table->forgein('owner_id')->references('user_id')->on('users'); + $table->forgein('room_id')->references('room_id')->on('rooms'); $table->timestamps(); }); }