hapi-schema 0.8.9__tar.gz → 0.8.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/PKG-INFO +1 -1
  2. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/changelog.md +7 -0
  3. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/_version.py +2 -2
  4. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_patch.py +7 -3
  5. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_views_as_tables.py +98 -33
  6. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_patch.py +1 -2
  7. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_views_as_tables.py +3 -2
  8. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.config/coveragerc +0 -0
  9. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.config/pre-commit-config.yaml +0 -0
  10. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.config/pytest.ini +0 -0
  11. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.config/ruff.toml +0 -0
  12. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.github/workflows/publish.yaml +0 -0
  13. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.github/workflows/run-python-tests.yaml +0 -0
  14. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/.gitignore +0 -0
  15. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/LICENSE +0 -0
  16. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/README.md +0 -0
  17. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/contributing.md +0 -0
  18. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/docker/docker-compose.yml +0 -0
  19. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/initialize_test_db.sh +0 -0
  20. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/pyproject.toml +0 -0
  21. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/requirements.txt +0 -0
  22. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/__init__.py +0 -0
  23. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_admin1.py +0 -0
  24. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_admin2.py +0 -0
  25. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_conflict_event.py +0 -0
  26. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_currency.py +0 -0
  27. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_dataset.py +0 -0
  28. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_food_price.py +0 -0
  29. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_food_security.py +0 -0
  30. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_funding.py +0 -0
  31. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_humanitarian_needs.py +0 -0
  32. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_location.py +0 -0
  33. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_national_risk.py +0 -0
  34. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_operational_presence.py +0 -0
  35. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_org.py +0 -0
  36. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_org_type.py +0 -0
  37. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_population.py +0 -0
  38. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_poverty_rate.py +0 -0
  39. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_refugees.py +0 -0
  40. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_resource.py +0 -0
  41. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_sector.py +0 -0
  42. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_wfp_commodity.py +0 -0
  43. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/db_wfp_market.py +0 -0
  44. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/__init__.py +0 -0
  45. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/base.py +0 -0
  46. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/constraints.py +0 -0
  47. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/enums.py +0 -0
  48. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/hapi_views_code_generator.py +0 -0
  49. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/view_as_table_code_generator.py +0 -0
  50. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/view_as_table_definitions.toml +0 -0
  51. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/utils/view_params.py +0 -0
  52. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/src/hapi_schema/views.py +0 -0
  53. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/conftest.py +0 -0
  54. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/__init__.py +0 -0
  55. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_admin1.py +0 -0
  56. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_admin2.py +0 -0
  57. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_conflict_event.py +0 -0
  58. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_currency.py +0 -0
  59. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_dataset.py +0 -0
  60. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_food_price.py +0 -0
  61. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_food_security.py +0 -0
  62. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_funding.py +0 -0
  63. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_humanitarian_needs.py +0 -0
  64. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_location.py +0 -0
  65. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_national_risk.py +0 -0
  66. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_operational_presence.py +0 -0
  67. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_org.py +0 -0
  68. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_org_type.py +0 -0
  69. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_patch.py +0 -0
  70. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_population.py +0 -0
  71. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_poverty_rate.py +0 -0
  72. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_refugees.py +0 -0
  73. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_resource.py +0 -0
  74. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_sector.py +0 -0
  75. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_wfp_commodity.py +0 -0
  76. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/sample_data/data_wfp_market.py +0 -0
  77. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_admin1.py +0 -0
  78. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_admin2.py +0 -0
  79. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_conflict_event.py +0 -0
  80. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_currency.py +0 -0
  81. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_dataset.py +0 -0
  82. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_food_price.py +0 -0
  83. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_food_security.py +0 -0
  84. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_funding.py +0 -0
  85. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_humanitarian_needs.py +0 -0
  86. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_location.py +0 -0
  87. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_national_risk.py +0 -0
  88. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_operational_presence.py +0 -0
  89. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_org.py +0 -0
  90. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_org_type.py +0 -0
  91. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_population.py +0 -0
  92. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_poverty_rate.py +0 -0
  93. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_refugees.py +0 -0
  94. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_resource.py +0 -0
  95. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_sector.py +0 -0
  96. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_wfp_commodity.py +0 -0
  97. {hapi_schema-0.8.9 → hapi_schema-0.8.10}/tests/test_wfp_market.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hapi-schema
