Commit 599f0e67 authored by Dylan Jones's avatar Dylan Jones

i give up on commit messages

parent 8f0a599d
"""inital database models
Revision ID: 24dfd0eb9da6
Revision ID: 1ef22e364966
Revises:
Create Date: 2020-02-16 19:22:25.106964
Create Date: 2020-02-16 19:28:28.905839
"""
from alembic import op
......@@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '24dfd0eb9da6'
revision = '1ef22e364966'
down_revision = None
branch_labels = None
depends_on = None
......@@ -21,6 +21,7 @@ def upgrade():
op.create_table('category',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('icon', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
......@@ -28,7 +29,6 @@ def upgrade():
sa.Column('id', sa.Integer(), autoincrement=True, 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('unit', sa.String(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['category_id'], ['category.id'], ),
sa.PrimaryKeyConstraint('id')
......
"""add icon field
Revision ID: 6781f9d7ee85
Revises: 24dfd0eb9da6
Create Date: 2020-02-16 19:25:29.011628
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6781f9d7ee85'
down_revision = '24dfd0eb9da6'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('category', sa.Column('icon', sa.String(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('category', 'icon')
# ### end Alembic commands ###
from flask import Flask
from sqlalchemy.orm import Session
from where.field_types import FieldType
from . import sa
app = Flask(__name__)
......@@ -29,8 +30,14 @@ def test_data():
# Water Fountain, the class.
wf = sa.Category()
wf.name = "Water Fountain"
wf.icon
wf.icon = "https://karel.pw/water.png"
session.add(wf)
session.commit()
# coldness
cd = sa.Field()
cd.name = "Coldness"
cd.type = FieldType.RATING
cd.category_id = wf.id
......
......@@ -79,7 +79,6 @@ class Field(Base):
name = Column(String, nullable=False)
type = Column(Enum(FieldType), nullable=False)
unit = Column(String)
# Relationship
category_id = Column(Integer, ForeignKey('category.id'))
......
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