Skip to content

Commit

Permalink
Fix template id db migration (#159)
Browse files Browse the repository at this point in the history
* Set empty string as default for template id field

* Stop charm execution if db migrations fail to avoid overwriting status
  • Loading branch information
omar-selo committed Apr 18, 2024
1 parent 6eb786f commit 38e8498
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/charm/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def _migrate_database(self):
logger.error(e.stdout)
logger.error(e.stderr)
self.unit.status = BlockedStatus("Database migration failed")
raise SystemExit(0)

def _on_database_changed(self, event):
self._migrate_database()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@


def upgrade() -> None:
op.add_column("test_case", sa.Column("template_id", sa.String(), nullable=False))
op.add_column(
"test_case",
sa.Column("template_id", sa.String(), nullable=False, server_default=""),
)


def downgrade() -> None:
Expand Down

0 comments on commit 38e8498

Please sign in to comment.