Coverage for .tox/coverage/lib/python3.11/site-packages/wuttjamaican/db/model/upgrades.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-08-26 14:27 -0500

1# -*- coding: utf-8; -*- 

2################################################################################ 

3# 

4# WuttJamaican -- Base package for Wutta Framework 

5# Copyright © 2023-2024 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""" 

26 

27import datetime 

28 

29import sqlalchemy as sa 

30from sqlalchemy import orm 

31 

32from .base import Base, uuid_column, uuid_fk_column 

33from wuttjamaican.enum import UpgradeStatus 

34 

35 

36class Upgrade(Base): 

37 """ 

38 Represents an app upgrade. 

39 """ 

40 __tablename__ = 'upgrade' 

41 

42 uuid = uuid_column() 

43 

44 created = sa.Column(sa.DateTime(timezone=True), nullable=False, 

45 default=datetime.datetime.now, doc=""" 

46 When the upgrade record was created. 

47 """) 

48 

49 created_by_uuid = uuid_fk_column('user.uuid', nullable=False) 

50 created_by = orm.relationship( 

51 'User', 

52 foreign_keys=[created_by_uuid], 

53 doc=""" 

54 :class:`~wuttjamaican.db.model.auth.User` who created the 

55 upgrade record. 

56 """) 

57 

58 description = sa.Column(sa.String(length=255), nullable=False, doc=""" 

59 Basic (identifying) description for the upgrade. 

60 """) 

61 

62 notes = sa.Column(sa.Text(), nullable=True, doc=""" 

63 Notes for the upgrade. 

64 """) 

65 

66 executing = sa.Column(sa.Boolean(), nullable=False, default=False, doc=""" 

67 Whether or not the upgrade is currently being performed. 

68 """) 

69 

70 status = sa.Column(sa.Enum(UpgradeStatus), nullable=False, doc=""" 

71 Current status for the upgrade. This field uses an enum, 

72 :class:`~wuttjamaican.enum.UpgradeStatus`. 

73 """) 

74 

75 executed = sa.Column(sa.DateTime(timezone=True), nullable=True, doc=""" 

76 When the upgrade was executed. 

77 """) 

78 

79 executed_by_uuid = uuid_fk_column('user.uuid', nullable=True) 

80 executed_by = orm.relationship( 

81 'User', 

82 foreign_keys=[executed_by_uuid], 

83 doc=""" 

84 :class:`~wuttjamaican.db.model.auth.User` who executed the 

85 upgrade. 

86 """) 

87 

88 exit_code = sa.Column(sa.Integer(), nullable=True, doc=""" 

89 Exit code for the upgrade execution process, if applicable. 

90 """) 

91 

92 def __str__(self): 

93 return str(self.description or "")