Skip to content

Commit

Permalink
Add table access_url_rel_usergroup
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed May 22, 2015
1 parent 7a8c054 commit 0157b72
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
100 changes: 100 additions & 0 deletions src/Chamilo/CoreBundle/Entity/AccessUrlRelUserGroup.php
@@ -0,0 +1,100 @@
<?php

namespace Chamilo\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* AccessUrlRelUser
*
* @ORM\Table(name="access_url_rel_usergroup")
* @ORM\Entity
*/
class AccessUrlRelUserGroup
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue()
*/
private $id;

/**
* @var integer
*
* @ORM\Column(name="access_url_id", type="integer")
*/
private $accessUrlId;

/**
* @var integer
*
* @ORM\Column(name="usergroup_id", type="integer")
*/
private $userGroupId;


/**
* Set accessUrlId
*
* @param integer $accessUrlId
* @return AccessUrlRelUser
*/
public function setAccessUrlId($accessUrlId)
{
$this->accessUrlId = $accessUrlId;

return $this;
}

/**
* Get accessUrlId
*
* @return integer
*/
public function getAccessUrlId()
{
return $this->accessUrlId;
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @param int $id
* @return AccessUrlRelUserGroup
*/
public function setId($id)
{
$this->id = $id;

return $this;
}

/**
* @return int
*/
public function getUserGroupId()
{
return $this->userGroupId;
}

/**
* @param int $userGroupId
* @return AccessUrlRelUserGroup
*/
public function setUserGroupId($userGroupId)
{
$this->userGroupId = $userGroupId;

return $this;
}
}
@@ -0,0 +1,42 @@
<?php
/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\Migrations\Schema\V110;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;


/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20150522112023 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
if (!$schema->hasTable('access_url_rel_usergroup')) {
$this->addSql(
'CREATE TABLE access_url_rel_usergroup (id INT UNSIGNED AUTO_INCREMENT NOT NULL, access_url_id INT UNSIGNED NOT NULL, usergroup_id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$sql = 'SELECT * FROM usergroup';
$result = $this->connection->query($sql);
$results = $result->fetchAll();
foreach ($results as $result) {
$groupId = $result['id'];
$sql = "INSERT INTO access_url_rel_usergroup (access_url_id, usergroup_id) VALUES ('1', '$groupId')";
$this->addSql($sql);
}
}
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql('DROP TABLE access_url_rel_usergroup');
}
}

0 comments on commit 0157b72

Please sign in to comment.