diff --git a/schema/schema_template.py b/schema/schema_template.py index bc0f80e..8b635ff 100644 --- a/schema/schema_template.py +++ b/schema/schema_template.py @@ -12,7 +12,7 @@ import enum from astrodbkit2.astrodb import Base -from sqlalchemy import Column, DateTime, Float, ForeignKey, Integer, String +from sqlalchemy import Column, DateTime, Float, ForeignKey, Integer, String, Boolean from sqlalchemy.orm import validates # Globals @@ -338,4 +338,65 @@ def validate_comments(self, key, value): check_string_length(value, DESCRIPTION_STRING_LENGTH, key) return value +class Parallax(Base): + # This is an example of a measurement table (see below, commented-out table as another example) + + __tablename__ = 'Parallax' + source = Column( + String(100), + ForeignKey("Sources.source", ondelete="cascade", onupdate="cascade"), + nullable=False, + primary_key=True, + ) + + # always note units, following the practices of Chen et al. 2022. + parallax_mas = Column(Float, nullable=False) + + parallax_error = Column(Float) # todo: make asymmetric errors + adopted = Column(Boolean) # flag for indicating if this is the adopted + comments = Column(String(1000)) + reference = Column( + String(30), + ForeignKey("Publications.reference", onupdate="cascade"), + primary_key=True, + ) + + @validates("comment") + def validate_comment_length(self, key, value): + check_string_length(value, 1000, key) + return value + +# class Measurement(Base): +# # This is a template table that you can fill in with your own measurement. +# . This is a placeholder for a table that would store measurements such as parallax. +# +# __tablename__ = 'Measurement' +# source = Column( +# String(100), +# ForeignKey("Sources.source", ondelete="cascade", onupdate="cascade"), +# nullable=False, +# primary_key=True, +# ) +# +# # units should be included in the column name. +# # e.g., for parallax measured in milliarcseconds, this would read parallax_mas +# measurement = Column(Float, nullable=False) +# +# measurement_error = Column(Float) # todo: make asymmetric errors +# adopted = Column(Boolean) # flag for indicating if this is the adopted +# comments = Column(String(1000)) +# reference = Column( +# String(30), +# ForeignKey("Publications.reference", onupdate="cascade"), +# primary_key=True, +# ) +# +# @validates("comment") +# def validate_comment_length(self, key, value): +# check_string_length(value, 1000, key) +# return value + + + +