Fixing database stuff

This commit is contained in:
Dan Cryer 2014-12-02 16:41:07 +00:00
parent 3eac0b0c23
commit 1b28d43b7f
5 changed files with 71 additions and 17 deletions

View file

@ -9,6 +9,13 @@ class FixDatabaseColumns extends AbstractMigration
*/ */
public function up() public function up()
{ {
$dbAdapter = $this->getAdapter();
if ($dbAdapter instanceof \Phinx\Db\Adapter\PdoAdapter) {
$pdo = $dbAdapter->getConnection();
$pdo->exec('SET foreign_key_checks = 0');
}
$build = $this->table('build'); $build = $this->table('build');
$build->changeColumn('project_id', 'integer', array('null' => false)); $build->changeColumn('project_id', 'integer', array('null' => false));
$build->changeColumn('commit_id', 'string', array('limit' => 50, 'null' => false)); $build->changeColumn('commit_id', 'string', array('limit' => 50, 'null' => false));
@ -45,5 +52,10 @@ class FixDatabaseColumns extends AbstractMigration
$user->changeColumn('hash', 'string', array('limit' => 250, 'null' => false)); $user->changeColumn('hash', 'string', array('limit' => 250, 'null' => false));
$user->changeColumn('is_admin', 'integer', array('null' => false, 'default' => 0)); $user->changeColumn('is_admin', 'integer', array('null' => false, 'default' => 0));
$user->changeColumn('name', 'string', array('limit' => 250, 'null' => false)); $user->changeColumn('name', 'string', array('limit' => 250, 'null' => false));
if ($dbAdapter instanceof \Phinx\Db\Adapter\PdoAdapter) {
$pdo = $dbAdapter->getConnection();
$pdo->exec('SET foreign_key_checks = 1');
}
} }
} }

View file

