Files
cal_counter/migrations/versions/46cd3e1a3b67_.py
Stef 66204e7e4a Add Docker, migrations, and initial database setup
Added Dockerfile and docker-compose.yaml for containerization. Introduced Alembic migrations with initial schema and a migration to alter column types. Added requirements.txt for dependencies and removed temp.py cleanup script. Updated .gitignore to allow tracking of migration files.
2025-08-11 00:49:46 +02:00

74 lines
2.6 KiB
Python

"""empty message
Revision ID: 46cd3e1a3b67
Revises:
Create Date: 2025-07-07 14:31:50.181885
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '46cd3e1a3b67'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('unit',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('symbol', sa.String(length=10), nullable=False),
sa.Column('name', sa.String(length=50), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name'),
sa.UniqueConstraint('symbol')
)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=150), nullable=False),
sa.Column('password', sa.String(), nullable=False),
sa.Column('is_admin', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('username')
)
op.create_table('food_item',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('barcode', sa.Integer(), nullable=True),
sa.Column('owner_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=150), nullable=False),
sa.Column('energy_100', sa.Integer(), nullable=False),
sa.Column('protein_100', sa.Float(), nullable=False),
sa.Column('carbs_100', sa.Float(), nullable=False),
sa.Column('sugar_100', sa.Float(), nullable=True),
sa.Column('fat_100', sa.Float(), nullable=False),
sa.Column('saturated_fat_100', sa.Float(), nullable=True),
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('barcode', 'owner_id', name='barcode_owner_key')
)
op.create_table('food_log',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('datetime_created', sa.DateTime(), nullable=False),
sa.Column('date_', sa.Date(), nullable=False),
sa.Column('food_item_id', sa.Integer(), nullable=False),
sa.Column('part_of_day', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('amount', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['food_item_id'], ['food_item.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('food_log')
op.drop_table('food_item')
op.drop_table('user')
op.drop_table('unit')
# ### end Alembic commands ###