Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/31#discussion_r90505762
  
    --- Diff: aria/storage/models.py ---
    @@ -60,353 +73,612 @@
     )
     
     # todo: sort this, maybe move from mgr or move from aria???
    -ACTION_TYPES = ()
    -ENTITY_TYPES = ()
    +# TODO: this must change
    +ACTION_TYPES = ('a')
    +ENTITY_TYPES = ('b')
    +
    +
    +def uuid_generator():
    +    """
    +    wrapper function which generates ids
    +    """
    +    return str(uuid4())
     
     
    -class Blueprint(Model):
    +class Blueprint(SQLModelBase):
         """
    -    A Model which represents a blueprint
    +    Blueprint model representation.
         """
    -    plan = Field(type=dict)
    -    id = Field(type=basestring, default=uuid_generator)
    -    description = Field(type=(basestring, NoneType))
    -    created_at = Field(type=datetime)
    -    updated_at = Field(type=datetime)
    -    main_file_name = Field(type=basestring)
    +    __tablename__ = 'blueprints'
    +
    +    storage_id = Column(Integer, primary_key=True, autoincrement=True)
    +    id = Column(Text, index=True)
     
    +    created_at = Column(DateTime, nullable=False, index=True)
    +    main_file_name = Column(Text, nullable=False)
    +    plan = Column(MutableDict.as_mutable(Dict), nullable=False)
    +    updated_at = Column(DateTime)
    +    description = Column(Text)
     
    -class Snapshot(Model):
    +
    +class Snapshot(SQLModelBase):
         """
    -    A Model which represents a snapshot
    +    Snapshot model representation.
         """
    +    __tablename__ = 'snapshots'
    +
         CREATED = 'created'
         FAILED = 'failed'
         CREATING = 'creating'
         UPLOADED = 'uploaded'
    +
    +    STATES = [CREATED, FAILED, CREATING, UPLOADED]
         END_STATES = [CREATED, FAILED, UPLOADED]
     
    -    id = Field(type=basestring, default=uuid_generator)
    -    created_at = Field(type=datetime)
    -    status = Field(type=basestring)
    -    error = Field(type=basestring, default=None)
    +    storage_id = Column(Integer, primary_key=True, autoincrement=True)
    +    id = Column(Text, index=True)
     
    +    created_at = Column(DateTime, nullable=False, index=True)
    +    status = Column(Enum(*STATES, name='snapshot_status'))
    +    error = Column(Text)
     
    -class Deployment(Model):
    -    """
    -    A Model which represents a deployment
    -    """
    -    id = Field(type=basestring, default=uuid_generator)
    -    description = Field(type=(basestring, NoneType))
    -    created_at = Field(type=datetime)
    -    updated_at = Field(type=datetime)
    -    blueprint_id = Field(type=basestring)
    -    workflows = Field(type=dict)
    -    inputs = Field(type=dict, default=lambda: {})
    -    policy_types = Field(type=dict, default=lambda: {})
    -    policy_triggers = Field(type=dict, default=lambda: {})
    -    groups = Field(type=dict, default=lambda: {})
    -    outputs = Field(type=dict, default=lambda: {})
    -    scaling_groups = Field(type=dict, default=lambda: {})
    -
    -
    -class DeploymentUpdateStep(Model):
    +
    +class Deployment(SQLModelBase):
         """
    -    A Model which represents a deployment update step
    +    Deployment model representation.
         """
    -    id = Field(type=basestring, default=uuid_generator)
    -    action = Field(type=basestring, choices=ACTION_TYPES)
    -    entity_type = Field(type=basestring, choices=ENTITY_TYPES)
    -    entity_id = Field(type=basestring)
    -    supported = Field(type=bool, default=True)
    -
    -    def __hash__(self):
    -        return hash((self.id, self.entity_id))
    +    __tablename__ = 'deployments'
    +
    +    # See base class for an explanation on these properties
    +    join_properties = {
    +        'blueprint_id': {
    +            # No need to provide the Blueprint table, as it's already 
joined
    +            'models': [Blueprint],
    +            'column': Blueprint.id.label('blueprint_id')
    +        },
    +    }
    +    join_order = 2
    +
    +    _private_fields = ['blueprint_storage_id']
    --- End diff --
    
    add comment in base


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to