From 18c200895954f54b307c583e2f4c538a9779bc8b Mon Sep 17 00:00:00 2001 From: mcbloch Date: Tue, 2 Apr 2019 18:03:14 +0200 Subject: [PATCH] squash database migrations, update model to be equal to the server --- app/migrations/versions/150252c1cdb1_.py | 76 +++++++++++++++++++ .../{ => old_migrations}/2d696203e56_.py | 0 .../{ => old_migrations}/3243c3538fc_.py | 0 .../{ => old_migrations}/354676f60be_.py | 0 .../{ => old_migrations}/42709384216_.py | 0 .../{ => old_migrations}/4e94c0b08ed_.py | 0 .../{ => old_migrations}/57a00d0b7bc_.py | 0 app/models.py | 4 +- 8 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 app/migrations/versions/150252c1cdb1_.py rename app/migrations/versions/{ => old_migrations}/2d696203e56_.py (100%) rename app/migrations/versions/{ => old_migrations}/3243c3538fc_.py (100%) rename app/migrations/versions/{ => old_migrations}/354676f60be_.py (100%) rename app/migrations/versions/{ => old_migrations}/42709384216_.py (100%) rename app/migrations/versions/{ => old_migrations}/4e94c0b08ed_.py (100%) rename app/migrations/versions/{ => old_migrations}/57a00d0b7bc_.py (100%) diff --git a/app/migrations/versions/150252c1cdb1_.py b/app/migrations/versions/150252c1cdb1_.py new file mode 100644 index 0000000..45a90e6 --- /dev/null +++ b/app/migrations/versions/150252c1cdb1_.py @@ -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 ### diff --git a/app/migrations/versions/2d696203e56_.py b/app/migrations/versions/old_migrations/2d696203e56_.py similarity index 100% rename from app/migrations/versions/2d696203e56_.py rename to app/migrations/versions/old_migrations/2d696203e56_.py diff --git a/app/migrations/versions/3243c3538fc_.py b/app/migrations/versions/old_migrations/3243c3538fc_.py similarity index 100% rename from app/migrations/versions/3243c3538fc_.py rename to app/migrations/versions/old_migrations/3243c3538fc_.py diff --git a/app/migrations/versions/354676f60be_.py b/app/migrations/versions/old_migrations/354676f60be_.py similarity index 100% rename from app/migrations/versions/354676f60be_.py rename to app/migrations/versions/old_migrations/354676f60be_.py diff --git a/app/migrations/versions/42709384216_.py b/app/migrations/versions/old_migrations/42709384216_.py similarity index 100% rename from app/migrations/versions/42709384216_.py rename to app/migrations/versions/old_migrations/42709384216_.py diff --git a/app/migrations/versions/4e94c0b08ed_.py b/app/migrations/versions/old_migrations/4e94c0b08ed_.py similarity index 100% rename from app/migrations/versions/4e94c0b08ed_.py rename to app/migrations/versions/old_migrations/4e94c0b08ed_.py diff --git a/app/migrations/versions/57a00d0b7bc_.py b/app/migrations/versions/old_migrations/57a00d0b7bc_.py similarity index 100% rename from app/migrations/versions/57a00d0b7bc_.py rename to app/migrations/versions/old_migrations/57a00d0b7bc_.py diff --git a/app/models.py b/app/models.py index 2507e82..1f76a21 100644 --- a/app/models.py +++ b/app/models.py @@ -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))