Unverified Commit 021ff387 authored by Dylan Jones's avatar Dylan Jones
Browse files

test data

parent 599f0e67
"""inital database models """empty message
Revision ID: 1ef22e364966 Revision ID: 26f2853e67de
Revises: Revises:
Create Date: 2020-02-16 19:28:28.905839 Create Date: 2020-02-16 19:33:26.275339
""" """
from alembic import op from alembic import op
...@@ -10,7 +10,7 @@ import sqlalchemy as sa ...@@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '1ef22e364966' revision = '26f2853e67de'
down_revision = None down_revision = None
branch_labels = None branch_labels = None
depends_on = None depends_on = None
...@@ -27,6 +27,7 @@ def upgrade(): ...@@ -27,6 +27,7 @@ def upgrade():
) )
op.create_table('field', op.create_table('field',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('slug', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=False), sa.Column('name', sa.String(), nullable=False),
sa.Column('type', sa.Enum('STRING', 'FLOAT', 'INTEGER', 'BOOLEAN', 'RATING', name='fieldtype'), nullable=False), sa.Column('type', sa.Enum('STRING', 'FLOAT', 'INTEGER', 'BOOLEAN', 'RATING', name='fieldtype'), nullable=False),
sa.Column('category_id', sa.Integer(), nullable=True), sa.Column('category_id', sa.Integer(), nullable=True),
......
...@@ -36,9 +36,34 @@ def test_data(): ...@@ -36,9 +36,34 @@ def test_data():
# coldness # coldness
cd = sa.Field() cd = sa.Field()
cd.name = "Coldness" cd.name = "Coldness"
cd.slug = "coldness"
cd.type = FieldType.RATING cd.type = FieldType.RATING
cd.category_id = wf.id cd.category_id = wf.id
# filler
fl = sa.Field()
fl.slug = "bottle_filler"
fl.name = "Has Bottle Filler"
fl.type = FieldType.BOOLEAN
fl.category_id = wf.id
session.add(cd)
session.add(fl)
session.commit()
# an actual instance!
fn = sa.Point()
fn.name = None
fn.category_id = wf.id
fn.parent_id = None
fn.attributes = {
"coldness": {
"num_reviews": 32,
"average_rating": 0.5
},
"bottle_filler": {
"value": True
}
}
session.add(fn)
session.commit()
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -77,6 +77,7 @@ class Field(Base): ...@@ -77,6 +77,7 @@ class Field(Base):
""" """
__tablename__ = 'field' __tablename__ = 'field'
slug = Column(String, nullable=False)
name = Column(String, nullable=False) name = Column(String, nullable=False)
type = Column(Enum(FieldType), nullable=False) type = Column(Enum(FieldType), nullable=False)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment