Coverage for crateweb/research/migrations/0001_initial.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-08-27 10:34 -0500

1""" 

2crate_anon/crateweb/research/migrations/0001_initial.py 

3 

4=============================================================================== 

5 

6 Copyright (C) 2015, University of Cambridge, Department of Psychiatry. 

7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk). 

8 

9 This file is part of CRATE. 

10 

11 CRATE is free software: you can redistribute it and/or modify 

12 it under the terms of the GNU General Public License as published by 

13 the Free Software Foundation, either version 3 of the License, or 

14 (at your option) any later version. 

15 

16 CRATE is distributed in the hope that it will be useful, 

17 but WITHOUT ANY WARRANTY; without even the implied warranty of 

18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

19 GNU General Public License for more details. 

20 

21 You should have received a copy of the GNU General Public License 

22 along with CRATE. If not, see <https://www.gnu.org/licenses/>. 

23 

24=============================================================================== 

25 

26**Research app, migration 0001.** 

27 

28""" 

29 

30from __future__ import unicode_literals 

31 

32from django.db import migrations, models 

33 

34# noinspection PyPackageRequirements 

35import picklefield.fields 

36from django.conf import settings 

37 

38 

39class Migration(migrations.Migration): 

40 

41 dependencies = [ 

42 migrations.swappable_dependency(settings.AUTH_USER_MODEL), 

43 ] 

44 

45 operations = [ 

46 migrations.CreateModel( 

47 name="PidLookup", 

48 fields=[ 

49 ( 

50 "pid", 

51 models.PositiveIntegerField( 

52 serialize=False, 

53 primary_key=True, 

54 db_column="patient_id", 

55 ), 

56 ), 

57 ("mpid", models.PositiveIntegerField(db_column="nhsnum")), 

58 ("rid", models.CharField(max_length=255, db_column="brcid")), 

59 ( 

60 "mrid", 

61 models.CharField(max_length=255, db_column="nhshash"), 

62 ), 

63 ("trid", models.PositiveIntegerField(db_column="trid")), 

64 ], 

65 options={ 

66 "managed": False, 

67 "db_table": "secret_map", 

68 }, 

69 ), 

70 migrations.CreateModel( 

71 name="Highlight", 

72 fields=[ 

73 ("id", models.AutoField(serialize=False, primary_key=True)), 

74 ( 

75 "colour", 

76 models.PositiveSmallIntegerField( 

77 verbose_name="Colour number" 

78 ), 

79 ), 

80 ( 

81 "text", 

82 models.CharField( 

83 max_length=255, verbose_name="Text to highlight" 

84 ), 

85 ), 

86 ("active", models.BooleanField(default=True)), 

87 ( 

88 "user", 

89 models.ForeignKey( 

90 to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE 

91 ), 

92 ), 

93 ], 

94 ), 

95 migrations.CreateModel( 

96 name="Query", 

97 fields=[ 

98 ("id", models.AutoField(serialize=False, primary_key=True)), 

99 ("sql", models.TextField(verbose_name="SQL query")), 

100 ( 

101 "args", 

102 picklefield.fields.PickledObjectField( 

103 verbose_name="Pickled arguments", 

104 null=True, 

105 editable=False, 

106 ), 

107 ), 

108 ( 

109 "raw", 

110 models.BooleanField( 

111 verbose_name="SQL is raw, not parameter-substituted", 

112 default=False, 

113 ), 

114 ), 

115 ( 

116 "qmark", 

117 models.BooleanField( 

118 verbose_name=( 

119 "Parameter-substituted SQL uses ?, not %s, as" 

120 " placeholders" 

121 ), 

122 default=True, 

123 ), 

124 ), 

125 ("active", models.BooleanField(default=True)), 

126 ("created", models.DateTimeField(auto_now_add=True)), 

127 ( 

128 "deleted", 

129 models.BooleanField( 

130 verbose_name=( 

131 "Deleted from the user's perspective. Audited" 

132 " queries are never properly deleted." 

133 ), 

134 default=False, 

135 ), 

136 ), 

137 ("audited", models.BooleanField(default=False)), 

138 ( 

139 "user", 

140 models.ForeignKey( 

141 to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE 

142 ), 

143 ), 

144 ], 

145 ), 

146 migrations.CreateModel( 

147 name="QueryAudit", 

148 fields=[ 

149 ("id", models.AutoField(serialize=False, primary_key=True)), 

150 ("when", models.DateTimeField(auto_now_add=True)), 

151 ("count_only", models.BooleanField(default=False)), 

152 ("n_records", models.PositiveIntegerField(default=0)), 

153 ("failed", models.BooleanField(default=False)), 

154 ("fail_msg", models.TextField()), 

155 ( 

156 "query", 

157 models.ForeignKey( 

158 to="research.Query", on_delete=models.PROTECT 

159 ), 

160 ), 

161 ], 

162 ), 

163 ]