3
- Version: 0.8.9
3
+ Version: 0.8.10
4
4
  Summary: HAPI database schema specified in SQLAlchemy
5
5
  Project-URL: Homepage, https://github.com/OCHA-DAP/hapi-schemas
6
6
  Author-email: Simon Johnson <simon.johnson@un.org>
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.8.10
9
+
10
+ ### Changes
11
+
12
+ - Adapted primary keys and make columsn nullable in the VAT tables
13
+ - Use the enum casting util in the patch table
14
+
8
15
  ## 0.8.9
9
16
 
10
17
  ### Fixed
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.8.9'
16
- __version_tuple__ = version_tuple = (0, 8, 9)
15
+ __version__ = version = '0.8.10'
16
+ __version_tuple__ = version_tuple = (0, 8, 10)
@@ -25,16 +25,20 @@ class DBPatch(Base):
25
25
  patch_sequence_number: Mapped[int] = mapped_column(
26
26
  Integer, nullable=False, index=True
27
27
  )
28
- commit_hash: Mapped[str] = mapped_column(String(48), nullable=False)
28
+ commit_hash: Mapped[str] = mapped_column(
29
+ String(48), unique=False, nullable=False
30
+ )
29
31
  commit_date: Mapped[datetime] = mapped_column(DateTime, nullable=False)
30
32
  patch_path: Mapped[str] = mapped_column(
31
33
  String(512), nullable=False, index=True
32
34
  )
33
35
  patch_permalink_url: Mapped[str] = mapped_column(
34
- String(1024), nullable=False, unique=True
36
+ String(1024), nullable=False, unique=False
35
37
  )
36
38
  patch_target: Mapped[str] = mapped_column(String(128), nullable=False)
37
- patch_hash: Mapped[str] = mapped_column(String(48), nullable=False)
39
+ patch_hash: Mapped[str] = mapped_column(
40
+ String(48), unique=False, nullable=False
41
+ )
38
42
  state: Mapped[StateEnum] = mapped_column(
39
43
  Enum(StateEnum), nullable=False, index=True
40
44
  )
@@ -11,6 +11,20 @@ from sqlalchemy import (
11
11
  from sqlalchemy.orm import Mapped, mapped_column
12
12
 
13
13
  from hapi_schema.utils.base import Base
14
+ from hapi_schema.utils.enums import (
15
+ CommodityCategory,
16
+ DisabledMarker,
17
+ EventType,
18
+ Gender,
19
+ IPCPhase,
20
+ IPCType,
21
+ PopulationGroup,
22
+ PopulationStatus,
23
+ PriceFlag,
24
+ PriceType,
25
+ RiskClass,
26
+ build_enum_using_values,
27
+ )
14
28
 
15
29
 
16
30
  class DBAdmin1VAT(Base):
@@ -25,7 +39,9 @@ class DBAdmin1VAT(Base):
25
39
  DateTime, index=True
26
40
  )
27
41
  reference_period_end: Mapped[datetime] = mapped_column(
28
- DateTime, index=True
42
+ DateTime,
43
+ index=True,
44
+ nullable=True,
29
45
  )
30
46
  location_code: Mapped[str] = mapped_column(String(128), index=True)
31
47
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -43,7 +59,9 @@ class DBAdmin2VAT(Base):
43
59
  DateTime, nullable=True, index=True
44
60
  )
45
61
  reference_period_end: Mapped[datetime] = mapped_column(
46
- DateTime, nullable=True, index=True
62
+ DateTime,
63
+ nullable=True,
64
+ index=True,
47
65
  )
48
66
  admin1_code: Mapped[str] = mapped_column(String(128))
49
67
  admin1_name: Mapped[str] = mapped_column(String(512))
@@ -56,14 +74,18 @@ class DBConflictEventVAT(Base):
56
74
  __tablename__ = "conflict_event_vat"
57
75
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
58
76
  admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
59
- event_type: Mapped[str] = mapped_column(String(18), primary_key=True)
77
+ event_type: Mapped[EventType] = mapped_column(
78
+ build_enum_using_values(EventType), primary_key=True
79
+ )
60
80
  events: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
61
81
  fatalities: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
