Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
cfb2f0251316
Commit
fcb1a0f1
authored
Feb 26, 2021
by
François Ferry
Browse files
fix(db-create): don't force to use --drop if there is no existing db.
related:
#202
parent
0827e00b6a66
Pipeline
#39258
passed with stage
in 1 minute and 30 seconds
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
cubicweb/server/serverctl.py
View file @
cfb2f025
...
...
@@ -403,12 +403,17 @@ class CreateInstanceDBCommand(Command):
ASK
.
confirm
(
'Create db user %s ?'
%
user
,
default_is_yes
=
False
)):
helper
.
create_user
(
source
[
'db-user'
],
source
.
get
(
'db-password'
))
print
(
'-> user %s created.'
%
user
)
if
dbname
in
helper
.
list_databases
(
cursor
)
and
should_drop_db
():
cursor
.
execute
(
'DROP DATABASE "%s"'
%
dbname
)
else
:
print
(
'you may want to run "cubicweb-ctl db-create '
'--drop %s" to continue.'
%
config
.
appid
)
return
if
dbname
in
helper
.
list_databases
(
cursor
):
if
should_drop_db
():
cursor
.
execute
(
'DROP DATABASE "%s"'
%
dbname
)
else
:
print
(
'The database %s already exists, but automatically dropping it '
'is currently forbidden. You may want to run '
'"cubicweb-ctl db-create --drop=y %s" to continue or '
'"cubicweb-ctl db-create --help" to get help.'
%
(
dbname
,
config
.
appid
))
raise
Exception
(
'Not allowed to drop existing database.'
)
createdb
(
helper
,
source
,
dbcnx
,
cursor
)
dbcnx
.
commit
()
print
(
'-> database %s created.'
%
dbname
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment