Exemple #1
0
class IntegerSequencedWithIDRecord(Base):
    __tablename__ = "integer_sequenced_items"

    # Record ID.
    id = Column(
        BigInteger().with_variant(Integer, "sqlite"),
        primary_key=True,
        index=True,
        unique=True,
    )

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), nullable=False)

    # Position (index) of item in sequence.
    position = Column(BigInteger().with_variant(Integer, "sqlite"), nullable=False)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(LargeBinary())

    __table_args__ = (
        Index(
            "integer_sequenced_items_sequence_id_position_index",
            "sequence_id",
            "position",
            unique=True,
        ),
    )
Exemple #2
0
class ExtendedIntegerSequencedRecord(Base):
    __tablename__ = 'extended_integer_sequenced_items'

    id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), nullable=False)

    # Position (index) of item in sequence.
    position = Column(BigInteger(), nullable=False)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(String(255), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())

    # Timestamp of the event.
    timestamp = Column(DECIMAL(24, 6, 6), nullable=False)
    # timestamp = Column(DECIMAL(27, 9, 9), nullable=False)

    # Type of the event (class name).
    event_type = Column(String(255))

    __table_args__ = (Index('integer_sequenced_items_index',
                            'sequence_id',
                            'position',
                            unique=True), )
Exemple #3
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "stored_events",
        sa.Column("application_name", sa.String(length=32), nullable=False),
        sa.Column("originator_id",
                  sqlalchemy_utils.types.uuid.UUIDType(),
                  nullable=False),
        sa.Column(
            "originator_version",
            BigInteger().with_variant(Integer, "sqlite"),
            nullable=False,
        ),
        sa.Column("pipeline_id", sa.Integer(), nullable=True),
        sa.Column(
            "notification_id",
            BigInteger().with_variant(Integer, "sqlite"),
            nullable=True,
        ),
        sa.Column("topic", sa.Text(), nullable=False),
        sa.Column("state", sa.Text(), nullable=True),
        sa.Column("causal_dependencies", sa.Text(), nullable=True),
        sa.PrimaryKeyConstraint("application_name", "originator_id",
                                "originator_version"),
    )
    op.create_index(
        "stored_events_notification_index",
        "stored_events",
        ["application_name", "pipeline_id", "notification_id"],
        unique=True,
    )
Exemple #4
0
class StoredEventRecord(Base):
    __tablename__ = 'stored_events'

    # Record ID.
    id = Column(BigInteger().with_variant(Integer, "sqlite"),
                primary_key=True,
                index=True,
                unique=True)

    # Originator ID (e.g. an entity or aggregate ID).
    originator_id = Column(UUIDType(), nullable=False)

    # Originator version of item in sequence.
    originator_version = Column(BigInteger().with_variant(Integer, "sqlite"),
                                nullable=False)

    # Type of the event (class name).
    event_type = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())

    __table_args__ = (Index('stored_events_sequence_id_position_index',
                            'originator_id',
                            'originator_version',
                            unique=True), )
Exemple #5
0
class SqlStoredEvent(Base):
    # Explicit table name.
    __tablename__ = 'stored_events'

    # Unique constraint.
    __table_args__ = UniqueConstraint('aggregate_id',
                                      'aggregate_version',
                                      name='stored_events_uc'),

    # Primary key.
    id = Column(Integer, Sequence('stored_event_id_seq'), primary_key=True)

    # Sequence ID (e.g. an entity or aggregate ID).
    aggregate_id = Column(UUIDType(), index=True)

    # Position (timestamp) of item in sequence.
    aggregate_version = Column(BigInteger(), index=True)

    # Type of the event (class name).
    event_type = Column(String(100))

    # Timestamp of the event.
    timestamp = Column(Float())

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())
class SqlIntegerSequencedItem(Base):
    __tablename__ = 'integer_sequenced_items'

    id = Column(Integer,
                Sequence('integer_sequened_item_id_seq'),
                primary_key=True)

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), index=True)

    # Position (index) of item in sequence.
    position = Column(BigInteger(), index=True)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(String(255))

    # State of the item (serialized dict, possibly encrypted).
    data = Column(Text())

    # Unique constraint includes 'entity_id' which is a good value
    # to partition on, because all events for an entity will be in the same
    # partition, which may help performance.
    __table_args__ = UniqueConstraint('sequence_id',
                                      'position',
                                      name='integer_sequenced_item_uc'),
