-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Stop using template1 as default database for postgres drivers #2279
Conversation
Ohh yeah.. and ... "fixes" #2278 |
@kimhemsoe IIRC the reason we decided against using |
Can we somehow query to check whether the schema is there? |
@Ocramius I doubt this helps a lot. If the schema isn't there we still can't establish a temp connection. Also relying on a "default" database that has no special purpose and can be dopped by anyone. It's basically like a demo database to start with. |
You can drop template1 too, postgres schema is the "recommended" schema to use as default for applications (Read the bottom note in the link), using template1 is not an option for various reasons. There is numerous stackoverflow explaining this. I do not think you can drop template0 but that is not a good idea either for the same as template1. I do strongly believe that using he postgres schema is the lesser evil of the 3 options that we have. "Unknown database "postgres" is alot better error message then random ""SQLSTATE[55006]: Object in use: 7 ERROR: source database "template1" is being accessed by other users"" which may not even get throwed from dbal but from other random applications using the pg instance because we are using template1 as the default schema. |
Closing in favour of #2280 |
@kimhemsoe in a default database setup you cannot drop template databases as they are protected via the
See #2280 for a complete explanation. Also |
Reopening as the discussion in #2280 revealed this might be the better approach. |
Stop using template1 as default database for postgres drivers
@kimhemsoe thanks :) |
Backported to 2.5 branch in af38e30 |
We better provide the driver param fast to catch the issue flooding from doctrine bundle. |
@kimhemsoe do you think that many people are not having the postgres database? Otherwise yeah go ahead do a PR :) |
The template1 change came from a few doctrine bundle issues, i will provide PR's for the parameter. doctrine/DoctrineBundle#461 Btw i think we should merge #2280 too, not the template1 active connection reason, but to make sure we always have clean a database for tests, without any local changes. |
@kimhemsoe I don't see how your referenced PRs are related to this issue here. Those PRs deal with a completely different problem. |
The "postgresql" should be used as the default database and not "template1". Postgresql creates databases by copying an existing database and "template1" is the default if none is specified, if any connection to the template database exists when a "CREATE DATABASE" is issued postgresql is unable to create the new database.
http://www.postgresql.org/docs/9.4/static/manage-ag-templatedbs.html