Skip to content

Commit 3c42c0d

Browse files
committed
enable search context after migrating database
1 parent 12ea20f commit 3c42c0d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

database/runtime/handler.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ def handler(event, context):
199199
print("Registering PostGIS ...")
200200
register_extensions(cursor=cur)
201201

202-
print("Enabling context extension ...")
203-
enable_context(cursor=cur)
204-
205202
dsn = "postgresql://{user}:{password}@{host}:{port}/{dbname}".format(
206203
dbname=user_params.get("dbname", "postgres"),
207204
user=user_params["username"],
@@ -212,9 +209,16 @@ def handler(event, context):
212209

213210
asyncio.run(run_migration(dsn))
214211

212+
# Enable context extension after migrating database
213+
with psycopg.connect(con_str, autocommit=True) as conn:
214+
with conn.cursor() as cur:
215+
print("Enabling context extension ...")
216+
enable_context(cursor=cur)
217+
215218
except Exception as e:
216219
print(f"Unable to bootstrap database with exception={e}")
217220
return send(event, context, "FAILED", {"message": str(e)})
218221

222+
219223
print("Complete.")
220224
return send(event, context, "SUCCESS", {})

0 commit comments

Comments
 (0)