theofidry / AliceDataFixtures

Nelmio Alice extension to persist the loaded fixtures.
MIT License
311 stars 71 forks source link

Exclude readOnly entities from purge / delete mode #141

Closed Neirda24 closed 4 years ago

Neirda24 commented 4 years ago

(Original request here)

Hi. I have several entities with a readOnly mode

/**
 * @Entity(readOnly=true)
 * ...
 */

These are SQL views also ignored by doctrine to not mapped the schema diff

doctrine:
    dbal:
        default_connection: 'default'
        connections:
            default:
                url: '%env(resolve:DATABASE_URL)%'
                schema_filter: '#^(?!view_).*#'

but when trying to insert the fixtures it fails with either :

$ # with --purge-with-truncate
SQLSTATE[42809]: Wrong object type: 7 ERROR:  "view_something" is not a table

or

$ # without --purge-with-truncate
SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR:  cannot delete from view "view_something"
  DETAIL:  Views containing GROUP BY are not automatically updatable.
  HINT:  To enable deleting from the view, provide an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule.

any clues ?

Thanks in advance

Neirda24 commented 4 years ago

Ok it was my mistake sorry... The thing was: I am using postgres and on my entities I used the schema key so the table name (doctrine point of view) was not view_* but schema.view_* So I had to update my regex from #^(?!view_).*# to #^(?![^\.]*\.?view_).*#