diff --git a/src/Migrations/Version20190729162655.php b/src/Migrations/Version20190729162655.php index a7f8de7b..f44f1187 100644 --- a/src/Migrations/Version20190729162655.php +++ b/src/Migrations/Version20190729162655.php @@ -15,7 +15,7 @@ use App\Doctrine\AbstractMigration; use Doctrine\DBAL\Schema\Schema; /** - * Creates user team tables. + * Adds missing foreign keys on tag table. * * @version 1.2 */ @@ -23,7 +23,7 @@ final class Version20190729162655 extends AbstractMigration { public function getDescription(): string { - return 'Fixes foreign keys on tag table'; + return 'Adds missing foreign keys on tag table'; } protected function isSupportingForeignKeys(): bool diff --git a/src/Migrations/Version20191113132640.php b/src/Migrations/Version20191113132640.php new file mode 100644 index 00000000..587ffbe9 --- /dev/null +++ b/src/Migrations/Version20191113132640.php @@ -0,0 +1,62 @@ +isPlatformSqlite()) { + // does fail if we use transactions, as tables are re-created and foreign keys would fail + return false; + } + + return true; + } + + 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'); + } + + public function down(Schema $schema): void + { + } +} diff --git a/var/data/kimai_test.sqlite b/var/data/kimai_test.sqlite index 5939e2e4..f2461d15 100644 Binary files a/var/data/kimai_test.sqlite and b/var/data/kimai_test.sqlite differ