@ -110,16 +110,15 @@ class BuildBase extends Model
'commit_id' => array( 'commit_id' => array(
'type' => 'varchar', 'type' => 'varchar',
'length' => 50, 'length' => 50,
'nullable' => true,
'default' => null, 'default' => null,
), ),
'status' => array( 'status' => array(
'type' => 'tinyint', 'type' => 'int',
'length' => 4, 'length' => 11,
'default' => null, 'default' => null,
), ),
'log' => array( 'log' => array(
'type' => 'longtext', 'type' => 'text',
'nullable' => true, 'nullable' => true,
'default' => null, 'default' => null,
), ),
@ -155,7 +154,7 @@ class BuildBase extends Model
'default' => null, 'default' => null,
), ),
'extra' => array( 'extra' => array(
'type' => 'longtext', 'type' => 'text',
'nullable' => true, 'nullable' => true,
'default' => null, 'default' => null,
), ),
@ -382,10 +381,12 @@ class BuildBase extends Model
/** /**
* Set the value of CommitId / commit_id. * Set the value of CommitId / commit_id.
* *
* Must not be null.
* @param $value string * @param $value string
*/ */
public function setCommitId($value) public function setCommitId($value)
{ {
$this->_validateNotNull('CommitId', $value);
$this->_validateString('CommitId', $value); $this->_validateString('CommitId', $value);
if ($this->data['commit_id'] === $value) { if ($this->data['commit_id'] === $value) {

View file

@ -91,17 +91,15 @@ class BuildMetaBase extends Model
'build_id' => array( 'build_id' => array(
'type' => 'int', 'type' => 'int',
'length' => 11, 'length' => 11,
'nullable' => true,
'default' => null, 'default' => null,
), ),
'meta_key' => array( 'meta_key' => array(
'type' => 'varchar', 'type' => 'varchar',
'length' => 255, 'length' => 250,
'default' => null, 'default' => null,
), ),
'meta_value' => array( 'meta_value' => array(
'type' => 'longtext', 'type' => 'text',
'nullable' => true,
'default' => null, 'default' => null,
), ),
); );
@ -238,10 +236,12 @@ class BuildMetaBase extends Model
/** /**
* Set the value of BuildId / build_id. * Set the value of BuildId / build_id.
* *
* Must not be null.
* @param $value int * @param $value int
*/ */
public function setBuildId($value) public function setBuildId($value)
{ {
$this->_validateNotNull('BuildId', $value);
$this->_validateInt('BuildId', $value); $this->_validateInt('BuildId', $value);
if ($this->data['build_id'] === $value) { if ($this->data['build_id'] === $value) {
@ -276,10 +276,12 @@ class BuildMetaBase extends Model
/** /**
* Set the value of MetaValue / meta_value. * Set the value of MetaValue / meta_value.
* *
* Must not be null.
* @param $value string * @param $value string
*/ */
public function setMetaValue($value) public function setMetaValue($value)
{ {
$this->_validateNotNull('MetaValue', $value);
$this->_validateString('MetaValue', $value); $this->_validateString('MetaValue', $value);
if ($this->data['meta_value'] === $value) { if ($this->data['meta_value'] === $value) {

View file

@ -36,6 +36,7 @@ class ProjectBase extends Model
'id' => null, 'id' => null,
'title' => null, 'title' => null,
'reference' => null, 'reference' => null,
'branch' => null,
'ssh_private_key' => null, 'ssh_private_key' => null,
'type' => null, 'type' => null,
'access_information' => null, 'access_information' => null,
@ -53,6 +54,7 @@ class ProjectBase extends Model
'id' => 'getId', 'id' => 'getId',
'title' => 'getTitle', 'title' => 'getTitle',
'reference' => 'getReference', 'reference' => 'getReference',
'branch' => 'getBranch',
'ssh_private_key' => 'getSshPrivateKey', 'ssh_private_key' => 'getSshPrivateKey',
'type' => 'getType', 'type' => 'getType',
'access_information' => 'getAccessInformation', 'access_information' => 'getAccessInformation',
@ -72,6 +74,7 @@ class ProjectBase extends Model
'id' => 'setId', 'id' => 'setId',
'title' => 'setTitle', 'title' => 'setTitle',
'reference' => 'setReference', 'reference' => 'setReference',
'branch' => 'setBranch',
'ssh_private_key' => 'setSshPrivateKey', 'ssh_private_key' => 'setSshPrivateKey',
'type' => 'setType', 'type' => 'setType',
'access_information' => 'setAccessInformation', 'access_information' => 'setAccessInformation',
@ -104,6 +107,11 @@ class ProjectBase extends Model
'length' => 250, 'length' => 250,
'default' => null, 'default' => null,
), ),
'branch' => array(
'type' => 'varchar',
'length' => 50,
'default' => 'master',
),
'ssh_private_key' => array( 'ssh_private_key' => array(
'type' => 'text', 'type' => 'text',
'nullable' => true, 'nullable' => true,
@ -112,7 +120,7 @@ class ProjectBase extends Model
'type' => array( 'type' => array(
'type' => 'varchar', 'type' => 'varchar',
'length' => 50, 'length' => 50,
'default' => 1, 'default' => null,
), ),
'access_information' => array( 'access_information' => array(
'type' => 'varchar', 'type' => 'varchar',
@ -137,9 +145,8 @@ class ProjectBase extends Model
'default' => null, 'default' => null,
), ),
'allow_public_status' => array( 'allow_public_status' => array(
'type' => 'tinyint', 'type' => 'int',
'length' => 4, 'length' => 11,
'default' => null,
), ),
); );
@ -193,6 +200,18 @@ class ProjectBase extends Model
return $rtn; return $rtn;
} }
/**
* Get the value of Branch / branch.
*
* @return string
*/
public function getBranch()
{
$rtn = $this->data['branch'];
return $rtn;
}
/** /**
* Get the value of SshPrivateKey / ssh_private_key. * Get the value of SshPrivateKey / ssh_private_key.
* *
@ -337,6 +356,26 @@ class ProjectBase extends Model
$this->_setModified('reference'); $this->_setModified('reference');
} }
/**
* Set the value of Branch / branch.
*
* Must not be null.
* @param $value string
*/
public function setBranch($value)
{
$this->_validateNotNull('Branch', $value);
$this->_validateString('Branch', $value);
if ($this->data['branch'] === $value) {
return;
}
$this->data['branch'] = $value;
$this->_setModified('branch');
}
/** /**
* Set the value of SshPrivateKey / ssh_private_key. * Set the value of SshPrivateKey / ssh_private_key.
* *

View file

@ -90,14 +90,12 @@ class UserBase extends Model
'default' => null, 'default' => null,
), ),
'is_admin' => array( 'is_admin' => array(
'type' => 'tinyint', 'type' => 'int',
'length' => 1, 'length' => 11,
'default' => null,
), ),
'name' => array( 'name' => array(
'type' => 'varchar', 'type' => 'varchar',
'length' => 250, 'length' => 250,
'nullable' => true,
'default' => null, 'default' => null,
), ),
); );
@ -259,10 +257,12 @@ class UserBase extends Model
/** /**
* Set the value of Name / name. * Set the value of Name / name.
* *
* Must not be null.
* @param $value string * @param $value string
*/ */
public function setName($value) public function setName($value)
{ {
$this->_validateNotNull('Name', $value);
$this->_validateString('Name', $value); $this->_validateString('Name', $value);
if ($this->data['name'] === $value) { if ($this->data['name'] === $value) {