62
82
  reference_period_start: Mapped[datetime] = mapped_column(
63
83
  DateTime, primary_key=True
64
84
  )
65
85
  reference_period_end: Mapped[datetime] = mapped_column(
66
- DateTime, index=True
86
+ DateTime,
87
+ index=True,
88
+ nullable=True,
67
89
  )
68
90
  location_code: Mapped[str] = mapped_column(String(128), index=True)
69
91
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -98,22 +120,28 @@ class DBFoodPriceVAT(Base):
98
120
  market_code: Mapped[str] = mapped_column(String(32), primary_key=True)
99
121
  commodity_code: Mapped[str] = mapped_column(String(32), primary_key=True)
100
122
  currency_code: Mapped[str] = mapped_column(String(32), index=True)
101
- unit: Mapped[str] = mapped_column(String(32))
102
- price_flag: Mapped[str] = mapped_column(String(16), primary_key=True)
103
- price_type: Mapped[str] = mapped_column(String(9), primary_key=True)
123
+ unit: Mapped[str] = mapped_column(String(32), primary_key=True)
124
+ price_flag: Mapped[PriceFlag] = mapped_column(
125
+ build_enum_using_values(PriceFlag), primary_key=True
126
+ )
127
+ price_type: Mapped[PriceType] = mapped_column(
128
+ build_enum_using_values(PriceType), primary_key=True
129
+ )
104
130
  price: Mapped[Decimal] = mapped_column()
105
131
  reference_period_start: Mapped[datetime] = mapped_column(
106
132
  DateTime, primary_key=True
107
133
  )
108
134
  reference_period_end: Mapped[datetime] = mapped_column(
109
- DateTime, index=True
135
+ DateTime,
136
+ index=True,
137
+ nullable=True,
110
138
  )
111
139
  admin2_ref: Mapped[int] = mapped_column(Integer)
112
140
  market_name: Mapped[str] = mapped_column(String(512), index=True)
113
141
  lat: Mapped[float] = mapped_column(Float, index=True)
114
142
  lon: Mapped[float] = mapped_column(Float, index=True)
115
- commodity_category: Mapped[str] = mapped_column(
116
- String(18), primary_key=True
143
+ commodity_category: Mapped[CommodityCategory] = mapped_column(
144
+ build_enum_using_values(CommodityCategory)
117
145
  )
118
146
  commodity_name: Mapped[str] = mapped_column(String(512), index=True)
119
147
  location_code: Mapped[str] = mapped_column(String(128), index=True)
@@ -132,15 +160,21 @@ class DBFoodSecurityVAT(Base):
132
160
  __tablename__ = "food_security_vat"
133
161
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
134
162
  admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
135
- ipc_phase: Mapped[str] = mapped_column(String(12), primary_key=True)
136
- ipc_type: Mapped[str] = mapped_column(String(17), primary_key=True)
163
+ ipc_phase: Mapped[IPCPhase] = mapped_column(
164
+ build_enum_using_values(IPCPhase), primary_key=True
165
+ )
166
+ ipc_type: Mapped[IPCType] = mapped_column(
167
+ build_enum_using_values(IPCType), primary_key=True
168
+ )
137
169
  population_in_phase: Mapped[int] = mapped_column(Integer, index=True)
138
170
  population_fraction_in_phase: Mapped[Decimal] = mapped_column(index=True)
139
171
  reference_period_start: Mapped[datetime] = mapped_column(
140
172
  DateTime, primary_key=True
141
173
  )
142
174
  reference_period_end: Mapped[datetime] = mapped_column(
143
- DateTime, index=True
175
+ DateTime,
176
+ index=True,
177
+ nullable=True,
144
178
  )
145
179
  location_code: Mapped[str] = mapped_column(String(128), index=True)
146
180
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -168,7 +202,8 @@ class DBFundingVAT(Base):
168
202
  DateTime, index=True
169
203
  )
170
204
  reference_period_end: Mapped[datetime] = mapped_column(
171
- DateTime, nullable=True
205
+ DateTime,
206
+ nullable=True,
172
207
  )
173
208
  location_code: Mapped[str] = mapped_column(String(128), index=True)
174
209
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -178,22 +213,30 @@ class DBHumanitarianNeedsVAT(Base):
178
213
  __tablename__ = "humanitarian_needs_vat"