Exemple #7
0
class TimestampSequencedWithIDRecord(Base):
    __tablename__ = 'timestamp_sequenced_items'

    # Record ID.
    id = Column(BigInteger().with_variant(Integer, "sqlite"),
                primary_key=True,
                index=True,
                unique=True,
                autoincrement=True)

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), nullable=False)

    # Position (timestamp) of item in sequence.
    position = Column(DECIMAL(24, 6, 6), nullable=False, unique=False)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    data = Column(Text())

    __table_args__ = (
        Index('timestamp_sequenced_items_sequence_id_position_index',
              'sequence_id',
              'position',
              unique=True),
        Index('timestamp_sequenced_items_position_index',
              'position',
              unique=False),
    )
Exemple #8
0
class t_Brush(Basic.base):
    __tablename__ = "brush"

    ID = Column(BigInteger, primary_key=True)
    Name = Column(String(50))
    Description = Column(String)
    C_ID = Column(BigInteger(), ForeignKey('company.ID'))
    BT_ID = Column(BigInteger(), ForeignKey('brush_type.ID'))
    Owned = Column(Boolean, default=True)
    Deleted = Column(Boolean, default=False)
    company = relationship("t_Company", back_populates="brushes")
    brush_type = relationship("t_Brush_Type", back_populates="brushes")

    def __repr__(self):
        return "ID = {}\nName = {}\nDescription = {}\nC_ID = {}\nBT_ID = {}\nOwned = {}\nDeleted = {}".format(
            str(self.ID), self.Name, self.Description, str(self.C_ID),
            str(self.BT_ID), str(self.Owned), str(self.deleted))
Exemple #9
0
class SqlStoredEvent(Base):

    __tablename__ = 'stored_events'

    id = Column(Integer, Sequence('stored_event_id_seq'), primary_key=True)
    event_id = Column(String(255), index=True)
    timestamp_long = Column(BigInteger(), index=True)
    stored_entity_id = Column(String(255), index=True)
    event_topic = Column(String(255))
    event_attrs = Column(Text())
class StoredEventRecord(db.Model):
    """
    Original definition of StoredEventRecord retrieved from:
    https://github.com/johnbywater/eventsourcing/blob/b50f1e6c89a6412da3013b5dbc720f159124e92d/eventsourcing/infrastructure/sqlalchemy/records.py#L149-L184

    But tweaked to work with Postgres
    """

    __tablename__ = "stored_events"

    # Application ID.
    application_name = Column(String(length=32), primary_key=True)

    # Originator ID (e.g. an entity or aggregate ID).
    originator_id = Column(UUIDType(), primary_key=True)

    # Originator version of item in sequence.
    originator_version = Column(BigInteger().with_variant(Integer, "sqlite"),
                                primary_key=True)

    # Pipeline ID.
    pipeline_id = Column(Integer(), nullable=True)

    # Notification ID.
    notification_id = Column(BigInteger().with_variant(Integer, "sqlite"),
                             nullable=True)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())

    # Causal dependencies.
    causal_dependencies = Column(Text())

    __table_args__ = (Index(
        "stored_events_notification_index",
        "application_name",
        "pipeline_id",
        "notification_id",
        unique=True,
    ), )
Exemple #11
0
class StoredEventRecord(Base):
    __tablename__ = "stored_events"

    # Application ID.
    application_name = Column(String(length=32), primary_key=True)

    # Originator ID (e.g. an entity or aggregate ID).
    originator_id = Column(UUIDType(), primary_key=True)

    # Originator version of item in sequence.
    originator_version = Column(
        BigInteger().with_variant(Integer, "sqlite"), primary_key=True
    )

    # Pipeline ID.
    pipeline_id = Column(Integer(), nullable=True)

    # Notification ID.
    notification_id = Column(
        BigInteger().with_variant(Integer, "sqlite"), nullable=True
    )

    # Topic of the item (e.g. path to domain event class).
    topic = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(LargeBinary())

    # Causal dependencies.
    causal_dependencies = Column(Text())

    __table_args__ = (
        Index(
            "stored_events_notification_index",
            "application_name",
            "pipeline_id",
            "notification_id",
            unique=True,
        ),
    )
Exemple #12
0
class Account(DB_BASE):
    __tablename__ = 'account'
    __table_args__ = ({'sqlite_autoincrement': True})
    id = Column(BigInteger().with_variant(Integer, "sqlite"),
                primary_key=True,
                autoincrement=True)
    name = Column(Text, nullable=False)

    def to_dict(self):
        return {
            "id": self.id,
            "name": self.name,
        }
