@@ -40,6 +40,7 @@ class SimulationMetadata(Base):
4040 # Scenario information
4141 dataset = Column (String , nullable = False ) # e.g., "frs_2023_24"
4242 scenario = Column (String , nullable = False ) # e.g., "baseline"
43+ model_version = Column (String , nullable = True ) # e.g., "0.5.2"
4344
4445 # Processing metadata
4546 status = Column (Enum (SimulationStatus ), default = SimulationStatus .PENDING , nullable = False )
@@ -65,24 +66,83 @@ class DatasetMetadata(Base):
6566 # Dataset characteristics
6667 source = Column (String , nullable = True ) # "FRS", "CPS", etc.
6768 version = Column (String , nullable = True )
69+ model_version = Column (String , nullable = True ) # e.g., "0.5.2"
6870
6971 # Metadata
7072 description = Column (Text , nullable = True )
7173 created_at = Column (DateTime , default = datetime .now )
7274 updated_at = Column (DateTime , default = datetime .now , onupdate = datetime .now )
7375
7476
75- class Scenario (Base ):
77+ class ScenarioMetadata (Base ):
7678 """Modifications made to baseline simulation behaviour."""
7779 __tablename__ = "scenarios"
7880
7981 id = Column (String , primary_key = True , default = generate_uuid )
8082 name = Column (String , nullable = False , unique = True , index = True )
8183 country = Column (String , nullable = False , index = True )
84+ model_version = Column (String , nullable = True ) # e.g., "0.5.2"
8285
8386 # Metadata
8487 description = Column (Text , nullable = True )
8588
8689 created_at = Column (DateTime , default = datetime .now )
8790 updated_at = Column (DateTime , default = datetime .now , onupdate = datetime .now )
8891 created_by = Column (String , nullable = True )
92+
93+ # Relationships
94+ parameter_changes = relationship ("ParameterChange" , back_populates = "scenario" , cascade = "all, delete-orphan" )
95+
96+
97+ class ParameterMetadata (Base ):
98+ """Registry of all parameters that can be modified."""
99+ __tablename__ = "parameters"
100+
101+ id = Column (String , primary_key = True , default = generate_uuid )
102+ name = Column (String , nullable = False , unique = True , index = True ) # e.g., "gov.basic_rate"
103+ country = Column (String , nullable = False , index = True )
104+ parent_id = Column (String , ForeignKey ("parameters.id" ), nullable = True )
105+
106+ # Parameter metadata
107+ label = Column (String , nullable = True ) # Human-readable name
108+ description = Column (Text , nullable = True )
109+ unit = Column (String , nullable = True ) # e.g., "GBP", "percent", "boolean"
110+ data_type = Column (String , nullable = False ) # "float", "int", "bool", "string"
111+
112+ # Metadata
113+ created_at = Column (DateTime , default = datetime .now )
114+ updated_at = Column (DateTime , default = datetime .now , onupdate = datetime .now )
115+
116+ # Relationships
117+ changes = relationship ("ParameterChange" , back_populates = "parameter" , cascade = "all, delete-orphan" )
118+
119+
120+ class ParameterChangeMetadata (Base ):
121+ """Individual parameter change within a scenario."""
122+ __tablename__ = "parameter_changes"
123+
124+ id = Column (String , primary_key = True , default = generate_uuid )
125+
126+ # Foreign keys
127+ scenario_id = Column (String , ForeignKey ("scenarios.id" ), nullable = False , index = True )
128+ parameter_id = Column (String , ForeignKey ("parameters.id" ), nullable = False , index = True )
129+
130+ # Time period for this change
131+ start_date = Column (DateTime , nullable = False , index = True ) # When this change takes effect
132+ end_date = Column (DateTime , nullable = True , index = True ) # When this change expires (null = indefinite)
133+
134+ # The actual change
135+ value = Column (JSON , nullable = False ) # JSON to handle different data types
136+
137+ # Ordering within scenario (for applying changes in sequence)
138+ order_index = Column (Integer , nullable = False , default = 0 )
139+
140+ # Metadata
141+ model_version = Column (String , nullable = True ) # e.g., "0.5.2"
142+ description = Column (Text , nullable = True ) # Optional description of this specific change
143+ created_at = Column (DateTime , default = datetime .now )
144+ updated_at = Column (DateTime , default = datetime .now , onupdate = datetime .now )
145+
146+ # Relationships
147+ scenario = relationship ("Scenario" , back_populates = "parameter_changes" )
148+ parameter = relationship ("Parameter" , back_populates = "changes" )
0 commit comments