feature: made migration moe robust

This commit is contained in:
ievgenii vdovenko 2025-07-25 11:04:21 +02:00
parent 1c3d177833
commit ff4f3f0575
2 changed files with 21 additions and 12 deletions

View file

@ -4091,6 +4091,14 @@ class _PullRequestBase(BaseModel):
"reviewer_data_json", MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384))))
)
settings = Column(
"settings_json",
MutationObj.as_mutable(
JsonType(dialect_map=dict(mysql=UnicodeText(16384))),
),
default=dict,
)
@property
def reviewer_data_json(self):
return json.dumps(self.reviewer_data)

View file

@ -27,19 +27,20 @@ def upgrade(migrate_engine):
UserModel: User = db.User
ghost_user = UserModel()
ghost_user.name = UserModel.GHOST_USER.capitalize()
ghost_user.username = UserModel.GHOST_USER
ghost_user.lastname = "User"
ghost_user.strict_creation_check = False
ghost_user.email = UserModel.GHOST_USER_EMAIL
ghost_user.active = False
ghost_user.description = "System user to own assets of deleted users (does not consume license slot)"
ghost_user.is_new_user = False
if not User.get_by_username(UserModel.GHOST_USER):
ghost_user = UserModel()
ghost_user.name = UserModel.GHOST_USER.capitalize()
ghost_user.username = UserModel.GHOST_USER
ghost_user.lastname = "User"
ghost_user.strict_creation_check = False
ghost_user.email = UserModel.GHOST_USER_EMAIL
ghost_user.active = False
ghost_user.description = "System user to own assets of deleted users (does not consume license slot)"
ghost_user.is_new_user = False
session = meta.Session()
session.add(ghost_user)
session.commit()
session = meta.Session()
session.add(ghost_user)
session.commit()
def downgrade(migrate_engine):