Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -0,0 +1,50 @@
<?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;
final class Version20180701120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Initial database structure';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE kimai2_users (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(60) NOT NULL, mail VARCHAR(160) NOT NULL, password VARCHAR(254) DEFAULT NULL, alias VARCHAR(60) DEFAULT NULL, active TINYINT(1) NOT NULL, registration_date DATETIME DEFAULT NULL, title VARCHAR(50) DEFAULT NULL, avatar VARCHAR(255) DEFAULT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', UNIQUE INDEX UNIQ_B9AC5BCE5E237E06 (name), UNIQUE INDEX UNIQ_B9AC5BCE5126AC48 (mail), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE kimai2_user_preferences (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, name VARCHAR(50) NOT NULL, value VARCHAR(255) DEFAULT NULL, INDEX IDX_8D08F631A76ED395 (user_id), UNIQUE INDEX UNIQ_8D08F631A76ED3955E237E06 (user_id, name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE kimai2_customers (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(150) NOT NULL, number VARCHAR(50) DEFAULT NULL, comment TEXT DEFAULT NULL, visible TINYINT(1) NOT NULL, company VARCHAR(255) DEFAULT NULL, contact VARCHAR(255) DEFAULT NULL, address TEXT DEFAULT NULL, country VARCHAR(2) NOT NULL, currency VARCHAR(3) NOT NULL, phone VARCHAR(255) DEFAULT NULL, fax VARCHAR(255) DEFAULT NULL, mobile VARCHAR(255) DEFAULT NULL, mail VARCHAR(255) DEFAULT NULL, homepage VARCHAR(255) DEFAULT NULL, timezone VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE kimai2_projects (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, name VARCHAR(150) NOT NULL, order_number TINYTEXT DEFAULT NULL, comment TEXT DEFAULT NULL, visible TINYINT(1) NOT NULL, budget NUMERIC(10, 2) NOT NULL, INDEX IDX_407F12069395C3F3 (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE kimai2_activities (id INT AUTO_INCREMENT NOT NULL, project_id INT DEFAULT NULL, name VARCHAR(150) NOT NULL, comment TEXT DEFAULT NULL, visible TINYINT(1) NOT NULL, INDEX IDX_8811FE1C166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE kimai2_timesheet (id INT AUTO_INCREMENT NOT NULL, user INT DEFAULT NULL, activity_id INT DEFAULT NULL, start_time DATETIME NOT NULL, end_time DATETIME DEFAULT NULL, duration INT DEFAULT NULL, description TEXT DEFAULT NULL, rate NUMERIC(10, 2) NOT NULL, INDEX IDX_4F60C6B18D93D649 (user), INDEX IDX_4F60C6B181C06096 (activity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE kimai2_invoice_templates (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(60) NOT NULL, title VARCHAR(255) NOT NULL, company VARCHAR(255) NOT NULL, address TEXT DEFAULT NULL, due_days INT NOT NULL, vat INT DEFAULT NULL, calculator VARCHAR(20) NOT NULL, number_generator VARCHAR(20) NOT NULL, renderer VARCHAR(20) NOT NULL, payment_terms TEXT DEFAULT NULL, UNIQUE INDEX UNIQ_1626CFE95E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE kimai2_user_preferences ADD CONSTRAINT FK_8D08F631A76ED395 FOREIGN KEY (user_id) REFERENCES kimai2_users (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE kimai2_projects ADD CONSTRAINT FK_407F12069395C3F3 FOREIGN KEY (customer_id) REFERENCES kimai2_customers (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE kimai2_activities ADD CONSTRAINT FK_8811FE1C166D1F9C FOREIGN KEY (project_id) REFERENCES kimai2_projects (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B18D93D649 FOREIGN KEY (user) REFERENCES kimai2_users (id)');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B181C06096 FOREIGN KEY (activity_id) REFERENCES kimai2_activities (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_invoice_templates');
$schema->dropTable('kimai2_timesheet');
$schema->dropTable('kimai2_user_preferences');
$schema->dropTable('kimai2_users');
$schema->dropTable('kimai2_activities');
$schema->dropTable('kimai2_projects');
$schema->dropTable('kimai2_customers');
}
}

View File

@@ -0,0 +1,94 @@
<?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\Index;
use Doctrine\DBAL\Schema\Schema;
/**
* Migration for FOSUserBundle
*
* Changes the table structure of "users" table and migrates from json_array type to serialized array,
* probably also fixing the higher required MariaDB version.
*
* This was fixed in earlier migrations for new installations, but it is still in here for users migrating up from a lower version.
*/
final class Version20180715160326 extends AbstractMigration
{
/**
* @var Index[]
*/
protected $indexesOld = [];
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Exception
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema): void
{
// delete all existing indexes
$indexesOld = $schema->getTable('kimai2_users')->getIndexes();
foreach ($indexesOld as $index) {
if (\in_array('name', $index->getColumns()) || \in_array('mail', $index->getColumns())) {
$this->indexesOld[] = $index;
$this->addSql('DROP INDEX ' . $index->getName() . ' ON kimai2_users');
}
}
$this->addSql('ALTER TABLE kimai2_users CHANGE name username VARCHAR(180) NOT NULL, ADD username_canonical VARCHAR(180) NOT NULL, CHANGE mail email VARCHAR(180) NOT NULL, ADD email_canonical VARCHAR(180) NOT NULL, ADD salt VARCHAR(255) DEFAULT NULL, ADD last_login DATETIME DEFAULT NULL, ADD confirmation_token VARCHAR(180) DEFAULT NULL, ADD password_requested_at DATETIME DEFAULT NULL, CHANGE password password VARCHAR(255) NOT NULL, CHANGE alias alias VARCHAR(60) DEFAULT NULL, CHANGE registration_date registration_date DATETIME DEFAULT NULL, CHANGE title title VARCHAR(50) DEFAULT NULL, CHANGE avatar avatar VARCHAR(255) DEFAULT NULL, CHANGE roles roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', CHANGE active enabled TINYINT(1) NOT NULL');
$this->addSql('UPDATE kimai2_users set username_canonical = username');
$this->addSql('UPDATE kimai2_users set email_canonical = email');
$this->addSql('UPDATE kimai2_users SET roles = \'a:1:{i:0;s:16:"ROLE_SUPER_ADMIN";}\' WHERE roles LIKE \'%ROLE_SUPER_ADMIN%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'a:1:{i:0;s:10:"ROLE_ADMIN";}\' WHERE roles LIKE \'%ROLE_ADMIN%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'a:1:{i:0;s:13:"ROLE_TEAMLEAD";}\' WHERE roles LIKE \'%ROLE_TEAMLEAD%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'a:0:{}\' WHERE roles LIKE \'%ROLE_USER%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'a:1:{i:0;s:13:"ROLE_CUSTOMER";}\' WHERE roles LIKE \'%ROLE_CUSTOMER%\'');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCE92FC23A8 ON kimai2_users (username_canonical)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCEA0D96FBF ON kimai2_users (email_canonical)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCEC05FB297 ON kimai2_users (confirmation_token)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCEF85E0677 ON kimai2_users (username)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCEE7927C74 ON kimai2_users (email)');
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Exception
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema): void
{
$indexToDelete = ['UNIQ_B9AC5BCE92FC23A8', 'UNIQ_B9AC5BCEA0D96FBF', 'UNIQ_B9AC5BCEC05FB297', 'UNIQ_B9AC5BCEF85E0677', 'UNIQ_B9AC5BCEE7927C74'];
foreach ($indexToDelete as $indexName) {
$this->addSql('DROP INDEX ' . $indexName . ' ON kimai2_users');
}
$this->addSql('ALTER TABLE kimai2_users CHANGE username name VARCHAR(60) NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE email mail VARCHAR(160) NOT NULL COLLATE utf8mb4_unicode_ci, DROP username_canonical, DROP email_canonical, DROP salt, DROP last_login, DROP confirmation_token, DROP password_requested_at, CHANGE password password VARCHAR(254) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE roles roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', CHANGE alias alias VARCHAR(60) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE registration_date registration_date DATETIME DEFAULT NULL, CHANGE title title VARCHAR(50) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE avatar avatar VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE enabled active TINYINT(1) NOT NULL');
$this->addSql('UPDATE kimai2_users SET roles = \'["ROLE_SUPER_ADMIN"]\' WHERE roles LIKE \'%ROLE_SUPER_ADMIN%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'["ROLE_ADMIN"]\' WHERE roles LIKE \'%ROLE_ADMIN%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'["ROLE_TEAMLEAD"]\' WHERE roles LIKE \'%ROLE_TEAMLEAD%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'["ROLE_USER"]\' WHERE roles LIKE \'%ROLE_USER%\'');
$this->addSql('UPDATE kimai2_users SET roles = \'["ROLE_CUSTOMER"]\' WHERE roles LIKE \'%ROLE_CUSTOMER%\'');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCE5E237E06 ON kimai2_users (name)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCE5126AC48 ON kimai2_users (mail)');
$usersTable = $schema->getTable('kimai2_users');
foreach ($this->indexesOld as $index) {
$usersTable->addIndex($index->getColumns(), $index->getName(), $index->getFlags(), $index->getOptions());
}
}
}

View File

@@ -0,0 +1,49 @@
<?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\Index;
use Doctrine\DBAL\Schema\Schema;
/**
* Migrations fot the "delete user" feature.
*
* Adds constraints to the timesheet table, so all timesheet entries will be deleted when a user is deleted.
*/
final class Version20180730044139 extends AbstractMigration
{
/**
* @var Index[]
*/
protected $indexesOld = [];
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Exception
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_timesheet DROP FOREIGN KEY FK_4F60C6B18D93D649');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B18D93D649 FOREIGN KEY (user) REFERENCES kimai2_users (id) ON DELETE CASCADE');
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Exception
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_timesheet DROP FOREIGN KEY FK_4F60C6B18D93D649');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B18D93D649 FOREIGN KEY (user) REFERENCES kimai2_users (id)');
}
}

View 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;
/**
* Added "API-token" to users table.
*/
final class Version20180805183527 extends AbstractMigration
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Exception
*/
public function up(Schema $schema): void
{
$schema->getTable('kimai2_users')->addColumn('api_token', 'string', ['length' => 255, 'notnull' => false, 'default' => null]);
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Exception
*/
public function down(Schema $schema): void
{
$schema->getTable('kimai2_users')->dropColumn('api_token');
}
}

View File

@@ -0,0 +1,35 @@
<?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;
/**
* Adding hourly_rate and fixed_rate to timesheet table
*/
final class Version20180903202256 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_timesheet ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_timesheet ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->dropColumn('hourly_rate');
$timesheet->dropColumn('fixed_rate');
}
}

View File

@@ -0,0 +1,51 @@
<?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;
/**
* Adding hourly_rate and fixed_rate to:
* - Activities
* - Projects
* - Customer
*/
final class Version20180905190737 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_activities ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_activities ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_customers ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_customers ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$customer = $schema->getTable('kimai2_customers');
$customer->dropColumn('hourly_rate');
$customer->dropColumn('fixed_rate');
$project = $schema->getTable('kimai2_projects');
$project->dropColumn('hourly_rate');
$project->dropColumn('fixed_rate');
$activity = $schema->getTable('kimai2_activities');
$activity->dropColumn('hourly_rate');
$activity->dropColumn('fixed_rate');
}
}

View File

@@ -0,0 +1,34 @@
<?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;
/**
* Changes the invoice templates table for:
* - shorter template name and proper index name
* - VAT supporting percentages
*/
final class Version20180924111853 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('UPDATE kimai2_invoice_templates SET name=SUBSTRING(name, 1, 60)');
$this->addSql('ALTER TABLE kimai2_invoice_templates CHANGE name name VARCHAR(60) NOT NULL, CHANGE vat vat DOUBLE PRECISION DEFAULT 0');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_invoice_templates CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE vat vat INT DEFAULT NULL');
}
}

View File

@@ -0,0 +1,56 @@
<?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;
/**
* Migration that adds the project column to timesheets table, to allow global activities.
* It also fixes foreign-key columns on timesheet and projects table, which are not allowed.
*/
final class Version20181031220003 extends AbstractMigration
{
public function up(Schema $schema): void
{
// project table
$this->addSql('ALTER TABLE kimai2_projects DROP FOREIGN KEY FK_407F12069395C3F3');
$this->addSql('ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL');
$this->addSql('ALTER TABLE kimai2_projects ADD CONSTRAINT FK_407F12069395C3F3 FOREIGN KEY (customer_id) REFERENCES kimai2_customers (id) ON DELETE CASCADE');
// timesheet table
$this->addSql('ALTER TABLE kimai2_timesheet ADD project_id INT DEFAULT NULL AFTER activity_id');
$this->addSql('CREATE INDEX IDX_4F60C6B1166D1F9C ON kimai2_timesheet (project_id)');
// update timesheet table and insert project_id from activity table
$this->addSql('UPDATE kimai2_timesheet SET project_id = (SELECT project_id FROM kimai2_activities WHERE id = activity_id)');
// now update the timesheet table and disallow null values for all required columns (that was a bug before)
$this->addSql('ALTER TABLE kimai2_timesheet DROP FOREIGN KEY FK_4F60C6B18D93D649');
$this->addSql('ALTER TABLE kimai2_timesheet DROP FOREIGN KEY FK_4F60C6B181C06096');
$this->addSql('ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B1166D1F9C FOREIGN KEY (project_id) REFERENCES kimai2_projects (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B18D93D649 FOREIGN KEY (user) REFERENCES kimai2_users (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B181C06096 FOREIGN KEY (activity_id) REFERENCES kimai2_activities (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// project table
$this->addSql('ALTER TABLE kimai2_projects DROP FOREIGN KEY FK_407F12069395C3F3');
$this->addSql('ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects ADD CONSTRAINT FK_407F12069395C3F3 FOREIGN KEY (customer_id) REFERENCES kimai2_customers (id) ON DELETE CASCADE');
// timesheet table
$this->addSql('ALTER TABLE kimai2_timesheet DROP FOREIGN KEY FK_4F60C6B1166D1F9C');
$this->addSql('DROP INDEX IDX_4F60C6B1166D1F9C ON kimai2_timesheet');
$this->addSql('ALTER TABLE kimai2_timesheet DROP project_id, CHANGE user user INT DEFAULT NULL, CHANGE activity_id activity_id INT DEFAULT NULL');
}
}

View File

@@ -0,0 +1,33 @@
<?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;
/**
* Adds the exported column to the timesheet table
*
* @version 0.8
*/
final class Version20190124004014 extends AbstractMigration
{
public function up(Schema $schema): void
{
$schema->getTable('kimai2_timesheet')->addColumn('exported', 'boolean', ['notnull' => true, 'default' => false]);
}
public function down(Schema $schema): void
{
$schema->getTable('kimai2_timesheet')->dropColumn('exported');
}
}

View File

@@ -0,0 +1,38 @@
<?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;
/**
* Adds the timezone column to the timesheet table
* See https://github.com/kimai/kimai/pull/372 for further information.
*
* @version 0.8
*/
final class Version20190201150324 extends AbstractMigration
{
public function up(Schema $schema): void
{
$timezone = date_default_timezone_get();
$this->addSql('ALTER TABLE kimai2_timesheet ADD timezone VARCHAR(64) NOT NULL');
$this->addSql("UPDATE kimai2_timesheet SET timezone = '" . $timezone . "'");
}
public function down(Schema $schema): void
{
$schema->getTable('kimai2_timesheet')->dropColumn('timezone');
}
}

View File

@@ -0,0 +1,35 @@
<?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;
/**
* Cleanup the user_preferences table from old configs.
*
* @version 0.9
*/
final class Version20190219200020 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('DELETE FROM kimai2_user_preferences WHERE name = "theme.fixed_layout"');
$this->addSql('DELETE FROM kimai2_user_preferences WHERE name = "theme.boxed_layout"');
$this->addSql('DELETE FROM kimai2_user_preferences WHERE name = "theme.mini_sidebar"');
}
public function down(Schema $schema): void
{
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,41 @@
<?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;
/**
* - rename mail to email in customer table
* - converts all decimal to float values, as decimals are treated as string in PHP:
* https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#decimal
*
* @version 0.9
*/
final class Version20190305152308 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_activities CHANGE fixed_rate fixed_rate DOUBLE PRECISION DEFAULT NULL, CHANGE hourly_rate hourly_rate DOUBLE PRECISION DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_customers CHANGE mail email VARCHAR(255) DEFAULT NULL, CHANGE fixed_rate fixed_rate DOUBLE PRECISION DEFAULT NULL, CHANGE hourly_rate hourly_rate DOUBLE PRECISION DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects CHANGE budget budget DOUBLE PRECISION NOT NULL, CHANGE fixed_rate fixed_rate DOUBLE PRECISION DEFAULT NULL, CHANGE hourly_rate hourly_rate DOUBLE PRECISION DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_timesheet CHANGE rate rate DOUBLE PRECISION NOT NULL, CHANGE fixed_rate fixed_rate DOUBLE PRECISION DEFAULT NULL, CHANGE hourly_rate hourly_rate DOUBLE PRECISION DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_activities CHANGE fixed_rate fixed_rate NUMERIC(10, 2) DEFAULT NULL, CHANGE hourly_rate hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_customers CHANGE email mail VARCHAR(255) DEFAULT NULL, CHANGE fixed_rate fixed_rate NUMERIC(10, 2) DEFAULT NULL, CHANGE hourly_rate hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects CHANGE budget budget NUMERIC(10, 2) NOT NULL, CHANGE fixed_rate fixed_rate NUMERIC(10, 2) DEFAULT NULL, CHANGE hourly_rate hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_timesheet CHANGE rate rate NUMERIC(10, 2) NOT NULL, CHANGE fixed_rate fixed_rate NUMERIC(10, 2) DEFAULT NULL, CHANGE hourly_rate hourly_rate NUMERIC(10, 2) DEFAULT NULL');
}
}

