doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 387 forks source link

Automatic creation of schema's #1400

Open jasperweyne opened 4 months ago

jasperweyne commented 4 months ago

Feature Request

Q A
New Feature yes
RFC ?
BC Break no

Summary

When using Doctrine Migrations for the first time, a table is automatically created, which allows for quick and easy usage. In PostgreSQL, the default schema is public schema, which is automatically created by PostgreSQL itself. Since it is the default schema, it is used by default by Doctrine Migrations as well.

Although this works fine for user accounts who are owner of that database, or a user with superuser privileges, accounts who aren't the database owner aren't privileged to create anything in the public schema anymore since PostgreSQL 15. In this case, the doctrine_migration_versions table can't be created. The intuitive option would be to change the migrations table to a different schema, where the user has creation privileges. However, in contrast to tables, schema's aren't automatically created by Doctrine Migrations. Therefore, my suggestion would be to automatically create the relevant schema on schema-aware database implementations, as this would match the behaviour of table creation as well.

stof commented 4 months ago

Is it actually possible to create a schema when you are not the database owner ? If no, the automatic creation would not make sense either.

jasperweyne commented 4 months ago

@stof As far as I could find/test, that is possible. Creating tables/other resources within the public schema is limited, but creating other schema's, as well as creating resources within those schema's, is permitted.