doctrine:schema:drop --full-database does not remove some specific tables with names "sessions" and "rememberme_token" #6821

Open
opened 2026-01-22 15:39:26 +01:00 by admin · 1 comment
Owner

Originally created by @jean553 on GitHub (Sep 2, 2021).

Bug Report

When I execute doctrine:schema:drop with the option --full-database, the tables created manually (not through Doctrine ORM) are not deleted. So the "full-database" is not deleted.

The tables are not deleted only if their names are:

  • sessions
  • rememberme_token
Q A
BC Break no
Version 2.9.4

Summary

I have two types of database assets/tables:

  • tables created with migrations and entities through doctrine commands (doctrine:migrations:diff, doctrine:migrations:migrate),
  • two tables created from a blank migration (doctrine:migrations:generate) named sessions and rememberme_token

These two last tables are created according to the following Symfony documentations:

When I execute doctrine:schema:drop --full-database, all the tables created through Doctrine are correctly deleted. The two tables created manually are not deleted though.

This issue causes errors in automatic CI pipelines when trying to replay the whole migrations list after executing doctrine:schema:drop --full-database as the tables we try to create already exists. A work-around is to add $this->addSql('DROP TABLE IF EXISTS rememberme_token') just before the CREATE TABLE.

Current behavior

The full database content is not deleted when executing doctrine:schema:drop --full-database.

How to reproduce

PostgreSQL version: 12.7

1 - Execute doctrine:migrations:generate to create a blank migration,
2 - In the up() function, add the following code:

$this->addSql('                                            
    CREATE TABLE rememberme_token (                         
        series   char(88)     UNIQUE PRIMARY KEY NOT NULL, 
        value    varchar(88)  NOT NULL,                    
        lastUsed timestamp    NOT NULL,                    
        class    varchar(100) NOT NULL,                    
        username varchar(200) NOT NULL                     
    )                                                      
');                                                                                                                                         

3 - In the down() function, add the following code:

$this->addSql('                                            
    DROP TABLE rememberme_token
');                                                                                                                                         

4 - Execute doctrine:migrations:migrate to create the table in your database,
5 - Using PostgreSQL CLI, check the list of tables available; note that rememberme_token has been created,
6 - Execute doctrine:schema:dop --full-database to drop the content of the database
7 - Using PostgreSQL CLI check the list of tables available; note that rememberme_token is still there and has not been deleted;

Expected behavior

When executing doctrine:schema:drop with the option --full-database, all tables (including those created manually) should be removed.

Originally created by @jean553 on GitHub (Sep 2, 2021). ### Bug Report When I execute doctrine:schema:drop with the option --full-database, the tables created manually (not through Doctrine ORM) are not deleted. So the "full-database" is not deleted. The tables are not deleted only if their names are: - `sessions` - `rememberme_token` | Q | A |------------ | ------ | BC Break | no | Version | 2.9.4 #### Summary I have two types of database assets/tables: - tables created with migrations and entities through doctrine commands (doctrine:migrations:diff, doctrine:migrations:migrate), - two tables created from a blank migration (`doctrine:migrations:generate`) named `sessions` and `rememberme_token` These two last tables are created according to the following Symfony documentations: - using the "Remember me" feature (https://symfony.com/doc/current/security/remember_me.html) - storing the users session into database (https://symfony.com/doc/current/session/database.html) When I execute doctrine:schema:drop --full-database, all the tables created through Doctrine are correctly deleted. The two tables created manually are not deleted though. This issue causes errors in automatic CI pipelines when trying to replay the whole migrations list after executing `doctrine:schema:drop --full-database` as the tables we try to create already exists. A work-around is to add `$this->addSql('DROP TABLE IF EXISTS rememberme_token')` just before the `CREATE TABLE`. #### Current behavior The full database content is not deleted when executing `doctrine:schema:drop --full-database`. #### How to reproduce PostgreSQL version: 12.7 1 - Execute `doctrine:migrations:generate` to create a blank migration, 2 - In the up() function, add the following code: ``` $this->addSql(' CREATE TABLE rememberme_token ( series char(88) UNIQUE PRIMARY KEY NOT NULL, value varchar(88) NOT NULL, lastUsed timestamp NOT NULL, class varchar(100) NOT NULL, username varchar(200) NOT NULL ) '); ``` 3 - In the down() function, add the following code: ``` $this->addSql(' DROP TABLE rememberme_token '); ``` 4 - Execute `doctrine:migrations:migrate` to create the table in your database, 5 - Using PostgreSQL CLI, check the list of tables available; note that `rememberme_token` has been created, 6 - Execute `doctrine:schema:dop --full-database` to drop the content of the database 7 - Using PostgreSQL CLI check the list of tables available; note that `rememberme_token` is still there and has not been deleted; #### Expected behavior When executing doctrine:schema:drop with the option --full-database, all tables (including those created manually) should be removed.
Author
Owner

@eexit commented on GitHub (Sep 20, 2021):

Hi @jean553,

I found out that sessions table is black-listed as part of this CompilerPass, while the rememberme_token table is probably filtered out in the doctrine.yml file under the schema_filter key.
It seems there's some on-going work to remove this CP and some features are already handled by Symfony code-base but not yet for the session PDO handler.

So far, the command is behaving as expected but maybe they should create a --ignore-filters command flag that bypasses the filters altogether.

@eexit commented on GitHub (Sep 20, 2021): Hi @jean553, I found out that `sessions` table is black-listed as part of this [CompilerPass](https://github.com/doctrine/DoctrineBundle/blob/2.4.x/DependencyInjection/Compiler/WellKnownSchemaFilterPass.php#L40), while the `rememberme_token` table is probably filtered out in the doctrine.yml file under the `schema_filter` key. It seems there's some [on-going work](https://github.com/doctrine/DoctrineBundle/pull/1286#issuecomment-778242976) to remove this CP and some features are already handled by Symfony code-base but not yet for the session PDO handler. So far, the command is behaving as expected but maybe they should create a `--ignore-filters` command flag that bypasses the filters altogether.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6821