Skip to content

Commit

Permalink
make mysql compatible to mysql 8
Browse files Browse the repository at this point in the history
This may break older mysql so the query can be overridden now

#242
  • Loading branch information
zagy committed Mar 7, 2022
1 parent 9577420 commit f11e93d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
`./batou migrate`.
([#185](https://github.com/flyingcircusio/batou/issues/185))

- Support creating users in MySQL ≥8.
([#242](https://github.com/flyingcircusio/batou/issues/242))

2.3b3 (2021-11-30)
------------------
Expand Down
15 changes: 8 additions & 7 deletions src/batou/lib/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class User(Component):
allow_from_hostname = "localhost"
admin_password = None

SET_PASSWORD_QUERY = """
SET PASSWORD FOR
'{{component.user}}'@'{{component.allow_from_hostname}}' =
'{{component.password}}';
"""

def configure(self):

create = self.expand("""\
Expand All @@ -105,13 +111,8 @@ def configure(self):
""")
self += Command(
create, unless=create_unless, admin_password=self.admin_password)

set_password = self.expand("""\
SET PASSWORD FOR
'{{component.user}}'@'{{component.allow_from_hostname}}' =
PASSWORD('{{component.password}}');
""")
self += Command(set_password, admin_password=self.admin_password)
self += Command(self.expand(self.SET_PASSWORD_QUERY),
admin_password=self.admin_password)


class Grant(Command):
Expand Down

0 comments on commit f11e93d

Please sign in to comment.