View File

@@ -0,0 +1,38 @@
<?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;
/**
* Create the system configuration table.
*
* @version 0.9
*/
final class Version20190321181243 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create system configuration table';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE kimai2_configuration (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL, value VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_1C5D63D85E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_configuration');
}
}

View 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;
/**
* Creates the color columns on: customer, project, activity.
*
* @version 1.0
*/
final class Version20190502161758 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the color columns on: customer, project, activity';
}
public function up(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->addColumn('color', 'string', ['length' => 7, 'notnull' => false, 'default' => null]);
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('color', 'string', ['length' => 7, 'notnull' => false, 'default' => null]);
$activities = $schema->getTable('kimai2_activities');
$activities->addColumn('color', 'string', ['length' => 7, 'notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->dropColumn('color');
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('color');
$activities = $schema->getTable('kimai2_activities');
$activities->dropColumn('color');
}
}

View File

@@ -0,0 +1,45 @@
<?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;
/**
* New feature: tagging of timesheet records
*
* @version 1.0
*/
class Version20190510205245 extends AbstractMigration
{
public function up(Schema $schema): void
{
$timesheetTags = $schema->createTable('kimai2_timesheet_tags');
$timesheetTags->addColumn('timesheet_id', 'integer', ['length' => 11, 'notnull' => true]);
$timesheetTags->addColumn('tag_id', 'integer', ['length' => 11, 'notnull' => true]);
$timesheetTags->addIndex(['timesheet_id'], 'IDX_E3284EFEABDD46BE');
$timesheetTags->addIndex(['tag_id'], 'IDX_E3284EFEBAD26311');
$timesheetTags->setPrimaryKey(['timesheet_id', 'tag_id']);
$tags = $schema->createTable('kimai2_tags');
$tags->addColumn('id', 'integer', ['length' => 11, 'autoincrement' => true, 'notnull' => true]);
$tags->addColumn('name', 'string', ['length' => 100, 'notnull' => true]);
$tags->addUniqueIndex(['name'], 'UNIQ_27CAF54C5E237E06');
$tags->setPrimaryKey(['id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_timesheet_tags');
$schema->dropTable('kimai2_tags');
}
}

View File

@@ -0,0 +1,57 @@
<?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;
/**
* Creates the budget columns on: customer, project, activity.
*
* @version 1.0
*/
final class Version20190605171157 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the budget columns on: customer, project, activity';
}
public function up(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->addColumn('time_budget', 'integer', ['notnull' => true, 'default' => 0]);
$customers->addColumn('budget', 'float', ['notnull' => true, 'default' => 0]);
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('time_budget', 'integer', ['notnull' => true, 'default' => 0]);
$projects->getColumn('budget')->setDefault(0);
$activities = $schema->getTable('kimai2_activities');
$activities->addColumn('time_budget', 'integer', ['notnull' => true, 'default' => 0]);
$activities->addColumn('budget', 'float', ['notnull' => true, 'default' => 0]);
}
public function down(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->dropColumn('time_budget');
$customers->dropColumn('budget');
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('time_budget');
$activities = $schema->getTable('kimai2_activities');
$activities->dropColumn('time_budget');
$activities->dropColumn('budget');
}
}