Exemple #13
0
class SnapshotRecord(Base):
    __tablename__ = "snapshots"

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), primary_key=True)

    # Position (index) of item in sequence.
    position = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)

    # Topic of the item (e.g. path to domain entity class).
    topic = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(LargeBinary())
class NotificationTrackingRecord(Base):
    __tablename__ = 'notification_tracking'

    # Application ID.
    application_id = Column(UUIDType(), primary_key=True)

    # Upstream application ID.
    upstream_application_id = Column(UUIDType(), primary_key=True)

    # Partition ID.
    pipeline_id = Column(Integer(), primary_key=True)

    # Notification ID.
    notification_id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)
class IntegerSequencedNoIDRecord(Base):
    __tablename__ = 'integer_sequenced_items_noid'

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), primary_key=True)

    # Position (index) of item in sequence.
    position = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    data = Column(Text())
class StoredEventRecord(Base):
    __tablename__ = 'stored_events'

    # Application ID.
    application_id = Column(UUIDType(), primary_key=True)

    # Originator ID (e.g. an entity or aggregate ID).
    originator_id = Column(UUIDType(), primary_key=True)

    # Originator version of item in sequence.
    originator_version = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)

    # Partition ID.
    pipeline_id = Column(Integer(), nullable=False)

    # Record ID.
    id = Column(BigInteger().with_variant(Integer, "sqlite"), nullable=False)

    # Type of the event (class name).
    event_type = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())

    # Causal dependencies.
    causal_dependencies = Column(Text())

    __table_args__ = (
        Index(
            'stored_events_notification_index',
            'application_id',
            'pipeline_id',
            'id',
            unique=True
        ),
    )
Exemple #17
0
class NotificationTrackingRecord(Base):
    __tablename__ = "notification_tracking"

    # Application name.
    application_name = Column(String(length=32), primary_key=True)

    # Upstream application name.
    upstream_application_name = Column(String(length=32), primary_key=True)

    # Pipeline ID.
    pipeline_id = Column(Integer(), primary_key=True)

    # Notification ID.
    notification_id = Column(BigInteger().with_variant(Integer, "sqlite"),
                             primary_key=True)
class StoredEventRecord(ActiveRecord):
    __tablename__ = 'stored_events'

    # Originator ID (e.g. an entity or aggregate ID).
    originator_id = Column(UUIDType(), primary_key=True)

    # Originator version of item in sequence.
    originator_version = Column(BigInteger(), primary_key=True)

    # Type of the event (class name).
    event_type = Column(String(100))

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())

    __table_args__ = Index('index', 'originator_id', 'originator_version'),
Exemple #19
0
class t_Paint_Scheme_Line(Basic.base):
    __tablename__ = "paint_scheme_line"

    ID = Column(BigInteger, primary_key=True)
    PS_ID = Column(BigInteger, ForeignKey('paint_scheme.ID',
                                          ondelete='CASCADE'))
    Label = Column(String(50))
    C_ID = Column(BigInteger(), ForeignKey('color.ID'))
    Deleted = Column(Boolean, default=False)
    colors = relationship("t_Color", back_populates="scheme_lines")
    schemes = relationship("t_Paint_Scheme", back_populates="lines")

    def __repr__(self):
        return "Id = {}\nPS_ID = {}\nLabel = {}\nC_ID = {}\nDeleted{}".format(
            str(self.ID), str(self.PS_ID), self.Label, str(self.C_ID),
            str(self.Deleted))
class SnapshotRecord(ActiveRecord):
    __tablename__ = 'snapshots'

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), primary_key=True)

    # Position (index) of item in sequence.
    position = Column(BigInteger(), primary_key=True)

    # Topic of the item (e.g. path to domain entity class).
    topic = Column(String(255))

    # State of the item (serialized dict, possibly encrypted).
    data = Column(Text())

    __table_args__ = (Index('snapshots_index', 'sequence_id', 'position'), )
Exemple #21
0
class EntitySnapshotRecord(Base):
    __tablename__ = 'entity_snapshots'

    # Application ID.
    application_name = Column(String(length=32), primary_key=True)

    # Originator ID (e.g. an entity or aggregate ID).
    originator_id = Column(UUIDType(), primary_key=True)

    # Originator version of item in sequence.
    originator_version = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)

    # Topic of the item (e.g. path to domain entity class).
    event_type = Column(Text(), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())
