Merge pull request #98 from ZeusWPI/fix_db

squash database migrations, update model to be equal to the server
This commit is contained in:
Maxime 2019-04-04 17:41:47 +02:00 committed by GitHub
commit 27302bdc2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 78 additions and 2 deletions

View file

@ -0,0 +1,76 @@
"""empty message
Revision ID: 150252c1cdb1
Revises: None
Create Date: 2019-04-02 18:00:12.618368
"""
# revision identifiers, used by Alembic.
revision = '150252c1cdb1'
down_revision = None
from alembic import op
import sqlalchemy as sa
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('location',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=120), nullable=False),
sa.Column('address', sa.String(length=254), nullable=True),
sa.Column('website', sa.String(length=120), nullable=True),
sa.Column('telephone', sa.String(length=20), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=80), nullable=False),
sa.Column('admin', sa.Boolean(), nullable=True),
sa.Column('bias', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('username')
)
op.create_table('order',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('courrier_id', sa.Integer(), nullable=True),
sa.Column('location_id', sa.Integer(), nullable=True),
sa.Column('starttime', sa.DateTime(), nullable=True),
sa.Column('stoptime', sa.DateTime(), nullable=True),
sa.Column('public', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('product',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('location_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(length=120), nullable=False),
sa.Column('price', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('order_item',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('order_id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=True),
sa.Column('paid', sa.Boolean(), nullable=True),
sa.Column('extra', sa.String(length=254), nullable=True),
sa.Column('name', sa.String(length=120), nullable=True),
sa.ForeignKeyConstraint(['order_id'], ['order.id'], ),
sa.ForeignKeyConstraint(['product_id'], ['product.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('order_item')
op.drop_table('product')
op.drop_table('order')
op.drop_table('user')
op.drop_table('location')
# ### end Alembic commands ###

View file

@ -136,8 +136,8 @@ class OrderItem(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
order_id = db.Column(db.Integer, db.ForeignKey('order.id'), nullable=False)
product_id = db.Column(db.Integer, db.ForeignKey('product.id'),
nullable=False)
paid = db.Column(db.Boolean, default=False, nullable=False)
nullable=True) # TODO make false after init migration
paid = db.Column(db.Boolean, default=False, nullable=True) # TODO make false after init migration
extra = db.Column(db.String(254), nullable=True)
name = db.Column(db.String(120))