View File

@@ -0,0 +1,83 @@
<?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;
/**
* Creates meta tables to store custom fields for entities
*
* @version 1.0
*/
final class Version20190617100845 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates meta tables to store custom fields for entities';
}
public function up(Schema $schema): void
{
$timesheetMeta = $schema->createTable('kimai2_timesheet_meta');
$timesheetMeta->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$timesheetMeta->addColumn('timesheet_id', 'integer', ['notnull' => true]);
$timesheetMeta->addColumn('name', 'string', ['notnull' => true, 'length' => 50]);
$timesheetMeta->addColumn('value', 'string', ['notnull' => false, 'length' => 255]);
$timesheetMeta->addColumn('visible', 'boolean', ['notnull' => false, 'default' => false]);
$timesheetMeta->setPrimaryKey(['id']);
$timesheetMeta->addIndex(['timesheet_id'], 'IDX_CB606CBAABDD46BE');
$timesheetMeta->addUniqueIndex(['timesheet_id', 'name'], 'UNIQ_CB606CBAABDD46BE5E237E06');
$timesheetMeta->addForeignKeyConstraint('kimai2_timesheet', ['timesheet_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_CB606CBAABDD46BE');
$customerMeta = $schema->createTable('kimai2_customers_meta');
$customerMeta->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$customerMeta->addColumn('customer_id', 'integer', ['notnull' => true]);
$customerMeta->addColumn('name', 'string', ['notnull' => true, 'length' => 50]);
$customerMeta->addColumn('value', 'string', ['notnull' => false, 'length' => 255]);
$customerMeta->addColumn('visible', 'boolean', ['notnull' => false, 'default' => false]);
$customerMeta->setPrimaryKey(['id']);
$customerMeta->addIndex(['customer_id'], 'IDX_A48A760F9395C3F3');
$customerMeta->addUniqueIndex(['customer_id', 'name'], 'UNIQ_A48A760F9395C3F35E237E06');
$customerMeta->addForeignKeyConstraint('kimai2_customers', ['customer_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_A48A760F9395C3F3');
$projectMeta = $schema->createTable('kimai2_projects_meta');
$projectMeta->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$projectMeta->addColumn('project_id', 'integer', ['notnull' => true]);
$projectMeta->addColumn('name', 'string', ['notnull' => true, 'length' => 50]);
$projectMeta->addColumn('value', 'string', ['notnull' => false, 'length' => 255]);
$projectMeta->addColumn('visible', 'boolean', ['notnull' => false, 'default' => false]);
$projectMeta->setPrimaryKey(['id']);
$projectMeta->addIndex(['project_id'], 'IDX_50536EF2166D1F9C');
$projectMeta->addUniqueIndex(['project_id', 'name'], 'UNIQ_50536EF2166D1F9C5E237E06');
$projectMeta->addForeignKeyConstraint('kimai2_projects', ['project_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_50536EF2166D1F9C');
$activityMeta = $schema->createTable('kimai2_activities_meta');
$activityMeta->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$activityMeta->addColumn('activity_id', 'integer', ['notnull' => true]);
$activityMeta->addColumn('name', 'string', ['notnull' => true, 'length' => 50]);
$activityMeta->addColumn('value', 'string', ['notnull' => false, 'length' => 255]);
$activityMeta->addColumn('visible', 'boolean', ['notnull' => false, 'default' => false]);
$activityMeta->setPrimaryKey(['id']);
$activityMeta->addIndex(['activity_id'], 'IDX_A7C0A43D81C06096');
$activityMeta->addUniqueIndex(['activity_id', 'name'], 'UNIQ_A7C0A43D81C060965E237E06');
$activityMeta->addForeignKeyConstraint('kimai2_activities', ['activity_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_A7C0A43D81C06096');
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_timesheet_meta');
$schema->dropTable('kimai2_customers_meta');
$schema->dropTable('kimai2_projects_meta');
$schema->dropTable('kimai2_activities_meta');
}
}

View File

@@ -0,0 +1,54 @@
<?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;
/**
* Fix meta-table definitions
*
* @version 1.1
*/
final class Version20190706224211 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fix meta-table definitions';
}
public function up(Schema $schema): void
{
$timesheetMeta = $schema->getTable('kimai2_timesheet_meta');
$timesheetMeta->changeColumn('visible', ['notnull' => true, 'default' => false]);
$timesheetMeta->changeColumn('timesheet_id', ['notnull' => true]);
$projectMeta = $schema->getTable('kimai2_projects_meta');
$projectMeta->changeColumn('visible', ['notnull' => true, 'default' => false]);
$projectMeta->changeColumn('project_id', ['notnull' => true]);
$customerMeta = $schema->getTable('kimai2_customers_meta');
$customerMeta->changeColumn('visible', ['notnull' => true, 'default' => false]);
$customerMeta->changeColumn('customer_id', ['notnull' => true]);
$activityMeta = $schema->getTable('kimai2_activities_meta');
$activityMeta->changeColumn('visible', ['notnull' => true, 'default' => false]);
$activityMeta->changeColumn('activity_id', ['notnull' => true]);
}
public function down(Schema $schema): void
{
// the columns above were created incorrect in migration Version20190617100845 for upgraded systems
// that's why there are no equivalent changes in down()
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,85 @@
<?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;
/**
* Creates several indices to improve speed for default queries.
*
* @version 1.1
*/
final class Version20190706224219 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates several indices to improve speed for default queries.';
}
public function up(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->addIndex(['user', 'start_time'], 'IDX_4F60C6B18D93D649502DF587');
$timesheet->addIndex(['start_time'], 'IDX_4F60C6B1502DF587');
$timesheet->addIndex(['start_time', 'end_time'], 'IDX_4F60C6B1502DF58741561401');
$timesheet->addIndex(['start_time', 'end_time', 'user'], 'IDX_4F60C6B1502DF587415614018D93D649');
$activity = $schema->getTable('kimai2_activities');
$name = $activity->getColumn('name');
if ($name->getLength() !== 150) {
$name->setLength(150);
}
$activity->addIndex(['visible', 'project_id'], 'IDX_8811FE1C7AB0E859166D1F9C');
$activity->addIndex(['visible', 'project_id', 'name'], 'IDX_8811FE1C7AB0E859166D1F9C5E237E06');
$activity->addIndex(['visible', 'name'], 'IDX_8811FE1C7AB0E8595E237E06');
$project = $schema->getTable('kimai2_projects');
$name = $project->getColumn('name');
if ($name->getLength() !== 150) {
$name->setLength(150);
}
$project->addIndex(['customer_id', 'visible', 'name'], 'IDX_407F12069395C3F37AB0E8595E237E06');
$project->addIndex(['customer_id', 'visible', 'id'], 'IDX_407F12069395C3F37AB0E859BF396750');
$customer = $schema->getTable('kimai2_customers');
$name = $customer->getColumn('name');
if ($name->getLength() !== 150) {
$name->setLength(150);
}
$customer->addIndex(['visible'], 'IDX_5A9760447AB0E859');
}
public function down(Schema $schema): void
{
$activity = $schema->getTable('kimai2_activities');
$activity->dropIndex('IDX_8811FE1C7AB0E859166D1F9C');
$activity->dropIndex('IDX_8811FE1C7AB0E859166D1F9C5E237E06');
$activity->dropIndex('IDX_8811FE1C7AB0E8595E237E06');
$activity->getColumn('name')->setLength(255);
$customer = $schema->getTable('kimai2_customers');
$customer->dropIndex('IDX_5A9760447AB0E859');
$customer->getColumn('name')->setLength(255);
$project = $schema->getTable('kimai2_projects');
$project->dropIndex('IDX_407F12069395C3F37AB0E8595E237E06');
$project->dropIndex('IDX_407F12069395C3F37AB0E859BF396750');
$project->getColumn('name')->setLength(255);
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->dropIndex('IDX_4F60C6B18D93D649502DF587');
$timesheet->dropIndex('IDX_4F60C6B1502DF587');
$timesheet->dropIndex('IDX_4F60C6B1502DF587415614018D93D649');
$timesheet->dropIndex('idx_4f60c6b1502df58741561401');
}
}

View File

@@ -0,0 +1,45 @@
<?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;
/**
* Adds missing foreign keys on tag table.
*
* @version 1.2
*/
final class Version20190729162655 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds missing foreign keys on tag table';
}
public function up(Schema $schema): void
{
$timesheetTags = $schema->getTable('kimai2_timesheet_tags');
if (!$timesheetTags->hasForeignKey('FK_732EECA9ABDD46BE')) {
$timesheetTags->addForeignKeyConstraint('kimai2_timesheet', ['timesheet_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_732EECA9ABDD46BE');
}
if (!$timesheetTags->hasForeignKey('FK_732EECA9BAD26311')) {
$timesheetTags->addForeignKeyConstraint('kimai2_tags', ['tag_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_732EECA9BAD26311');
}
}
public function down(Schema $schema): void
{
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,68 @@
<?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;
/**
* Creates user team and permission tables.
*
* @version 1.2
*/
final class Version20190730123324 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates user team and permission tables';
}
public function up(Schema $schema): void
{
$teams = $schema->createTable('kimai2_teams');
$teams->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$teams->addColumn('name', 'string', ['notnull' => true, 'length' => 100]);
$teams->addColumn('teamlead_id', 'integer', ['length' => 11, 'notnull' => true]);
$teams->setPrimaryKey(['id']);
$teams->addUniqueIndex(['name'], 'UNIQ_3BEDDC7F5E237E06');
$teams->addForeignKeyConstraint('kimai2_users', ['teamlead_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_3BEDDC7F8F7DE5D7');
$userTeams = $schema->createTable('kimai2_users_teams');
$userTeams->addColumn('user_id', 'integer', ['length' => 11, 'notnull' => true]);
$userTeams->addColumn('team_id', 'integer', ['length' => 11, 'notnull' => true]);
$userTeams->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_B5E92CF8A76ED395');
$userTeams->addForeignKeyConstraint('kimai2_teams', ['team_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_B5E92CF8296CD8AE');
$userTeams->setPrimaryKey(['user_id', 'team_id']);
$customerTeams = $schema->createTable('kimai2_customers_teams');
$customerTeams->addColumn('customer_id', 'integer', ['length' => 11, 'notnull' => true]);
$customerTeams->addColumn('team_id', 'integer', ['length' => 11, 'notnull' => true]);
$customerTeams->addForeignKeyConstraint('kimai2_customers', ['customer_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_50BD83889395C3F3');
$customerTeams->addForeignKeyConstraint('kimai2_teams', ['team_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_50BD8388296CD8AE');
$customerTeams->setPrimaryKey(['customer_id', 'team_id']);
$projectTeams = $schema->createTable('kimai2_projects_teams');
$projectTeams->addColumn('project_id', 'integer', ['length' => 11, 'notnull' => true]);
$projectTeams->addColumn('team_id', 'integer', ['length' => 11, 'notnull' => true]);
$projectTeams->addForeignKeyConstraint('kimai2_projects', ['project_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_9345D431166D1F9C');
$projectTeams->addForeignKeyConstraint('kimai2_teams', ['team_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_9345D431296CD8AE');
$projectTeams->setPrimaryKey(['project_id', 'team_id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_projects_teams');
$schema->dropTable('kimai2_customers_teams');
$schema->dropTable('kimai2_users_teams');
$schema->dropTable('kimai2_teams');
}
}

View File

@@ -0,0 +1,63 @@
<?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;
/**
* Changing column sizes to prevent index length errors.
*
* @version 1.2
*/
final class Version20190813162649 extends AbstractMigration
{
public function getDescription(): string
{
return 'Changing column sizes to prevent index length errors';
}
public function up(Schema $schema): void
{
$activity = $schema->getTable('kimai2_activities');
$name = $activity->getColumn('name');
if ($name->getLength() !== 150) {
$name->setLength(150);
}
$project = $schema->getTable('kimai2_projects');
$name = $project->getColumn('name');
if ($name->getLength() !== 150) {
$name->setLength(150);
}
$customer = $schema->getTable('kimai2_customers');
$name = $customer->getColumn('name');
if ($name->getLength() !== 150) {
$name->setLength(150);
}
$customer->getColumn('timezone')->setLength(64);
}
public function down(Schema $schema): void
{
$activity = $schema->getTable('kimai2_activities');
$activity->getColumn('name')->setLength(255);
$project = $schema->getTable('kimai2_projects');
$project->getColumn('name')->setLength(255);
$customer = $schema->getTable('kimai2_customers');
$customer->getColumn('name')->setLength(255);
$customer->getColumn('timezone')->setLength(255);
}
}

View File

@@ -0,0 +1,40 @@
<?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;
/**
* Adds the order_date column to the projects table.
*
* @version 1.5
*/
final class Version20191024100951 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the order_date column to the projects table';
}
public function up(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('order_date', 'datetime', ['notnull' => false]);
}
public function down(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('order_date');
}
}

View 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;
/**
* Adds the user roles and role permissions table
*
* @version 1.6
*/
final class Version20191108151534 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the user roles and role permissions table';
}
public function up(Schema $schema): void
{
$roles = $schema->createTable('kimai2_roles');
$roles->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$roles->addColumn('name', 'string', ['notnull' => true, 'length' => 50]);
$roles->setPrimaryKey(['id']);
$roles->addUniqueIndex(['name'], 'roles_name');
$rolePermissions = $schema->createTable('kimai2_roles_permissions');
$rolePermissions->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$rolePermissions->addColumn('role_id', 'integer', ['length' => 11, 'notnull' => true]);
$rolePermissions->addColumn('permission', 'string', ['notnull' => true, 'length' => 50]);
$rolePermissions->addColumn('allowed', 'boolean', ['notnull' => true, 'default' => false]);
$rolePermissions->setPrimaryKey(['id']);
$rolePermissions->addUniqueIndex(['role_id', 'permission'], 'role_permission');
$rolePermissions->addForeignKeyConstraint('kimai2_roles', ['role_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_D263A3B8D60322AC');
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_roles_permissions');
$schema->dropTable('kimai2_roles');
}
}

View File

@@ -0,0 +1,50 @@
<?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;
/**
* Fixes foreign keys on tag table.
*
* @version 1.6
*/
final class Version20191113132640 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fixes foreign keys on tag table';
}
public function up(Schema $schema): void
{
$timesheetTags = $schema->getTable('kimai2_timesheet_tags');
if ($timesheetTags->hasForeignKey('FK_732EECA9ABDD46BE')) {
$timesheetTags->removeForeignKey('FK_732EECA9ABDD46BE');
}
$timesheetTags->addForeignKeyConstraint('kimai2_timesheet', ['timesheet_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_732EECA9ABDD46BE');
if ($timesheetTags->hasForeignKey('FK_732EECA9BAD26311')) {
$timesheetTags->removeForeignKey('FK_732EECA9BAD26311');
}
$timesheetTags->addForeignKeyConstraint('kimai2_tags', ['tag_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_732EECA9BAD26311');
$this->preventEmptyMigrationWarning();
}
public function down(Schema $schema): void
{
$this->preventEmptyMigrationWarning();
}
}

View 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;
/**
* New Vat ID columns and invoice template improvements
*
* @version 1.6
*/
final class Version20191116110124 extends AbstractMigration
{
public function getDescription(): string
{
return 'New Vat ID columns and invoice template improvements';
}
public function up(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->addColumn('vat_id', 'string', ['length' => 50, 'notnull' => false]);
$invoiceTemplates = $schema->getTable('kimai2_invoice_templates');
$invoiceTemplates->addColumn('vat_id', 'string', ['length' => 50, 'notnull' => false, 'default' => null]);
$invoiceTemplates->addColumn('contact', 'text', ['notnull' => false, 'default' => null]);
$invoiceTemplates->addColumn('payment_details', 'text', ['notnull' => false, 'default' => null]);
$this->addSql("UPDATE kimai2_invoice_templates SET renderer = 'default' WHERE renderer IN ('export', 'open-spreadsheet', 'spreadsheet')");
}
public function down(Schema $schema): void
{
$invoiceTemplates = $schema->getTable('kimai2_invoice_templates');
$invoiceTemplates->dropColumn('payment_details');
$invoiceTemplates->dropColumn('contact');
$invoiceTemplates->dropColumn('vat_id');
$customers = $schema->getTable('kimai2_customers');
$customers->dropColumn('vat_id');
}
}

View File

@@ -0,0 +1,44 @@
<?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;
/**
* Adds project_start and project_end to projects tables
*
* @version 1.7
*/
final class Version20191204120823 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds project_start and project_end to projects tables';
}
public function up(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('start', 'datetime', ['notnull' => false]);
$projects->addColumn('end', 'datetime', ['notnull' => false]);
$projects->addColumn('timezone', 'string', ['notnull' => false, 'length' => 64]);
}
public function down(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('timezone');
$projects->dropColumn('end');
$projects->dropColumn('start');
}
}

View File

@@ -0,0 +1,65 @@
<?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;
/**
* Creates comment tables for customers and projects
*
* @version 1.7
*/
final class Version20200109102138 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates comment tables for customers and projects';
}
public function up(Schema $schema): void
{
$customerComment = $schema->createTable('kimai2_customers_comments');
$customerComment->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$customerComment->addColumn('customer_id', 'integer', ['notnull' => true]);
$customerComment->addColumn('message', 'text', ['notnull' => true]);
$customerComment->addColumn('created_by_id', 'integer', ['notnull' => true]);
$customerComment->addColumn('created_at', 'datetime', ['notnull' => true]);
$customerComment->addColumn('pinned', 'boolean', ['notnull' => true, 'default' => false]);
$customerComment->setPrimaryKey(['id']);
$customerComment->addIndex(['customer_id'], 'IDX_A5B142D99395C3F3');
$customerComment->addForeignKeyConstraint('kimai2_customers', ['customer_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_A5B142D99395C3F3');
$customerComment->addForeignKeyConstraint('kimai2_users', ['created_by_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_A5B142D9B03A8386');
$projectComment = $schema->createTable('kimai2_projects_comments');
$projectComment->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$projectComment->addColumn('project_id', 'integer', ['notnull' => true]);
$projectComment->addColumn('message', 'text', ['notnull' => true]);
$projectComment->addColumn('created_by_id', 'integer', ['notnull' => true]);
$projectComment->addColumn('created_at', 'datetime', ['notnull' => true]);
$projectComment->addColumn('pinned', 'boolean', ['notnull' => true, 'default' => false]);
$projectComment->setPrimaryKey(['id']);
$projectComment->addIndex(['project_id'], 'IDX_29A23638166D1F9C');
$projectComment->addForeignKeyConstraint('kimai2_projects', ['project_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_29A23638166D1F9C');
$projectComment->addForeignKeyConstraint('kimai2_users', ['created_by_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_29A23638B03A8386');
$this->addSql('DELETE from kimai2_configuration WHERE name = "theme.select_type"');
$this->addSql('DELETE from kimai2_roles_permissions WHERE permission = "delete_other_profile"');
$this->addSql('DELETE from kimai2_roles_permissions WHERE permission = "delete_own_profile"');
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_projects_comments');
$schema->dropTable('kimai2_customers_comments');
}
}

View File

@@ -0,0 +1,40 @@
<?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;
/**
* Adds a column to the user table to identify authenticator
*
* @version 1.8
*/
final class Version20200125123942 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds a column to the user table to identify authenticator';
}
public function up(Schema $schema): void
{
$users = $schema->getTable('kimai2_users');
$users->addColumn('auth', 'string', ['notnull' => false, 'length' => 20]);
}
public function down(Schema $schema): void
{
$users = $schema->getTable('kimai2_users');
$users->dropColumn('auth');
}
}

View File

@@ -0,0 +1,42 @@
<?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;
/**
* Adds language and decimal_duration column to invoice template table
*
* @version 1.8
*/
final class Version20200204124425 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds language and decimal_duration column to invoice template table';
}
public function up(Schema $schema): void
{
$invoiceTemplates = $schema->getTable('kimai2_invoice_templates');
$invoiceTemplates->addColumn('decimal_duration', 'boolean', ['notnull' => true, 'default' => false]);
$invoiceTemplates->addColumn('language', 'string', ['notnull' => false, 'length' => 6]);
}
public function down(Schema $schema): void
{
$invoiceTemplates = $schema->getTable('kimai2_invoice_templates');
$invoiceTemplates->dropColumn('language');
$invoiceTemplates->dropColumn('decimal_duration');
}
}

View File

@@ -0,0 +1,71 @@
<?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;
/**
* Adds the rate table, which allows to define user specific rate rules
*
* @version 1.8
*/
final class Version20200205115243 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the rate table, which allows to define user specific rate rules';
}
public function up(Schema $schema): void
{
$customerRates = $schema->createTable('kimai2_customers_rates');
$customerRates->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$customerRates->addColumn('user_id', 'integer', ['length' => 11, 'notnull' => false]);
$customerRates->addColumn('customer_id', 'integer', ['length' => 11, 'notnull' => false]);
$customerRates->addColumn('rate', 'float', ['notnull' => true]);
$customerRates->addColumn('fixed', 'boolean', ['notnull' => true]);
$customerRates->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_82AB0AECA76ED395');
$customerRates->addForeignKeyConstraint('kimai2_customers', ['customer_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_82AB0AEC9395C3F3');
$customerRates->addUniqueIndex(['user_id', 'customer_id'], 'UNIQ_82AB0AECA76ED3959395C3F3');
$customerRates->setPrimaryKey(['id']);
$projectRates = $schema->createTable('kimai2_projects_rates');
$projectRates->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$projectRates->addColumn('user_id', 'integer', ['length' => 11, 'notnull' => false]);
$projectRates->addColumn('project_id', 'integer', ['length' => 11, 'notnull' => false]);
$projectRates->addColumn('rate', 'float', ['notnull' => true]);
$projectRates->addColumn('fixed', 'boolean', ['notnull' => true]);
$projectRates->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_41535D55A76ED395');
$projectRates->addForeignKeyConstraint('kimai2_projects', ['project_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_41535D55166D1F9C');
$projectRates->addUniqueIndex(['user_id', 'project_id'], 'UNIQ_41535D55A76ED395166D1F9C');
$projectRates->setPrimaryKey(['id']);
$activityRates = $schema->createTable('kimai2_activities_rates');
$activityRates->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$activityRates->addColumn('user_id', 'integer', ['length' => 11, 'notnull' => false]);
$activityRates->addColumn('activity_id', 'integer', ['length' => 11, 'notnull' => false]);
$activityRates->addColumn('rate', 'float', ['notnull' => true]);
$activityRates->addColumn('fixed', 'boolean', ['notnull' => true]);
$activityRates->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_4A7F11BEA76ED395');
$activityRates->addForeignKeyConstraint('kimai2_activities', ['activity_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_4A7F11BE81C06096');
$activityRates->addUniqueIndex(['user_id', 'activity_id'], 'UNIQ_4A7F11BEA76ED39581C06096');
$activityRates->setPrimaryKey(['id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_activities_rates');
$schema->dropTable('kimai2_projects_rates');
$schema->dropTable('kimai2_customers_rates');
}
}

View File

@@ -0,0 +1,73 @@
<?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\ParameterType;
use Doctrine\DBAL\Schema\Schema;
/**
* Migrates the data from entity tables to user specific rate tables
*
* @version 1.8
*/
final class Version20200205115244 extends AbstractMigration
{
public function getDescription(): string
{
return 'Migrates the data from entity tables to user specific rate tables';
}
public function up(Schema $schema): void
{
$migrates = [
['kimai2_activities', 'activity_id', 'kimai2_activities_rates'],
['kimai2_projects', 'project_id', 'kimai2_projects_rates'],
['kimai2_customers', 'customer_id', 'kimai2_customers_rates'],
];
foreach ($migrates as $migrateOpts) {
$tableName = $migrateOpts[0];
$fieldName = $migrateOpts[1];
$targetTable = $migrateOpts[2];
$rules = $this->connection->prepare(
'SELECT id, fixed_rate, hourly_rate FROM ' . $tableName . ' WHERE fixed_rate IS NOT NULL OR hourly_rate IS NOT NULL'
);
$result = $rules->executeQuery();
foreach ($result->fetchAllAssociative() as $rateRule) {
$isFixed = $rateRule['fixed_rate'] !== null;
$rate = $rateRule['fixed_rate'] ?? $rateRule['hourly_rate'];
$params = ['user_id' => null, $fieldName => $rateRule['id'], 'rate' => $rate, 'fixed' => $isFixed];
$this->connection->insert($targetTable, $params, ['fixed' => ParameterType::BOOLEAN]);
}
}
$schema->getTable('kimai2_customers')->dropColumn('fixed_rate')->dropColumn('hourly_rate');
$schema->getTable('kimai2_projects')->dropColumn('fixed_rate')->dropColumn('hourly_rate');
$schema->getTable('kimai2_activities')->dropColumn('fixed_rate')->dropColumn('hourly_rate');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_customers ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_customers ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_projects ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_activities ADD COLUMN fixed_rate NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE kimai2_activities ADD COLUMN hourly_rate NUMERIC(10, 2) DEFAULT NULL');
}
}

View File

@@ -0,0 +1,55 @@
<?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.9
*/
final class Version20200308171950 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create the invoice table';
}
public function up(Schema $schema): void
{
$invoices = $schema->createTable('kimai2_invoices');
$invoices->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$invoices->addColumn('invoice_number', 'string', ['length' => 50, 'notnull' => true]);
$invoices->addColumn('customer_id', 'integer', ['length' => 11, 'notnull' => true]);
$invoices->addColumn('user_id', 'integer', ['length' => 11, 'notnull' => true]);
$invoices->addColumn('created_at', 'datetime', ['notnull' => true]);
$invoices->addColumn('timezone', 'string', ['length' => 64, 'notnull' => true]);
$invoices->addColumn('total', 'float', ['notnull' => true]);
$invoices->addColumn('tax', 'float', ['notnull' => true]);
$invoices->addColumn('currency', 'string', ['length' => 3, 'notnull' => true]);
$invoices->addColumn('status', 'string', ['length' => 20, 'notnull' => true]);
$invoices->addColumn('due_days', 'integer', ['length' => 11, 'notnull' => true]);
$invoices->addColumn('vat', 'float', ['notnull' => true]);
$invoices->addColumn('invoice_filename', 'string', ['length' => 100, 'notnull' => true]);
$invoices->addUniqueIndex(['invoice_number'], 'UNIQ_76C38E372DA68207');
$invoices->addUniqueIndex(['invoice_filename'], 'UNIQ_76C38E372323B33D');
$invoices->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_76C38E37A76ED395');
$invoices->addForeignKeyConstraint('kimai2_customers', ['customer_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_76C38E379395C3F3');
$invoices->setPrimaryKey(['id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_invoices');
}
}

View File

@@ -0,0 +1,42 @@
<?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.9
*/
final class Version20200323163038 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the internal_rate column to all rate tables';
}
public function up(Schema $schema): void
{
$schema->getTable('kimai2_activities_rates')->addColumn('internal_rate', 'float', ['notnull' => false]);
$schema->getTable('kimai2_projects_rates')->addColumn('internal_rate', 'float', ['notnull' => false]);
$schema->getTable('kimai2_customers_rates')->addColumn('internal_rate', 'float', ['notnull' => false]);
$schema->getTable('kimai2_timesheet')->addColumn('internal_rate', 'float', ['notnull' => false]);
}
public function down(Schema $schema): void
{
$schema->getTable('kimai2_timesheet')->dropColumn('internal_rate');
$schema->getTable('kimai2_activities_rates')->dropColumn('internal_rate');
$schema->getTable('kimai2_projects_rates')->dropColumn('internal_rate');
$schema->getTable('kimai2_customers_rates')->dropColumn('internal_rate');
}
}

View File

@@ -0,0 +1,36 @@
<?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.9
*/
final class Version20200323163039 extends AbstractMigration
{
public function getDescription(): string
{
return 'Set internal-rate from rate for existing timesheet entries';
}
public function up(Schema $schema): void
{
$this->addSql('UPDATE kimai2_timesheet SET internal_rate = rate');
}
public function down(Schema $schema): void
{
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,38 @@
<?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.9
*/
final class Version20200413133226 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add color for tags';
}
public function up(Schema $schema): void
{
$tags = $schema->getTable('kimai2_tags');
$tags->addColumn('color', 'string', ['length' => 7, 'notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$tags = $schema->getTable('kimai2_tags');
$tags->dropColumn('color');
}
}

View File

@@ -0,0 +1,41 @@
<?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.10
*/
final class Version20200524142042 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add table to store sessions in database';
}
public function up(Schema $schema): void
{
$sessions = $schema->createTable('kimai2_sessions');
$sessions->addColumn('id', 'string', ['length' => 128, 'notnull' => true]);
$sessions->addColumn('data', 'blob', ['length' => 65535, 'notnull' => true]);
$sessions->addColumn('time', 'integer', ['unsigned' => true, 'notnull' => true]);
$sessions->addColumn('lifetime', 'integer', ['unsigned' => true, 'notnull' => true]);
$sessions->setPrimaryKey(['id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_sessions');
}
}

View File

@@ -0,0 +1,48 @@
<?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.10
*/
final class Version20200705152310 extends AbstractMigration
{
public function getDescription(): string
{
return 'Updated invoice and added timesheet columns';
}
public function up(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_invoices');
$invoices->getColumn('invoice_filename')->setLength(150);
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->addColumn('billable', 'boolean', ['notnull' => false, 'default' => true]);
$timesheet->addColumn('category', 'string', ['length' => 10, 'notnull' => true, 'default' => 'work']);
$timesheet->addColumn('modified_at', 'datetime', ['notnull' => false]);
}
public function down(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_invoices');
$invoices->getColumn('invoice_filename')->setLength(100);
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->dropColumn('billable');
$timesheet->dropColumn('category');
$timesheet->dropColumn('modified_at');
}
}

View File

@@ -0,0 +1,43 @@
<?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;
/**
* Creates the activity teams table.
*
* @version 1.10
*/
final class Version20200725213424 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the activity teams table';
}
public function up(Schema $schema): void
{
$activityTeams = $schema->createTable('kimai2_activities_teams');
$activityTeams->addColumn('activity_id', 'integer', ['length' => 11, 'notnull' => true]);
$activityTeams->addColumn('team_id', 'integer', ['length' => 11, 'notnull' => true]);
$activityTeams->addForeignKeyConstraint('kimai2_activities', ['activity_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_986998DA81C06096');
$activityTeams->addForeignKeyConstraint('kimai2_teams', ['team_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_986998DA296CD8AE');
$activityTeams->setPrimaryKey(['activity_id', 'team_id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_activities_teams');
}
}

View 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;
/**
* Create the bookmark table, to store default search settings.
*
* @version 1.14
*/
final class Version20210316224358 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the bookmark table';
}
public function up(Schema $schema): void
{
$bookmarks = $schema->createTable('kimai2_bookmarks');
$bookmarks->addColumn('id', 'integer', ['length' => 11, 'autoincrement' => true, 'notnull' => true]);
$bookmarks->addColumn('user_id', 'integer', ['length' => 11, 'notnull' => true]);
$bookmarks->addColumn('type', 'string', ['length' => 20, 'notnull' => true]);
$bookmarks->addColumn('name', 'string', ['length' => 50, 'notnull' => true]);
$bookmarks->addColumn('content', 'text', ['notnull' => true]);
$bookmarks->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_4016EF25A76ED395');
$bookmarks->addUniqueIndex(['user_id', 'name'], 'UNIQ_4016EF25A76ED3955E237E06');
$bookmarks->setPrimaryKey(['id']);
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE kimai2_bookmarks');
}
}

View File

@@ -0,0 +1,40 @@
<?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;
/**
* Update invoice with payment date
*
* @version 1.14
*/
final class Version20210320162820 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update invoice with payment date';
}
public function up(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_invoices');
$invoices->addColumn('payment_date', 'date', ['default' => null, 'notnull' => false]);
}
public function down(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_invoices');
$invoices->dropColumn('payment_date');
}
}

