Coverage for .tox/coverage/lib/python3.13/site-packages/wuttjamaican/db/model/upgrades.py: 100%
23 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-07 21:12 -0500
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-07 21:12 -0500
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 target_key = sa.Column(
46 sa.String(length=100),
47 nullable=True,
48 doc="""
49 Config key for the :term:`upgrade target`. When this is null, the
50 ``default`` target is assumed.
51 """,
52 )
54 created = sa.Column(
55 sa.DateTime(),
56 nullable=False,
57 default=make_utc,
58 doc="""
59 When the upgrade record was created.
60 """,
61 )
63 created_by_uuid = uuid_fk_column("user.uuid", nullable=False)
64 created_by = orm.relationship(
65 "User",
66 foreign_keys=[created_by_uuid],
67 cascade_backrefs=False,
68 doc="""
69 :class:`~wuttjamaican.db.model.auth.User` who created the
70 upgrade record.
71 """,
72 )
74 description = sa.Column(
75 sa.String(length=255),
76 nullable=False,
77 doc="""
78 Basic (identifying) description for the upgrade.
79 """,
80 )
82 notes = sa.Column(
83 sa.Text(),
84 nullable=True,
85 doc="""
86 Notes for the upgrade.
87 """,
88 )
90 executing = sa.Column(
91 sa.Boolean(),
92 nullable=False,
93 default=False,
94 doc="""
95 Whether or not the upgrade is currently being performed.
96 """,
97 )
99 status = sa.Column(
100 sa.Enum(UpgradeStatus),
101 nullable=False,
102 doc="""
103 Current status for the upgrade. This field uses an enum,
104 :class:`~wuttjamaican.enum.UpgradeStatus`.
105 """,
106 )
108 executed = sa.Column(
109 sa.DateTime(),
110 nullable=True,
111 doc="""
112 When the upgrade was executed.
113 """,
114 )
116 executed_by_uuid = uuid_fk_column("user.uuid", nullable=True)
117 executed_by = orm.relationship(
118 "User",
119 foreign_keys=[executed_by_uuid],
120 cascade_backrefs=False,
121 doc="""
122 :class:`~wuttjamaican.db.model.auth.User` who executed the
123 upgrade.
124 """,
125 )
127 exit_code = sa.Column(
128 sa.Integer(),
129 nullable=True,
130 doc="""
131 Exit code for the upgrade execution process, if applicable.
132 """,
133 )
135 def __str__(self):
136 return str(self.description or "")