Allow skipping of triggers when dumping MySQL DB
specifically this is b/c of a production demo which makes use of multiple triggers of the same "type" but my dev maching has older MariaDB which doesn't allow such multiple triggers
This commit is contained in:
parent
9048403130
commit
9ae0015aba
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -149,15 +149,17 @@ def script(c, path, database=''):
|
||||||
c.sudo("bash -c 'mysql {} < {}'".format(database, path))
|
c.sudo("bash -c 'mysql {} < {}'".format(database, path))
|
||||||
|
|
||||||
|
|
||||||
def download_db(c, name, destination=None):
|
def download_db(c, name, destination=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Download a database from the "current" server.
|
Download a database from the "current" server.
|
||||||
"""
|
"""
|
||||||
if destination is None:
|
if destination is None:
|
||||||
destination = './{}.sql.gz'.format(name)
|
destination = './{}.sql.gz'.format(name)
|
||||||
|
triggers = '--skip-triggers' if kwargs.get('skip_triggers') else ''
|
||||||
|
mysqldump = 'mysqldump {0} --result-file={1}.sql {1}'.format(triggers, name)
|
||||||
# note, we force sudo "as root" to ensure -H flag is used
|
# note, we force sudo "as root" to ensure -H flag is used
|
||||||
# (which allows us to leverage /root/.my.cnf config file)
|
# (which allows us to leverage /root/.my.cnf config file)
|
||||||
c.sudo('mysqldump --result-file={0}.sql {0}'.format(name), user='root')
|
c.sudo(mysqldump, user='root')
|
||||||
c.sudo('gzip --force {}.sql'.format(name))
|
c.sudo('gzip --force {}.sql'.format(name))
|
||||||
c.get('{}.sql.gz'.format(name), destination)
|
c.get('{}.sql.gz'.format(name), destination)
|
||||||
c.sudo('rm {}.sql.gz'.format(name))
|
c.sudo('rm {}.sql.gz'.format(name))
|
||||||
|
|
Loading…
Reference in a new issue