View File

@@ -0,0 +1,40 @@
<?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;
/**
* Increase the configuration table column length
*
* @version 1.14
*/
final class Version20210405105611 extends AbstractMigration
{
public function getDescription(): string
{
return 'Increase the configuration table column length';
}
public function up(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_configuration');
$invoices->getColumn('value')->setLength(1024);
}
public function down(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_configuration');
$invoices->getColumn('value')->setLength(255);
}
}

View File

@@ -0,0 +1,43 @@
<?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 Version20210605154245 extends AbstractMigration
{
public function getDescription(): string
{
return 'Cleans up the user table';
}
public function up(Schema $schema): void
{
$user = $schema->getTable('kimai2_users');
$user->dropIndex('UNIQ_B9AC5BCE92FC23A8');
$user->dropIndex('UNIQ_B9AC5BCEA0D96FBF');
$user->dropColumn('username_canonical');
$user->dropColumn('email_canonical');
$user->dropColumn('salt');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE kimai2_users ADD username_canonical VARCHAR(180) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ADD email_canonical VARCHAR(180) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ADD salt VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCE92FC23A8 ON kimai2_users (username_canonical)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_B9AC5BCEA0D96FBF ON kimai2_users (email_canonical)');
}
}

View File

@@ -0,0 +1,44 @@
<?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 Version20210704111542 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the color columns on: user, team';
}
public function up(Schema $schema): void
{
$users = $schema->getTable('kimai2_users');
$users->addColumn('color', 'string', ['length' => 7, 'notnull' => false, 'default' => null]);
$teams = $schema->getTable('kimai2_teams');
$teams->addColumn('color', 'string', ['length' => 7, 'notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$users = $schema->getTable('kimai2_users');
$users->dropColumn('color');
$teams = $schema->getTable('kimai2_teams');
$teams->dropColumn('color');
}
}

View File

@@ -0,0 +1,38 @@
<?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 Version20210717211144 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the account column to the user table';
}
public function up(Schema $schema): void
{
$users = $schema->getTable('kimai2_users');
$users->addColumn('account', 'string', ['length' => 30, 'notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$users = $schema->getTable('kimai2_users');
$users->dropColumn('account');
}
}

View File

@@ -0,0 +1,50 @@
<?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 Version20210719123928 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the budget_type columns to customer, project and activity';
}
public function up(Schema $schema): void
{
$activities = $schema->getTable('kimai2_activities');
$activities->addColumn('budget_type', 'string', ['length' => 10, 'notnull' => false, 'default' => null]);
$customers = $schema->getTable('kimai2_customers');
$customers->addColumn('budget_type', 'string', ['length' => 10, 'notnull' => false, 'default' => null]);
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('budget_type', 'string', ['length' => 10, 'notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$activities = $schema->getTable('kimai2_activities');
$activities->dropColumn('budget_type');
$customers = $schema->getTable('kimai2_customers');
$customers->dropColumn('budget_type');
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('budget_type');
}
}

View File

@@ -0,0 +1,58 @@
<?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;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
/**
* @version 1.15
*/
final class Version20210727104955 extends AbstractMigration
{
public function getDescription(): string
{
return 'Allows arbitrary length of meta columns';
}
public function up(Schema $schema): void
{
$activitiesMeta = $schema->getTable('kimai2_activities_meta');
$activitiesMeta->getColumn('value')->setLength(65535)->setType(Type::getType(Types::TEXT));
$customersMeta = $schema->getTable('kimai2_customers_meta');
$customersMeta->getColumn('value')->setLength(65535)->setType(Type::getType(Types::TEXT));
$projectsMeta = $schema->getTable('kimai2_projects_meta');
$projectsMeta->getColumn('value')->setLength(65535)->setType(Type::getType(Types::TEXT));
$timesheetMeta = $schema->getTable('kimai2_timesheet_meta');
$timesheetMeta->getColumn('value')->setLength(65535)->setType(Type::getType(Types::TEXT));
}
public function down(Schema $schema): void
{
$activitiesMeta = $schema->getTable('kimai2_activities_meta');
$activitiesMeta->getColumn('value')->setLength(255)->setType(Type::getType(Types::STRING));
$customersMeta = $schema->getTable('kimai2_customers_meta');
$customersMeta->getColumn('value')->setLength(255)->setType(Type::getType(Types::STRING));
$projectsMeta = $schema->getTable('kimai2_projects_meta');
$projectsMeta->getColumn('value')->setLength(255)->setType(Type::getType(Types::STRING));
$timesheetMeta = $schema->getTable('kimai2_timesheet_meta');
$timesheetMeta->getColumn('value')->setLength(255)->setType(Type::getType(Types::STRING));
}
}

View 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;
use Doctrine\DBAL\Types\Types;
/**
* @version 1.15
*/
final class Version20210802152259 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add the date column to the timesheet table';
}
public function up(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->addColumn('date_tz', Types::DATE_MUTABLE, ['notnull' => false]);
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->dropColumn('date_tz');
}
}

