diff options
| author | Olivier Dony <odo@odoo.com> | 2018-06-29 16:31:07 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@odoo.com> | 2018-06-29 16:37:42 +0200 |
| commit | 3edd504f17a2fe435ccd8235037e96c11ba96c18 (patch) | |
| tree | 79e2f3dc3d1037e42dfc66003d005bb111e2f162 /odoo/tools | |
| parent | a8e164c420e93439420915203f104df8b1d4fa97 (diff) | |
[IMP] db: create new databases based on template0
As a follow-up to commit 276ea817f4675a73576905edbc2a4567570ac206,
we change the default template database used for CREATE DATABASE
operations, and we avoid setting the LC_COLLATE option unless
this default template is used (to avoid locale compatibility errors).
Rationale for the default template choice:
PostgreSQL uses `template1` by default, and recommends that users alter
`template1` if they need a custom template, while keeping template0
virgin. This is likely to be the reason why we had `template1` as the
default previously (from a1e5c645d97e4e8f48cec546e858643029b7424a).
However, for new Odoo databases, it's actually better to use `template0`
as template, for multiple reasons:
- We do not customize the template database, and the system will work
fine when starting from a completely virgin database
- Since template0 does not allow connections by default, we have a
stronger guarantee that no user will be connected to the template
database (which would otherwise block database creations!)
- We use the same logic for creating new databases and for creating
placholder databases for restoring dumps. In the latter case,
PostgreSQL recommends using a virgin template, to obtain a perfect
copy of the database being restored (unaffected by any template
customization)
- Using `template0` as a template lets us choose any encoding and locale
settings (LC_COLLATE/LC_CTYPE) upon creation. Any other database
template might cause errors unless we select compatible encodings
and locale settings.
As the locale setting is system-dependent, we can't just hope
that there will be no compatibility problem, we must explicitly
default to template0. Therefore the change in
276ea817f4675a73576905edbc2a4567570ac206 was prone to causing
locale compatibility errors.
Finally, if users have a reason to prefer a different template, they
should select it explicitly with the --db_template config.
Note: existing environments will likely continue to use `template1`
as a default due to presence of older config files.
Complements #25196
Diffstat (limited to 'odoo/tools')
| -rw-r--r-- | odoo/tools/config.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/odoo/tools/config.py b/odoo/tools/config.py index 7fa33f400fd..1a026486bbb 100644 --- a/odoo/tools/config.py +++ b/odoo/tools/config.py @@ -221,7 +221,7 @@ class configmanager(object): help="specify the database ssl connection mode (see PostgreSQL documentation)") group.add_option("--db_maxconn", dest="db_maxconn", type='int', my_default=64, help="specify the the maximum number of physical connections to PostgreSQL") - group.add_option("--db-template", dest="db_template", my_default="template1", + group.add_option("--db-template", dest="db_template", my_default="template0", help="specify a custom database template to create a new database") parser.add_option_group(group) |
