Schema Tool keeps recreating table user when inside a schema in PostgreSQL #7494

Open
opened 2026-01-22 15:52:18 +01:00 by admin · 0 comments
Owner

Originally created by @ThomasLandauer on GitHub (Apr 6, 2025).

Bug Report

Q A
Version 3.3.2

Summary

With the following mapping:

#[ORM\Table(schema: 'my')]
class User

whenever I rerun bin/console make:migration, I'm getting:

$this->addSql('CREATE TABLE my."user" (...)');
$this->addSql('DROP TABLE my."user"');

This is apparently due to user being a reserved word in SQL (or PostgreSQL), and the escaping Doctrine applies (as discussed in various issues at DBAL).

When I remove the schema, it works as expected:

[WARNING] No database changes were detected.

Workaround:
Rename the table in the database:

#[ORM\Table(name: 'users', schema: 'my')]

Current behavior

Expected behavior

How to reproduce

Originally created by @ThomasLandauer on GitHub (Apr 6, 2025). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |-------------------------------------------- | ------ | Version | 3.3.2 #### Summary With the following mapping: ```php #[ORM\Table(schema: 'my')] class User ``` whenever I rerun `bin/console make:migration`, I'm getting: ```php $this->addSql('CREATE TABLE my."user" (...)'); $this->addSql('DROP TABLE my."user"'); ``` This is apparently due to `user` being a reserved word in SQL (or PostgreSQL), and the escaping Doctrine applies (as discussed in various issues at DBAL). When I remove the schema, it works as expected: > [WARNING] No database changes were detected. Workaround: Rename the table in the database: ```php #[ORM\Table(name: 'users', schema: 'my')] ``` #### Current behavior <!-- What is the current (buggy) behavior? --> #### Expected behavior <!-- What was the expected (correct) behavior? --> #### How to reproduce <!-- Provide a failing Unit or Functional Test - you can submit one in a Pull Request separately, referencing this bug report. And if you feel like it, why not fix the bug while you're at it? If that is too difficult, provide a link to a minimal repository containing an application that reproduces the bug. If the bug is simple, you may provide a code snippet instead, or even a list of steps. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7494