View File

@@ -0,0 +1,58 @@
<?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 Version20210802152814 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fills the new date column in the timesheet table';
}
public function up(Schema $schema): void
{
$fetch = $this->connection->prepare('SELECT id, start_time, timezone FROM kimai2_timesheet WHERE date_tz IS NULL');
$result = $fetch->executeQuery();
$timezones = [];
foreach (\DateTimeZone::listIdentifiers() as $tz) {
$timezones[$tz] = new \DateTimeZone($tz);
}
foreach ($result->iterateAssociative() as $row) {
if (!isset($timezones[$row['timezone']])) {
$timezones[$row['timezone']] = new \DateTimeZone($row['timezone']);
}
$date = new \DateTime($row['start_time'], $timezones['UTC']);
$date->setTimezone($timezones[$row['timezone']]);
$this->addSql('UPDATE kimai2_timesheet SET date_tz = ? WHERE id = ?', [$date->format('Y-m-d'), $row['id']]);
}
$result->free();
$this->addSql('ALTER TABLE kimai2_timesheet ALTER date_tz DROP DEFAULT');
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->changeColumn('date_tz', ['notnull' => false]);
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,40 @@
<?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 Version20210802160837 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the index on the new timesheet statistic date column';
}
public function up(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->changeColumn('date_tz', ['notnull' => true]);
$timesheet->addIndex(['date_tz', 'user'], 'IDX_4F60C6B1BDF467148D93D649');
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->changeColumn('date_tz', ['notnull' => false]);
$timesheet->dropIndex('IDX_4F60C6B1BDF467148D93D649');
}
}