Exemple #22
0
class Equipment(Base):
    __tablename__ = 'equipments'

    id = Column(BigInteger(), primary_key=True, index=True)
    equipment_code = Column(String(64),
                            unique=True,
                            index=True,
                            comment='设备编号')
    equipment_name = Column(String(64), comment='设备名称')
    equipment_desc = Column(String(125), comment='设备描述')
    remarks = Column(String(125), comment='备注')
    is_active = Column(Boolean(), default=True, comment='激活状态')
    equipment_key = Column(String(256), comment='通信密钥')
    created_at = Column(DateTime(), default=datetime.now, comment='创建时间')
    updated_at = Column(DateTime(),
                        default=datetime.now,
                        onupdate=datetime.now,
                        comment='更新时间')

    def __repr__(self):
        return "<%s equipments.equipment_name: %s>" % (self.id,
                                                       self.equipment_name)
Exemple #23
0
class Email(Base):
    """
    Class representing an e-mail sent from CamCOPS.

    This is abstract, in that it doesn't care about the purpose of the e-mail.
    It's cross-referenced from classes that use it, such as
    :class:`camcops_server.cc_modules.cc_exportmodels.ExportedTaskEmail`.
    """

    __tablename__ = "_emails"

    # -------------------------------------------------------------------------
    # Basic things
    # -------------------------------------------------------------------------
    id = Column(
        # SQLite doesn't support autoincrement with BigInteger
        "id",
        BigInteger().with_variant(Integer, "sqlite"),
        primary_key=True,
        autoincrement=True,
        comment="Arbitrary primary key",
    )
    created_at_utc = Column(
        "created_at_utc",
        DateTime,
        comment="Date/time message was created (UTC)",
    )
    # -------------------------------------------------------------------------
    # Headers
    # -------------------------------------------------------------------------
    date = Column("date",
                  Rfc2822DateColType,
                  comment="Email date in RFC 2822 format")
    from_addr = Column("from_addr",
                       EmailAddressColType,
                       comment="Email 'From:' field")
    sender = Column("sender",
                    EmailAddressColType,
                    comment="Email 'Sender:' field")
    reply_to = Column("reply_to",
                      EmailAddressColType,
                      comment="Email 'Reply-To:' field")
    to = Column("to", Text, comment="Email 'To:' field")
    cc = Column("cc", Text, comment="Email 'Cc:' field")
    bcc = Column("bcc", Text, comment="Email 'Bcc:' field")
    subject = Column("subject", Text, comment="Email 'Subject:' field")
    # -------------------------------------------------------------------------
    # Body, message
    # -------------------------------------------------------------------------
    body = Column("body", Text, comment="Email body")
    content_type = Column("content_type",
                          MimeTypeColType,
                          comment="MIME type for e-mail body")
    charset = Column("charset",
                     CharsetColType,
                     comment="Character set for e-mail body")
    msg_string = Column("msg_string", LongText, comment="Full encoded e-mail")
    # -------------------------------------------------------------------------
    # Server
    # -------------------------------------------------------------------------
    host = Column("host", HostnameColType, comment="Email server")
    port = Column("port", Integer, comment="Port number on e-mail server")
    username = Column(
        "username",
        UserNameExternalColType,
        comment="Username on e-mail server",
    )
    use_tls = Column("use_tls", Boolean, comment="Use TLS?")
    # -------------------------------------------------------------------------
    # Status
    # -------------------------------------------------------------------------
    sent = Column("sent",
                  Boolean,
                  default=False,
                  nullable=False,
                  comment="Sent?")
    sent_at_utc = Column("sent_at_utc",
                         DateTime,
                         comment="Date/time message was sent (UTC)")
    sending_failure_reason = Column("sending_failure_reason",
                                    Text,
                                    comment="Reason for sending failure")

    def __init__(
        self,
        from_addr: str = "",
        date: str = None,
        sender: str = "",
        reply_to: str = "",
        to: str = "",
        cc: str = "",
        bcc: str = "",
        subject: str = "",
        body: str = "",
        content_type: str = MimeType.TEXT,
        charset: str = "utf8",
        attachment_filenames: Sequence[str] = None,
        attachments_binary: Sequence[Tuple[str, bytes]] = None,
        save_msg_string: bool = False,
    ) -> None:
        """
        Args:
            from_addr: name of the sender for the "From:" field
            date: e-mail date in RFC 2822 format, or ``None`` for "now"
            sender: name of the sender for the "Sender:" field
            reply_to: name of the sender for the "Reply-To:" field

            to: e-mail address(es) of the recipients for "To:" field, as a
                CSV list
            cc: e-mail address(es) of the recipients for "Cc:" field, as a
                CSV list
            bcc: e-mail address(es) of the recipients for "Bcc:" field, as a
                CSV list

            subject: e-mail subject
            body: e-mail body
            content_type: MIME type for body content, default ``text/plain``
            charset: character set for body; default ``utf8``
            charset:

            attachment_filenames: filenames of attachments to add
            attachments_binary: binary attachments to add, as a list of
                ``filename, bytes`` tuples

            save_msg_string: save the encoded message string? (May take
                significant space in the database).
        """
        # Note: we permit from_addr to be blank only for automated database
        # copying.

        # ---------------------------------------------------------------------
        # Timestamp
        # ---------------------------------------------------------------------
        now_local = get_now_localtz_pendulum()
        self.created_at_utc = convert_datetime_to_utc(now_local)

        # -------------------------------------------------------------------------
        # Arguments
        # -------------------------------------------------------------------------
        if not date:
            date = email.utils.format_datetime(now_local)
        attachment_filenames = (attachment_filenames
                                or [])  # type: Sequence[str]
        attachments_binary = (attachments_binary
                              or [])  # type: Sequence[Tuple[str, bytes]]
        if attachments_binary:
            attachment_binary_filenames, attachment_binaries = zip(
                *attachments_binary)
        else:
            attachment_binary_filenames = []  # type: List[str]
            attachment_binaries = []  # type: List[bytes]
        # ... https://stackoverflow.com/questions/13635032/what-is-the-inverse-function-of-zip-in-python  # noqa
        # Other checks performed by our e-mail function below

        # ---------------------------------------------------------------------
        # Transient fields
        # ---------------------------------------------------------------------
        self.password = None
        self.msg = (make_email(
            from_addr=from_addr,
            date=date,
            sender=sender,
            reply_to=reply_to,
            to=to,
            cc=cc,
            bcc=bcc,
            subject=subject,
            body=body,
            content_type=content_type,
            attachment_filenames=attachment_filenames,
            attachment_binaries=attachment_binaries,
            attachment_binary_filenames=attachment_binary_filenames,
        ) if from_addr else None)

        # ---------------------------------------------------------------------
        # Database fields
        # ---------------------------------------------------------------------
        self.date = date
        self.from_addr = from_addr
        self.sender = sender
        self.reply_to = reply_to
        self.to = to
        self.cc = cc
        self.bcc = bcc
        self.subject = subject
        self.body = body
        self.content_type = content_type
        self.charset = charset
        if save_msg_string:
            self.msg_string = self.msg.as_string()

    @reconstructor
    def init_on_load(self) -> None:
        """
        Called when SQLAlchemy recreates an object; see
        https://docs.sqlalchemy.org/en/latest/orm/constructors.html.
        """
        self.password = None
        self.msg = None

    def send(
        self,
        host: str,
        username: str,
        password: str,
        port: int = None,
        use_tls: bool = True,
    ) -> bool:
        """
        Sends message and returns success.
        """
        if port is None:
            port = STANDARD_TLS_PORT if use_tls else STANDARD_SMTP_PORT

        msg = None
        msg_string = None
        if self.msg:
            msg = self.msg
        elif self.msg_string:
            msg_string = self.msg_string
        else:
            log.error("Can't send message; not present (not saved?)")
            return False

        # Password not always required (for insecure servers...)

        if self.sent:
            log.info("Resending message")

        self.host = host
        self.port = port
        self.username = username
        # don't save password
        self.use_tls = use_tls
        to_addrs = COMMASPACE.join(x for x in (self.to, self.cc, self.bcc)
                                   if x)
        header_components = filter(
            None,
            (
                f"To: {self.to}" if self.to else "",
                f"Cc: {self.cc}" if self.cc else "",
                f"Bcc: {self.bcc}" if self.bcc else "",  # noqa
                f"Subject: {self.subject}" if self.subject else "",
            ),
        )
        log.info("Sending email -- {}", " -- ".join(header_components))
        try:
            send_msg(
                from_addr=self.from_addr,
                to_addrs=to_addrs,
                host=host,
                user=username,
                password=password,
                port=port,
                use_tls=use_tls,
                msg=msg,
                msg_string=msg_string,
            )
            log.debug("... sent")
            self.sent = True
            self.sent_at_utc = get_now_utc_pendulum()
            self.sending_failure_reason = None

            return True
        except RuntimeError as e:
            log.error("Failed to send e-mail: {!s}", e)
            if not self.sent:
                self.sent = False
                self.sending_failure_reason = str(e)

            return False