179
214
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
180
215
  admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
181
- gender: Mapped[str] = mapped_column(String(11), primary_key=True)
216
+ gender: Mapped[Gender] = mapped_column(
217
+ build_enum_using_values(Gender), primary_key=True
218
+ )
182
219
  age_range: Mapped[str] = mapped_column(String(32), primary_key=True)
183
220
  min_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
184
221
  max_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
185
- sector_code: Mapped[str] = mapped_column(String(32))
186
- population_group: Mapped[str] = mapped_column(String(14), primary_key=True)
187
- population_status: Mapped[str] = mapped_column(
188
- String(10), primary_key=True
222
+ sector_code: Mapped[str] = mapped_column(String(32), primary_key=True)
223
+ population_group: Mapped[PopulationGroup] = mapped_column(
224
+ build_enum_using_values(PopulationGroup), primary_key=True
225
+ )
226
+ population_status: Mapped[PopulationStatus] = mapped_column(
227
+ build_enum_using_values(PopulationStatus), primary_key=True
189
228
  )
190
- disabled_marker: Mapped[str] = mapped_column(String(3), primary_key=True)
191
- population: Mapped[int] = mapped_column(Integer, primary_key=True)
229
+ disabled_marker: Mapped[DisabledMarker] = mapped_column(
230
+ build_enum_using_values(DisabledMarker), primary_key=True
231
+ )
232
+ population: Mapped[int] = mapped_column(Integer)
192
233
  reference_period_start: Mapped[datetime] = mapped_column(
193
234
  DateTime, primary_key=True
194
235
  )
195
236
  reference_period_end: Mapped[datetime] = mapped_column(
196
- DateTime, index=True
237
+ DateTime,
238
+ index=True,
239
+ nullable=True,
197
240
  )
198
241
  sector_name: Mapped[str] = mapped_column(String(512))
199
242
  location_code: Mapped[str] = mapped_column(String(128), index=True)
@@ -218,7 +261,9 @@ class DBLocationVAT(Base):
218
261
  DateTime, index=True
219
262
  )
220
263
  reference_period_end: Mapped[datetime] = mapped_column(
221
- DateTime, index=True
264
+ DateTime,
265
+ index=True,
266
+ nullable=True,
222
267
  )
223
268
 
224
269
 
@@ -226,7 +271,9 @@ class DBNationalRiskVAT(Base):
226
271
  __tablename__ = "national_risk_vat"
227
272
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
228
273
  location_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
229
- risk_class: Mapped[str] = mapped_column(String(9))
274
+ risk_class: Mapped[RiskClass] = mapped_column(
275
+ build_enum_using_values(RiskClass)
276
+ )
230
277
  global_rank: Mapped[int] = mapped_column(Integer)
231
278
  overall_risk: Mapped[Decimal] = mapped_column()
232
279
  hazard_exposure_risk: Mapped[Decimal] = mapped_column()
@@ -238,7 +285,9 @@ class DBNationalRiskVAT(Base):
238
285
  DateTime, primary_key=True
239
286
  )
240
287
  reference_period_end: Mapped[datetime] = mapped_column(
241
- DateTime, index=True
288
+ DateTime,
289
+ index=True,
290
+ nullable=True,
242
291
  )
243
292
  location_code: Mapped[str] = mapped_column(String(128), index=True)
244
293
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -255,7 +304,9 @@ class DBOperationalPresenceVAT(Base):
255
304
  DateTime, primary_key=True
256
305
  )
257
306
  reference_period_end: Mapped[datetime] = mapped_column(
258
- DateTime, index=True
307
+ DateTime,
308
+ index=True,
309
+ nullable=True,
259
310
  )
260
311
  org_type_code: Mapped[str] = mapped_column(String(32))
261
312
  org_type_description: Mapped[str] = mapped_column(String(512), index=True)
@@ -292,7 +343,9 @@ class DBPopulationVAT(Base):
292
343
  __tablename__ = "population_vat"
293
344
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
294
345
  admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
295
- gender: Mapped[str] = mapped_column(String(11), primary_key=True)
346
+ gender: Mapped[Gender] = mapped_column(
347
+ build_enum_using_values(Gender), primary_key=True
348
+ )
296
349
  age_range: Mapped[str] = mapped_column(String(32), primary_key=True)
