-
-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lifecycle: migrate: ensure template schema exists before migrating (c…
…herry-pick #8952) (#9022) lifecycle: migrate: ensure template schema exists before migrating (#8952) Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
- Loading branch information
1 parent
5f0af81
commit 49d83f1
Showing
2 changed files
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from lifecycle.migrate import BaseMigration | ||
|
||
|
||
class Migration(BaseMigration): | ||
def needs_migration(self) -> bool: | ||
self.cur.execute( | ||
"SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'template';" | ||
) | ||
return not bool(self.cur.rowcount) | ||
|
||
def run(self): | ||
self.cur.execute("CREATE SCHEMA IF NOT EXISTS template; COMMIT;") |