Removed useless field 'last_commit' from table 'project'.

This commit is contained in:
Dmitry Khomutov 2018-03-11 23:57:18 +07:00
parent ad7670e81e
commit 2ed6377971
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
3 changed files with 32 additions and 41 deletions

View file

@ -0,0 +1,32 @@
<?php
use Phinx\Migration\AbstractMigration;
class RemovedLastCommitFromProject extends AbstractMigration
{
public function up()
{
if ($this->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();
}
}
}
}

View file

@ -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
*/

View file

@ -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();