support multiple teamleads in each team (#2702)
* fix jumping avatars * fix line-break after color dot for long names
This commit is contained in:
46
src/Migrations/Version20210802174318.php
Normal file
46
src/Migrations/Version20210802174318.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Doctrine\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* @version 1.15
|
||||
*/
|
||||
final class Version20210802174318 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Adds a new column to the team join table to support multiple teamleads';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$teamMember = $schema->getTable('kimai2_users_teams');
|
||||
$teamMember->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
|
||||
$teamMember->addColumn('teamlead', 'boolean', ['notnull' => true, 'default' => false]);
|
||||
$teamMember->dropPrimaryKey();
|
||||
$teamMember->setPrimaryKey(['id']);
|
||||
$teamMember->addUniqueIndex(['user_id', 'team_id'], 'UNIQ_B5E92CF8A76ED395296CD8AE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$teamMember = $schema->getTable('kimai2_users_teams');
|
||||
$teamMember->dropIndex('UNIQ_B5E92CF8A76ED395296CD8AE');
|
||||
$teamMember->dropPrimaryKey();
|
||||
$teamMember->dropColumn('teamlead');
|
||||
$teamMember->dropColumn('id');
|
||||
$teamMember->setPrimaryKey(['user_id', 'team_id']);
|
||||
}
|
||||
}
|
||||
52
src/Migrations/Version20210802174319.php
Normal file
52
src/Migrations/Version20210802174319.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Doctrine\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* @version 1.15
|
||||
*/
|
||||
final class Version20210802174319 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Migrate teamleads to join table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$fetch = $this->connection->prepare('SELECT id, teamlead_id FROM kimai2_teams');
|
||||
|
||||
foreach ($fetch->executeQuery()->iterateAssociative() as $row) {
|
||||
$this->addSql('UPDATE kimai2_users_teams SET teamlead = 1 WHERE user_id = ? AND team_id = ?', [$row['teamlead_id'], $row['id']]);
|
||||
}
|
||||
|
||||
$fetch->free();
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$fetch = $this->connection->prepare('SELECT user_id, team_id, teamlead FROM kimai2_users_teams WHERE teamlead = 1');
|
||||
|
||||
foreach ($fetch->executeQuery()->iterateAssociative() as $row) {
|
||||
$this->addSql('UPDATE kimai2_teams SET teamlead_id = ? where id = ?', [$row['user_id'], $row['team_id']]);
|
||||
}
|
||||
|
||||
$fetch->free();
|
||||
|
||||
$teams = $schema->getTable('kimai2_teams');
|
||||
$teams->getColumn('teamlead_id')->setNotnull(true);
|
||||
$teams->addForeignKeyConstraint('kimai2_users', ['teamlead_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_3BEDDC7F8F7DE5D7');
|
||||
}
|
||||
}
|
||||
39
src/Migrations/Version20210802174320.php
Normal file
39
src/Migrations/Version20210802174320.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Doctrine\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* @version 1.15
|
||||
*/
|
||||
final class Version20210802174320 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Remove teamlead id from teams table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$teams = $schema->getTable('kimai2_teams');
|
||||
$teams->removeForeignKey('FK_3BEDDC7F8F7DE5D7');
|
||||
$teams->dropColumn('teamlead_id');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$teams = $schema->getTable('kimai2_teams');
|
||||
$teams->addColumn('teamlead_id', 'integer', ['length' => 11, 'notnull' => false]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user