diff --git a/app/Models/DatabaseHost.php b/app/Models/DatabaseHost.php index 9494e6623..323a3cc8f 100644 --- a/app/Models/DatabaseHost.php +++ b/app/Models/DatabaseHost.php @@ -10,7 +10,6 @@ namespace Pterodactyl\Models; * @property string $username * @property string $password * @property int|null $max_databases - * @property int|null $node_id * @property \Carbon\CarbonImmutable $created_at * @property \Carbon\CarbonImmutable $updated_at */ diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index e354e0299..3b80189f0 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -62,7 +62,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase public function testDatabaseCannotBeCreatedIfServerHasReachedLimit() { $server = $this->createServerModel(['database_limit' => 2]); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(); Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); @@ -93,10 +93,10 @@ class DatabaseManagementServiceTest extends IntegrationTestCase public function testCreatingDatabaseWithIdenticalNameTriggersAnException() { $server = $this->createServerModel(); - $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); + $name = DatabaseManagementService::generateUniqueDatabaseName('something', $server->id); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - $host2 = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(); + $host2 = DatabaseHost::factory()->create(); Database::factory()->create([ 'database' => $name, 'database_host_id' => $host->id, @@ -122,9 +122,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase public function testServerDatabaseCanBeCreated() { $server = $this->createServerModel(); - $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); + $name = DatabaseManagementService::generateUniqueDatabaseName('something', $server->id); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(); $this->repository->expects('createDatabase')->with($name); @@ -180,9 +180,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase public function testExceptionEncounteredWhileCreatingDatabaseAttemptsToCleanup() { $server = $this->createServerModel(); - $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); + $name = DatabaseManagementService::generateUniqueDatabaseName('something', $server->id); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(); $this->repository->expects('createDatabase')->with($name)->andThrows(new BadMethodCallException()); $this->repository->expects('dropDatabase')->with($name); diff --git a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php index 2d4719571..2f652b448 100644 --- a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php +++ b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php @@ -64,8 +64,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $node = Node::factory()->create(['location_id' => $server->location->id]); - DatabaseHost::factory()->create(['node_id' => $node->id]); + $host = DatabaseHost::factory()->create(); + $node = Node::factory()->create(['location_id' => $server->location->id, 'database_host_id' => $host->id]); config()->set('pterodactyl.client_features.databases.allow_random', false); @@ -99,9 +99,9 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $node = Node::factory()->create(['location_id' => $server->location->id]); - DatabaseHost::factory()->create(['node_id' => $node->id]); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $node = Node::factory()->create(['location_id' => $server->location->id, 'database_host_id' => DatabaseHost::factory()->create()->id]); + $host = DatabaseHost::factory()->create(); + $server->node->database_host_id = $host->id; $this->managementService->expects('create')->with($server, [ 'database_host_id' => $host->id, @@ -126,8 +126,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $node = Node::factory()->create(['location_id' => $server->location->id]); - $host = DatabaseHost::factory()->create(['node_id' => $node->id]); + $host = DatabaseHost::factory()->create(); + $node = Node::factory()->create(['location_id' => $server->location->id, 'database_host_id' => $host->id]); $this->managementService->expects('create')->with($server, [ 'database_host_id' => $host->id,