View 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']);
}
}

View File

@@ -0,0 +1,58 @@
<?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');
$result = $fetch->executeQuery();
foreach ($result->iterateAssociative() as $row) {
$this->addSql('UPDATE kimai2_users_teams SET teamlead = 1 WHERE user_id = ? AND team_id = ?', [$row['teamlead_id'], $row['id']]);
}
$result->free();
$this->preventEmptyMigrationWarning();
}
public function down(Schema $schema): void
{
$fetch = $this->connection->prepare('SELECT user_id, team_id, teamlead FROM kimai2_users_teams WHERE teamlead = 1');
$result = $fetch->executeQuery();
foreach ($result->iterateAssociative() as $row) {
$this->addSql('UPDATE kimai2_teams SET teamlead_id = ? where id = ?', [$row['user_id'], $row['team_id']]);
}
$result->free();
$teams = $schema->getTable('kimai2_teams');
$teams->getColumn('teamlead_id')->setNotnull(true);
$teams->addForeignKeyConstraint('kimai2_users', ['teamlead_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_3BEDDC7F8F7DE5D7');
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,42 @@
<?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');
// @see https://github.com/kimai/kimai/issues/2706
if ($teams->hasForeignKey('FK_3BEDDC7F8F7DE5D7')) {
$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]);
}
}