Exemple #24
0
class Star(Base):
    __tablename__ = 'stars'

    id = Column(BigInteger(), primary_key=True)
    group_id = Column(UUID(as_uuid=True), nullable=False)
    mass = Column(Float(), nullable=True)
    luminosity = Column(Float(), nullable=True)
    r_galactocentric = Column(Float(), nullable=True)
    th_galactocentric = Column(Float(), nullable=True)
    z_coordinate = Column(Float(), nullable=True)
    proper_motion = Column(Float(), nullable=True)
    proper_motion_component_b = Column(Float(), nullable=True)
    proper_motion_component_l = Column(Float(), nullable=True)
    proper_motion_component_vr = Column(Float(), nullable=True)
    right_ascension = Column(Float(), nullable=True)
    declination = Column(Float(), nullable=True)
    right_ascension_proper_motion = Column(Float(), nullable=True)
    declination_proper_motion = Column(Float(), nullable=True)
    distance = Column(Float(), nullable=True)
    galactic_latitude = Column(Float(), nullable=True)
    galactic_longitude = Column(Float(), nullable=True)
    j_abs_magnitude = Column(Float(), nullable=True)
    b_abs_magnitude = Column(Float(), nullable=True)
    r_abs_magnitude = Column(Float(), nullable=True)
    v_abs_magnitude = Column(Float(), nullable=True)
    i_abs_magnitude = Column(Float(), nullable=True)
    u_velocity = Column(Float(), nullable=True)
    v_velocity = Column(Float(), nullable=True)
    w_velocity = Column(Float(), nullable=True)
    birth_time = Column(Float(), nullable=True)
    # TODO: make it Enum, DA - 0, DB - 1, ONe - 2
    spectral_type = Column(Integer(), nullable=True)
    galactic_disk_type = Column(Enum(GalacticDiskType), nullable=True)
    updated_timestamp = Column(DateTime(), server_default=func.now())

    def __init__(self,
                 group_id: uuid.UUID,
                 mass: float = None,
                 luminosity: float = None,
                 proper_motion: float = None,
                 r_galactocentric: float = None,
                 th_galactocentric: float = None,
                 z_coordinate: float = None,
                 proper_motion_component_b: float = None,
                 proper_motion_component_l: float = None,
                 proper_motion_component_vr: float = None,
                 right_ascension: float = None,
                 declination: float = None,
                 right_ascension_proper_motion: float = None,
                 declination_proper_motion: float = None,
                 distance: float = None,
                 galactic_latitude: float = None,
                 galactic_longitude: float = None,
                 j_abs_magnitude: float = None,
                 b_abs_magnitude: float = None,
                 r_abs_magnitude: float = None,
                 v_abs_magnitude: float = None,
                 i_abs_magnitude: float = None,
                 u_velocity: float = None,
                 v_velocity: float = None,
                 w_velocity: float = None,
                 birth_time: float = None,
                 spectral_type: int = None,
                 galactic_disk_type: GalacticDiskType = None):
        self.id = None
        self.group_id = group_id
        self.mass = mass
        self.luminosity = luminosity
        self.proper_motion = proper_motion
        self.r_galactocentric = r_galactocentric
        self.th_galactocentric = th_galactocentric
        self.z_coordinate = z_coordinate
        self.proper_motion_component_b = proper_motion_component_b
        self.proper_motion_component_l = proper_motion_component_l
        self.proper_motion_component_vr = proper_motion_component_vr
        self.right_ascension = right_ascension
        self.declination = declination
        self.right_ascension_proper_motion = right_ascension_proper_motion
        self.declination_proper_motion = declination_proper_motion
        self.distance = distance
        self.galactic_latitude = galactic_latitude
        self.galactic_longitude = galactic_longitude
        self.j_abs_magnitude = j_abs_magnitude
        self.b_abs_magnitude = b_abs_magnitude
        self.r_abs_magnitude = r_abs_magnitude
        self.v_abs_magnitude = v_abs_magnitude
        self.i_abs_magnitude = i_abs_magnitude
        self.u_velocity = u_velocity
        self.v_velocity = v_velocity
        self.w_velocity = w_velocity
        self.birth_time = birth_time
        self.spectral_type = spectral_type
        self.galactic_disk_type = galactic_disk_type