Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ThomasLandauer opened this issue Mar 14, 2025 · 4 comments

Comments

@ThomasLandauer
Copy link
Contributor

Bug Report

Q A
Version 4.2.3

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 here).

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

@morozov
Copy link
Member

morozov commented Apr 6, 2025

Please try to reproduce this issue using the DBAL API.

@ThomasLandauer
Copy link
Contributor Author

What is the DBAL API?

@morozov
Copy link
Member

morozov commented Apr 6, 2025

It's the classes, interface, etc. provided by the Doctrine DBAL library. Schema Tool is part of the ORM.

@ThomasLandauer
Copy link
Contributor Author

Sorry, but there are so many schema related bugs filed here, that I didn't look elsewhere ;-)
So I now opened an issue at ORM: doctrine/orm#11898

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants