Commit 051e9a34 by Julien Jorry

Fix table prefix for table fos_user_user_group and migration_versions

parent f4514d2c
...@@ -3,3 +3,4 @@ doctrine_migrations: ...@@ -3,3 +3,4 @@ doctrine_migrations:
# namespace is arbitrary but should be different from App\Migrations # namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded # as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations namespace: DoctrineMigrations
table_name: '%env(DATABASE_PREFIX)%migration_versions'
...@@ -144,7 +144,7 @@ class ImportController extends CRUDController ...@@ -144,7 +144,7 @@ class ImportController extends CRUDController
$compte = $row['compte']; $compte = $row['compte'];
if (empty($groupe) && empty($name)) { if (empty($groupe) && empty($name)) {
$this->addError($row, $line, 'email & groupe', $this->translator->trans("L'email et le groupe sont obligatoires !")); $this->addError($row, $line, 'nom & groupe', $this->translator->trans("Le nom et le groupe sont obligatoires !"));
$line++; $line++;
continue; continue;
} }
......
...@@ -115,6 +115,15 @@ class User extends BaseUser ...@@ -115,6 +115,15 @@ class User extends BaseUser
*/ */
private $pages; private $pages;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Usergroup")
* @ORM\JoinTable(name="user_usergroup",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
* )
*/
protected $groups;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace App\Entity; namespace App\Entity;
use Sonata\UserBundle\Entity\BaseGroup as BaseGroup; use FOS\UserBundle\Model\Group as BaseGroup;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190418202928 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE fos_user_user_group RENAME TO user_usergroup');
// $this->addSql('CREATE TABLE user_usergroup (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_4A84F5F3A76ED395 (user_id), INDEX IDX_4A84F5F3FE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB');
// $this->addSql('ALTER TABLE user_usergroup ADD CONSTRAINT FK_4A84F5F3A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
// $this->addSql('ALTER TABLE user_usergroup ADD CONSTRAINT FK_4A84F5F3FE54D947 FOREIGN KEY (group_id) REFERENCES usergroup (id)');
// $this->addSql('DROP TABLE fos_user_user_group');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE fos_user_user_group (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_B3C77447FE54D947 (group_id), INDEX IDX_B3C77447A76ED395 (user_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE fos_user_user_group ADD CONSTRAINT FK_B3C77447A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE fos_user_user_group ADD CONSTRAINT FK_B3C77447FE54D947 FOREIGN KEY (group_id) REFERENCES usergroup (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE user_usergroup');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment