Merge lp:~dangyogi/charms/trusty/postgresql/add_extensions into lp:charms/trusty/postgresql

Proposed by dangyogi
Status: Merged
Merged at revision: 123
Proposed branch: lp:~dangyogi/charms/trusty/postgresql/add_extensions
Merge into: lp:charms/trusty/postgresql
Diff against target: 37 lines (+20/-0) (has conflicts)
1 file modified
hooks/hooks.py (+20/-0)
Text conflict in hooks/hooks.py 
To merge this branch: bzr merge lp:~dangyogi/charms/trusty/postgresql/add_extensions
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+263708@code.launchpad.net

Commit message

removed DROP EXTENSION drom db relation

Description of the change

Removed the DROP EXTENSION logic from the db relation

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

All looks good, and matches previous discussions.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2015-06-25 08:11:29 +0000
3+++ hooks/hooks.py 2015-07-02 18:30:39 +0000
4@@ -1534,6 +1534,7 @@
5
6
7 def ensure_extensions(extensions, database):
8+<<<<<<< TREE
9 cur = db_cursor(db=database, autocommit=True)
10 cur.execute('SELECT extname FROM pg_extension')
11 installed_extensions = frozenset(x[0] for x in cur.fetchall())
12@@ -1551,6 +1552,25 @@
13 log("creating extension {}".format(ext), DEBUG)
14 cur.execute('CREATE EXTENSION %s', (AsIs(quote_identifier(ext)),))
15 cur.close()
16+=======
17+ if extensions:
18+ cur = db_cursor(db=database, autocommit=True)
19+ try:
20+ cur.execute('SELECT extname FROM pg_extension')
21+ installed_extensions = frozenset(x[0] for x in cur.fetchall())
22+ log("ensure_extensions({}), have {}"
23+ .format(extensions, installed_extensions),
24+ DEBUG)
25+ extensions_set = frozenset(extensions)
26+ extensions_to_create = \
27+ extensions_set.difference(installed_extensions)
28+ for ext in extensions_to_create:
29+ log("creating extension {}".format(ext), DEBUG)
30+ cur.execute('CREATE EXTENSION %s',
31+ (AsIs(quote_identifier(ext)),))
32+ finally:
33+ cur.close()
34+>>>>>>> MERGE-SOURCE
35
36
37 def snapshot_relations():

Subscribers

People subscribed via source and target branches

to all changes: