From 2ed6377971d52fdde25b37c58ab3c64a271c2b2d Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 11 Mar 2018 23:57:18 +0700 Subject: [PATCH] Removed useless field 'last_commit' from table 'project'. --- ...65225_removed_last_commit_from_project.php | 32 +++++++++++++++++++ src/Model/Base/Project.php | 28 ---------------- tests/src/Model/Base/ProjectTest.php | 13 -------- 3 files changed, 32 insertions(+), 41 deletions(-) create mode 100644 src/Migrations/20180311165225_removed_last_commit_from_project.php diff --git a/src/Migrations/20180311165225_removed_last_commit_from_project.php b/src/Migrations/20180311165225_removed_last_commit_from_project.php new file mode 100644 index 00000000..c19f254c --- /dev/null +++ b/src/Migrations/20180311165225_removed_last_commit_from_project.php @@ -0,0 +1,32 @@ +hasTable('project')) { + $table = $this->table('project'); + + if ($table->hasColumn('last_commit')) { + $table + ->removeColumn('last_commit') + ->save(); + } + } + } + + public function down() + { + if ($this->hasTable('project')) { + $table = $this->table('project'); + + if (!$table->hasColumn('last_commit')) { + $table + ->addColumn('last_commit', 'string', ['limit' => 250, 'null' => true, 'default' => null]) + ->save(); + } + } + } +} diff --git a/src/Model/Base/Project.php b/src/Model/Base/Project.php index 25f94154..0843ddb4 100644 --- a/src/Model/Base/Project.php +++ b/src/Model/Base/Project.php @@ -24,7 +24,6 @@ class Project extends Model 'ssh_public_key' => null, 'type' => null, 'access_information' => null, - 'last_commit' => null, 'build_config' => null, 'allow_public_status' => null, 'archived' => null, @@ -300,33 +299,6 @@ class Project extends Model return $this->setModified('access_information'); } - - /** - * @return string - */ - public function getLastCommit() - { - return $this->data['last_commit']; - } - - /** - * @param string $value - * - * @return boolean - */ - public function setLastCommit($value) - { - $this->validateString('last_commit', $value); - - if ($this->data['last_commit'] === $value) { - return false; - } - - $this->data['last_commit'] = $value; - - return $this->setModified('last_commit'); - } - /** * @return string */ diff --git a/tests/src/Model/Base/ProjectTest.php b/tests/src/Model/Base/ProjectTest.php index 6f8e2daa..8231afd2 100644 --- a/tests/src/Model/Base/ProjectTest.php +++ b/tests/src/Model/Base/ProjectTest.php @@ -24,7 +24,6 @@ class ProjectTest extends TestCase 'ssh_public_key' => null, 'type' => null, 'access_information' => null, - 'last_commit' => null, 'build_config' => null, 'allow_public_status' => null, 'archived' => null, @@ -155,18 +154,6 @@ class ProjectTest extends TestCase self::assertEquals(false, $result); } - public function testLastCommit() - { - $project = new Project(); - - $result = $project->setLastCommit('commit'); - self::assertEquals(true, $result); - self::assertEquals('commit', $project->getLastCommit()); - - $result = $project->setLastCommit('commit'); - self::assertEquals(false, $result); - } - public function testBuildConfig() { $project = new Project();