diff --git a/UPGRADE.md b/UPGRADE.md
index 4b2ccf255e2..895f991b362 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -8,6 +8,10 @@ awareness about deprecated code.
# Upgrade to 4.0
+## Removed `TableGenerator` component
+
+The `TableGenerator` component has been removed.
+
## Removed support for `Connection::lastInsertId($name)`
The `Connection::lastInsertId()` method no longer accepts a sequence name.
diff --git a/psalm.xml.dist b/psalm.xml.dist
index aab71dfcc10..925faa20b5d 100644
--- a/psalm.xml.dist
+++ b/psalm.xml.dist
@@ -46,11 +46,6 @@
is no longer supported.
-->
-
-
-
diff --git a/src/Id/TableGenerator.php b/src/Id/TableGenerator.php
deleted file mode 100644
index f35ed018f05..00000000000
--- a/src/Id/TableGenerator.php
+++ /dev/null
@@ -1,165 +0,0 @@
-> */
- private $sequences = [];
-
- /**
- * @throws Exception
- */
- public function __construct(Connection $conn, string $generatorTableName = 'sequences')
- {
- Deprecation::trigger(
- 'doctrine/dbal',
- 'https://github.com/doctrine/dbal/pull/4681',
- 'The TableGenerator class is is deprecated.',
- );
-
- if ($conn->getDriver() instanceof Driver\PDO\SQLite\Driver) {
- throw new Exception('Cannot use TableGenerator with SQLite.');
- }
-
- $this->conn = DriverManager::getConnection(
- $conn->getParams(),
- $conn->getConfiguration(),
- $conn->getEventManager()
- );
-
- $this->generatorTableName = $generatorTableName;
- }
-
- /**
- * Generates the next unused value for the given sequence name.
- *
- * @throws Exception
- */
- public function nextValue(string $sequence): int
- {
- if (isset($this->sequences[$sequence])) {
- $value = $this->sequences[$sequence]['value'];
- $this->sequences[$sequence]['value']++;
- if ($this->sequences[$sequence]['value'] >= $this->sequences[$sequence]['max']) {
- unset($this->sequences[$sequence]);
- }
-
- return $value;
- }
-
- $this->conn->beginTransaction();
-
- try {
- $platform = $this->conn->getDatabasePlatform();
- $sql = 'SELECT sequence_value, sequence_increment_by'
- . ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE)
- . ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL();
- $row = $this->conn->fetchAssociative($sql, [$sequence]);
-
- if ($row !== false) {
- $row = array_change_key_case($row, CASE_LOWER);
-
- $value = $row['sequence_value'];
- $value++;
-
- assert(is_int($value));
-
- if ($row['sequence_increment_by'] > 1) {
- $this->sequences[$sequence] = [
- 'value' => $value,
- 'max' => $row['sequence_value'] + $row['sequence_increment_by'],
- ];
- }
-
- $sql = 'UPDATE ' . $this->generatorTableName . ' ' .
- 'SET sequence_value = sequence_value + sequence_increment_by ' .
- 'WHERE sequence_name = ? AND sequence_value = ?';
- $rows = $this->conn->executeStatement($sql, [$sequence, $row['sequence_value']]);
-
- if ($rows !== 1) {
- throw new Exception('Race condition detected while updating sequence. Aborting generation.');
- }
- } else {
- $this->conn->insert(
- $this->generatorTableName,
- ['sequence_name' => $sequence, 'sequence_value' => 1, 'sequence_increment_by' => 1]
- );
- $value = 1;
- }
-
- $this->conn->commit();
- } catch (Throwable $e) {
- $this->conn->rollBack();
-
- throw new Exception(sprintf(
- 'Error occurred while generating ID with TableGenerator, aborted generation with error: %s',
- $e->getMessage()
- ), 0, $e);
- }
-
- return $value;
- }
-}
diff --git a/src/Id/TableGeneratorSchemaVisitor.php b/src/Id/TableGeneratorSchemaVisitor.php
deleted file mode 100644
index 99a6547ac61..00000000000
--- a/src/Id/TableGeneratorSchemaVisitor.php
+++ /dev/null
@@ -1,63 +0,0 @@
-generatorTableName = $generatorTableName;
- }
-
- public function acceptSchema(Schema $schema): void
- {
- $table = $schema->createTable($this->generatorTableName);
-
- $table->addColumn('sequence_name', 'string', ['length' => 255]);
- $table->addColumn('sequence_value', 'integer', ['default' => 1]);
- $table->addColumn('sequence_increment_by', 'integer', ['default' => 1]);
- }
-
- public function acceptTable(Table $table): void
- {
- }
-
- public function acceptColumn(Table $table, Column $column): void
- {
- }
-
- public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint): void
- {
- }
-
- public function acceptIndex(Table $table, Index $index): void
- {
- }
-
- public function acceptSequence(Sequence $sequence): void
- {
- }
-}
diff --git a/tests/Functional/TableGeneratorTest.php b/tests/Functional/TableGeneratorTest.php
deleted file mode 100644
index 773f7397a48..00000000000
--- a/tests/Functional/TableGeneratorTest.php
+++ /dev/null
@@ -1,62 +0,0 @@
-connection->getDatabasePlatform();
- if ($platform->getName() === 'sqlite') {
- self::markTestSkipped('TableGenerator does not work with SQLite');
- }
-
- try {
- $schema = new Schema();
- $visitor = new TableGeneratorSchemaVisitor();
- $schema->visit($visitor);
-
- foreach ($schema->toSql($platform) as $sql) {
- $this->connection->executeStatement($sql);
- }
- } catch (Throwable $e) {
- }
-
- $this->generator = new TableGenerator($this->connection);
- }
-
- public function testNextVal(): void
- {
- $id1 = $this->generator->nextValue('tbl1');
- $id2 = $this->generator->nextValue('tbl1');
- $id3 = $this->generator->nextValue('tbl2');
-
- self::assertGreaterThan(0, $id1, 'First id has to be larger than 0');
- self::assertEquals($id1 + 1, $id2, 'Second id is one larger than first one.');
- self::assertEquals($id1, $id3, 'First ids from different tables are equal.');
- }
-
- public function testNextValNotAffectedByOuterTransactions(): void
- {
- $this->connection->beginTransaction();
- $id1 = $this->generator->nextValue('tbl1');
- $this->connection->rollBack();
- $id2 = $this->generator->nextValue('tbl1');
-
- self::assertGreaterThan(0, $id1, 'First id has to be larger than 0');
- self::assertEquals($id1 + 1, $id2, 'Second id is one larger than first one.');
- }
-}