View File

@@ -0,0 +1,44 @@
<?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.16
*/
final class Version20211008092010 extends AbstractMigration
{
public function getDescription(): string
{
return 'Extend field orderNumber from 20 to 50 characters.';
}
public function up(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$column = $projects->getColumn('order_number');
$column->setOptions(['length' => 50]);
$this->preventEmptyMigrationWarning();
}
public function down(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$column = $projects->getColumn('order_number');
$column->setOptions(['length' => 20]);
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -0,0 +1,38 @@
<?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.17
*/
final class Version20211230163612 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the comment column to the invoices table.';
}
public function up(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_invoices');
$invoices->addColumn('comment', 'text', ['notnull' => false]);
}
public function down(Schema $schema): void
{
$invoices = $schema->getTable('kimai2_invoices');
$invoices->dropColumn('comment');
}
}

View File

@@ -0,0 +1,42 @@
<?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;
final class Version20220101204501 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the invoice-meta table';
}
public function up(Schema $schema): void
{
$table = $schema->createTable('kimai2_invoices_meta');
$table->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('invoice_id', 'integer', ['notnull' => true]);
$table->addColumn('name', 'string', ['notnull' => true, 'length' => 50]);
$table->addColumn('value', 'text', ['notnull' => false, 'length' => 65535]);
$table->addColumn('visible', 'boolean', ['notnull' => true, 'default' => false]);
$table->setPrimaryKey(['id']);
$table->addIndex(['invoice_id'], 'IDX_7EDC37D92989F1FD');
$table->addUniqueIndex(['invoice_id', 'name'], 'UNIQ_7EDC37D92989F1FD5E237E06');
$table->addForeignKeyConstraint('kimai2_invoices', ['invoice_id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_7EDC37D92989F1FD');
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_invoices_meta');
}
}

