Coverage for .tox/coverage/lib/python3.11/site-packages/wuttjamaican/db/model/upgrades.py: 100%
22 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-12-15 16:29 -0600
« prev ^ index » next coverage.py v7.11.0, created at 2025-12-15 16:29 -0600
1# -*- coding: utf-8; -*-
2################################################################################
3#
4# WuttJamaican -- Base package for Wutta Framework
5# Copyright © 2023-2025 Lance Edgar
6#
7# This file is part of Wutta Framework.
8#
9# Wutta Framework is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by the Free
11# Software Foundation, either version 3 of the License, or (at your option) any
12# later version.
13#
14# Wutta Framework is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17# more details.
18#
19# You should have received a copy of the GNU General Public License along with
20# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
21#
22################################################################################
23"""
24Upgrade Model
25"""
27import sqlalchemy as sa
28from sqlalchemy import orm
30from wuttjamaican.enum import UpgradeStatus
31from wuttjamaican.db.util import uuid_column, uuid_fk_column
32from wuttjamaican.db.model.base import Base
33from wuttjamaican.util import make_utc
36class Upgrade(Base): # pylint: disable=too-few-public-methods
37 """
38 Represents an app upgrade.
39 """
41 __tablename__ = "upgrade"
43 uuid = uuid_column()
45 created = sa.Column(
46 sa.DateTime(),
47 nullable=False,
48 default=make_utc,
49 doc="""
50 When the upgrade record was created.
51 """,
52 )
54 created_by_uuid = uuid_fk_column("user.uuid", nullable=False)
55 created_by = orm.relationship(
56 "User",
57 foreign_keys=[created_by_uuid],
58 cascade_backrefs=False,
59 doc="""
60 :class:`~wuttjamaican.db.model.auth.User` who created the
61 upgrade record.
62 """,
63 )
65 description = sa.Column(
66 sa.String(length=255),
67 nullable=False,
68 doc="""
69 Basic (identifying) description for the upgrade.
70 """,
71 )
73 notes = sa.Column(
74 sa.Text(),
75 nullable=True,
76 doc="""
77 Notes for the upgrade.
78 """,
79 )
81 executing = sa.Column(
82 sa.Boolean(),
83 nullable=False,
84 default=False,
85 doc="""
86 Whether or not the upgrade is currently being performed.
87 """,
88 )
90 status = sa.Column(
91 sa.Enum(UpgradeStatus),
92 nullable=False,
93 doc="""
94 Current status for the upgrade. This field uses an enum,
95 :class:`~wuttjamaican.enum.UpgradeStatus`.
96 """,
97 )
99 executed = sa.Column(
100 sa.DateTime(),
101 nullable=True,
102 doc="""
103 When the upgrade was executed.
104 """,
105 )
107 executed_by_uuid = uuid_fk_column("user.uuid", nullable=True)
108 executed_by = orm.relationship(
109 "User",
110 foreign_keys=[executed_by_uuid],
111 cascade_backrefs=False,
112 doc="""
113 :class:`~wuttjamaican.db.model.auth.User` who executed the
114 upgrade.
115 """,
116 )
118 exit_code = sa.Column(
119 sa.Integer(),
120 nullable=True,
121 doc="""
122 Exit code for the upgrade execution process, if applicable.
123 """,
124 )
126 def __str__(self):
127 return str(self.description or "")