297
350
  min_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
298
351
  max_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
@@ -301,7 +354,9 @@ class DBPopulationVAT(Base):
301
354
  DateTime, index=True
302
355
  )
303
356
  reference_period_end: Mapped[datetime] = mapped_column(
304
- DateTime, index=True
357
+ DateTime,
358
+ index=True,
359
+ nullable=True,
305
360
  )
306
361
  location_code: Mapped[str] = mapped_column(String(128), index=True)
307
362
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -331,7 +386,9 @@ class DBPovertyRateVAT(Base):
331
386
  DateTime, primary_key=True
332
387
  )
333
388
  reference_period_end: Mapped[datetime] = mapped_column(
334
- DateTime, index=True
389
+ DateTime,
390
+ index=True,
391
+ nullable=True,
335
392
  )
336
393
  location_code: Mapped[str] = mapped_column(String(128), index=True)
337
394
  location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -345,8 +402,12 @@ class DBRefugeesVAT(Base):
345
402
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
346
403
  origin_location_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
347
404
  asylum_location_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
348
- population_group: Mapped[str] = mapped_column(String(14))
349
- gender: Mapped[str] = mapped_column(String(11), primary_key=True)
405
+ population_group: Mapped[PopulationGroup] = mapped_column(
406
+ build_enum_using_values(PopulationGroup), primary_key=True
407
+ )
408
+ gender: Mapped[Gender] = mapped_column(
409
+ build_enum_using_values(Gender), primary_key=True
410
+ )
350
411
  age_range: Mapped[str] = mapped_column(String(32), primary_key=True)
351
412
  min_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
352
413
  max_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
@@ -355,7 +416,9 @@ class DBRefugeesVAT(Base):
355
416
  DateTime, primary_key=True
356
417
  )
357
418
  reference_period_end: Mapped[datetime] = mapped_column(
358
- DateTime, index=True
419
+ DateTime,
420
+ index=True,
421
+ nullable=True,
359
422
  )
360
423
  origin_location_code: Mapped[str] = mapped_column(String(128), index=True)
361
424
  origin_location_name: Mapped[str] = mapped_column(String(512), index=True)
@@ -392,7 +455,9 @@ class DBSectorVAT(Base):
392
455
  class DBWfpCommodityVAT(Base):
393
456
  __tablename__ = "wfp_commodity_vat"
394
457
  code: Mapped[str] = mapped_column(String(32), primary_key=True)
395
- category: Mapped[str] = mapped_column(String(18), index=True)
458
+ category: Mapped[CommodityCategory] = mapped_column(
459
+ build_enum_using_values(CommodityCategory), index=True
460
+ )
396
461
  name: Mapped[str] = mapped_column(String(512), index=True)
397
462
 
398
463
 
@@ -20,8 +20,7 @@ def test_db_patch(capfd):
20
20
  patch_hash VARCHAR(48) NOT NULL,
21
21
  state VARCHAR(10) NOT NULL,
22
22
  execution_date DATETIME,
23
- PRIMARY KEY (id),
24
- UNIQUE (patch_permalink_url)
23
+ PRIMARY KEY (id)
25
24
  )
26
25
  """
27
26
  sql_patch_sequence_number_index_creation = """
@@ -112,7 +112,7 @@ def test_food_price_vat(
112
112
  expected_primary_keys = [
113
113
  "market_code",
114
114
  "commodity_code",
115
- "commodity_category",
115
+ "unit",
116
116
  "price_flag",
117
117
  "price_type",
118
118
  "reference_period_start",
@@ -192,10 +192,10 @@ def test_humanitarian_needs_vat(
192
192
  "admin2_ref",
193
193
  "gender",
194
194
  "age_range",
195
+ "sector_code",
195
196
  "population_group",
196
197
  "population_status",
197
198
  "disabled_marker",
198
- "population",
199
199
  "reference_period_start",
200
200
  ]
201
201
  expected_indexes = [
@@ -370,6 +370,7 @@ def test_refugees_vat(
370
370
  expected_primary_keys = [
371
371
  "origin_location_ref",
372
372
  "asylum_location_ref",
373
+ "population_group",
373
374
  "gender",
374
375
  "age_range",
375
376
  "reference_period_start",
File without changes
File without changes
File without changes
File without changes