View File

@@ -0,0 +1,49 @@
<?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;
final class Version20220315224645 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds billable fields to Customer, Project and Activity';
}
public function up(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->addColumn('billable', 'boolean', ['notnull' => true, 'default' => true]);
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('billable', 'boolean', ['notnull' => true, 'default' => true]);
$activities = $schema->getTable('kimai2_activities');
$activities->addColumn('billable', 'boolean', ['notnull' => true, 'default' => true]);
$this->addSql('DELETE from kimai2_configuration WHERE `name` = "defaults.timesheet.billable"');
}
public function down(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->dropColumn('billable');
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('billable');
$activities = $schema->getTable('kimai2_activities');
$activities->dropColumn('billable');
}
}

View File

@@ -0,0 +1,40 @@
<?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;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
/**
* @version 1.19.2
*/
final class Version20220404150236 extends AbstractMigration
{
public function getDescription(): string
{
return 'Allow arbitrary string length for system configurations';
}
public function up(Schema $schema): void
{
$configuration = $schema->getTable('kimai2_configuration');
$configuration->getColumn('value')->setType(Type::getType(Types::TEXT));
}
public function down(Schema $schema): void
{
$configuration = $schema->getTable('kimai2_configuration');
$configuration->getColumn('value')->setLength(1024)->setType(Type::getType(Types::STRING));
}
}

View File

@@ -0,0 +1,44 @@
<?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.20.2
*/
final class Version20220531145920 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add invoice text columns to project and activity';
}
public function up(Schema $schema): void
{
$activities = $schema->getTable('kimai2_activities');
$activities->addColumn('invoice_text', 'text', ['notnull' => false, 'default' => null]);
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('invoice_text', 'text', ['notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$activities = $schema->getTable('kimai2_activities');
$activities->dropColumn('invoice_text');
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('invoice_text');
}
}

View File

@@ -0,0 +1,38 @@
<?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.22.0
*/
final class Version20220722125847 extends AbstractMigration
{
public function getDescription(): string
{
return '(De-)Activate global activities for Projects';
}
public function up(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('global_activities', 'boolean', ['notnull' => true, 'default' => true]);
}
public function down(Schema $schema): void
{
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('global_activities');
}
}

View File

@@ -0,0 +1,130 @@
<?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 Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* All the checks for hasIndex() and hasColumn() are here to simplify testing and development,
* as it allows to run the migration multiple times without causing issues.
*
* @version 2.0
*/
final class Version20993112235958 extends AbstractMigration
{
public function getDescription(): string
{
return 'Necessary changes for 2.0';
}
public function up(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
// clean up column length for strict mode
$customers->getColumn('company')->setLength(100);
$customers->getColumn('contact')->setLength(100);
$customers->getColumn('phone')->setLength(30);
$customers->getColumn('fax')->setLength(30);
$customers->getColumn('mobile')->setLength(30);
$customers->getColumn('homepage')->setLength(100);
$customers->getColumn('email')->setLength(75);
$users = $schema->getTable('kimai2_users');
if (!$users->hasColumn('totp_secret')) {
$users->addColumn('totp_secret', 'string', ['notnull' => false, 'default' => null]);
$users->addColumn('totp_enabled', 'boolean', ['notnull' => true, 'default' => false]);
}
if (!$users->hasColumn('system_account')) {
$users->addColumn('system_account', 'boolean', ['notnull' => true, 'default' => false]);
}
// new invoice features
if (!$customers->hasColumn('invoice_template_id')) {
$customers->addColumn('invoice_template_id', 'integer', ['notnull' => false, 'default' => null]);
$customers->addForeignKeyConstraint('kimai2_invoice_templates', ['invoice_template_id'], ['id'], ['onDelete' => 'SET NULL'], 'FK_5A97604412946D8B');
$customers->addIndex(['invoice_template_id'], 'IDX_5A97604412946D8B');
}
if (!$customers->hasColumn('invoice_text')) {
$customers->addColumn('invoice_text', 'text', ['notnull' => false, 'default' => null]);
}
$timesheet = $schema->getTable('kimai2_timesheet');
if (!$timesheet->hasIndex('IDX_4F60C6B1415614018D93D649')) {
$timesheet->addIndex(['end_time', 'user'], 'IDX_4F60C6B1415614018D93D649');
}
if (!$timesheet->hasIndex('IDX_TIMESHEET_TICKTAC')) {
$timesheet->addIndex(['end_time', 'user', 'start_time'], 'IDX_TIMESHEET_TICKTAC');
}
if (!$timesheet->hasIndex('IDX_TIMESHEET_RECENT_ACTIVITIES')) {
$timesheet->addIndex(['user', 'project_id', 'activity_id'], 'IDX_TIMESHEET_RECENT_ACTIVITIES');
}
if (!$timesheet->hasIndex('IDX_TIMESHEET_RESULT_STATS')) {
$timesheet->addIndex(['user', 'id', 'duration'], 'IDX_TIMESHEET_RESULT_STATS');
}
$this->addSql("UPDATE kimai2_invoice_templates SET `language` = 'en' WHERE `language` IS NULL");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'timesheet_daily_stats' WHERE `name` = 'timesheet.daily_stats'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'collapsed_sidebar' WHERE `name` = 'theme.collapsed_sidebar'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'layout' WHERE `name` = 'theme.layout'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'login_initial_view' WHERE `name` = 'login.initial_view'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'calendar_initial_view' WHERE `name` = 'calendar.initial_view'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'export_decimal' WHERE `name` = 'timesheet.export_decimal'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'update_browser_title' WHERE `name` = 'theme.update_browser_title'");
$this->addSql("UPDATE kimai2_configuration SET `value` = '15' WHERE `name` = 'timesheet.time_increment' and `value` = '0'");
$this->addSql("UPDATE kimai2_configuration SET `value` = '5' WHERE `name` = 'timesheet.time_increment' and `value` IN ('1', '2', '3', '4')");
$this->addSql("UPDATE kimai2_roles SET `name` = UPPER(`name`)");
$this->addSql("UPDATE kimai2_invoice_templates SET `renderer` = 'service-date' WHERE `renderer` = 'freelancer'");
$this->addSql("UPDATE kimai2_invoice_templates SET `renderer` = 'invoice' WHERE `renderer` = 'default'");
$this->addSql("UPDATE kimai2_invoice_templates SET `renderer` = 'default' WHERE `renderer` = 'default-pdf'");
}
public function down(Schema $schema): void
{
$customers = $schema->getTable('kimai2_customers');
$customers->getColumn('company')->setLength(255);
$customers->getColumn('contact')->setLength(255);
$customers->getColumn('phone')->setLength(255);
$customers->getColumn('fax')->setLength(255);
$customers->getColumn('mobile')->setLength(255);
$customers->getColumn('homepage')->setLength(255);
$customers->removeForeignKey('FK_5A97604412946D8B');
$customers->dropIndex('IDX_5A97604412946D8B');
$customers->dropColumn('invoice_template_id');
$customers->dropColumn('invoice_text');
$timesheet = $schema->getTable('kimai2_timesheet');
if ($timesheet->hasIndex('IDX_4F60C6B1415614018D93D649')) {
$timesheet->dropIndex('IDX_4F60C6B1415614018D93D649');
}
if ($timesheet->hasIndex('IDX_TIMESHEET_TICKTAC')) {
$timesheet->dropIndex('IDX_TIMESHEET_TICKTAC');
}
if ($timesheet->hasIndex('IDX_TIMESHEET_RECENT_ACTIVITIES')) {
$timesheet->dropIndex('IDX_TIMESHEET_RECENT_ACTIVITIES');
}
if ($timesheet->hasIndex('IDX_TIMESHEET_RESULT_STATS')) {
$timesheet->dropIndex('IDX_TIMESHEET_RESULT_STATS');
}
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.collapsed_sidebar' WHERE `name` = 'collapsed_sidebar'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.layout' WHERE `name` = 'theme_layout'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'calendar.initial_view' WHERE `name` = 'calendar_initial_view'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'login.initial_view' WHERE `name` = 'login_initial_view'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'timesheet.daily_stats' WHERE `name` = 'timesheet_daily_stats'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'timesheet.export_decimal' WHERE `name` = 'export_decimal'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.update_browser_title' WHERE `name` = 'update_browser_title'");
}
}