diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index d09d50b..0e42987 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -27,13 +27,6 @@ jobs: file: ./Dockerfile push: true tags: cornellappdev/uplift-dev:${{ steps.vars.outputs.sha_short }} - build-args: | - DB_PASSWORD=${{ secrets.DB_PASSWORD }} - DB_HOST=postgres - DB_NAME=${{ secrets.DB_NAME }} - DB_USERNAME=${{ secrets.DB_USERNAME }} - DB_PORT=${{ secrets.DB_PORT }} - FLASK_ENV=development - name: Remote SSH and Deploy uses: appleboy/ssh-action@master env: @@ -52,4 +45,6 @@ jobs: sudo systemctl stop nginx sudo systemctl restart nginx docker stack deploy -c docker-compose.yml the-stack --with-registry-auth + sleep 30s + docker exec $(docker ps -q -f name=the-stack_web) flask db upgrade yes | docker system prune -a diff --git a/Dockerfile b/Dockerfile index f359f37..ec3e3b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,22 +6,4 @@ COPY . . ENV MAX_CONCURRENT_PIP=4 RUN pip3 install --upgrade pip RUN pip3 install --exists-action w -r requirements.txt - -# to receive build arguments -ARG DB_PASSWORD -ARG DB_HOST -ARG DB_NAME -ARG DB_USERNAME -ARG DB_PORT -ARG FLASK_ENV - -# set env variables for build -ENV DB_PASSWORD=${DB_PASSWORD} -ENV DB_HOST=${DB_HOST} -ENV DB_NAME=${DB_NAME} -ENV DB_USERNAME=${DB_USERNAME} -ENV DB_PORT=${DB_PORT} -ENV FLASK_ENV=${FLASK_ENV} - -RUN flask db upgrade CMD python3 app.py diff --git a/migrations/versions/24684343da0f_update_equipment_table_with_muscle_.py b/migrations/versions/24684343da0f_update_equipment_table_with_muscle_.py new file mode 100644 index 0000000..7e16351 --- /dev/null +++ b/migrations/versions/24684343da0f_update_equipment_table_with_muscle_.py @@ -0,0 +1,32 @@ +"""update equipment table with muscle groups + +Revision ID: 24684343da0f +Revises: +Create Date: 2024-11-20 17:40:32.344965 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '24684343da0f' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('gear', 'cost', + existing_type=postgresql.DOUBLE_PRECISION(precision=53), + nullable=0) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('gear', 'cost', + existing_type=postgresql.DOUBLE_PRECISION(precision=53), + nullable=False) + # ### end Alembic commands ### diff --git a/migrations/versions/79fec8ab4c70_add_muscle_groups_and_clean_name_to_.py b/migrations/versions/79fec8ab4c70_add_muscle_groups_and_clean_name_to_.py deleted file mode 100644 index d63c007..0000000 --- a/migrations/versions/79fec8ab4c70_add_muscle_groups_and_clean_name_to_.py +++ /dev/null @@ -1,105 +0,0 @@ -"""add muscle groups and clean name to equipment - -Revision ID: 79fec8ab4c70 -Revises: f711f3c11324 -Create Date: 2024-11-13 17:48:46.093175 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -from sqlalchemy import Enum - - -# revision identifiers, used by Alembic. -revision = '79fec8ab4c70' -down_revision = None -branch_labels = None -depends_on = None - -# Define enums for reference -class MuscleGroup(Enum): - ABDOMINALS = 1 - CHEST = 2 - BACK = 3 - SHOULDERS = 4 - BICEPS = 5 - TRICEPS = 6 - HAMSTRINGS = 7 - QUADS = 8 - GLUTES = 9 - CALVES = 10 - MISCELLANEOUS = 11 - CARDIO = 12 - -class AccessibilityType(Enum): - wheelchair = 0 - -def upgrade(): - # First, delete all existing equipment data - op.execute('TRUNCATE TABLE equipment CASCADE') - - # Drop the old enum type - op.execute('DROP TYPE IF EXISTS equipmenttype') - - # Create new enum types - muscle_group_enum = postgresql.ENUM( - 'ABDOMINALS', 'CHEST', 'BACK', 'SHOULDERS', 'BICEPS', 'TRICEPS', - 'HAMSTRINGS', 'QUADS', 'GLUTES', 'CALVES', 'MISCELLANEOUS', 'CARDIO', - name='musclegroup' - ) - muscle_group_enum.create(op.get_bind()) - - new_accessibility_enum = postgresql.ENUM('wheelchair', name='accessibilitytype_new') - new_accessibility_enum.create(op.get_bind()) - - # Drop old columns - op.drop_column('equipment', 'equipment_type') - op.drop_column('equipment', 'accessibility') - - # Add new columns - op.add_column('equipment', sa.Column('clean_name', sa.String(), nullable=False)) - op.add_column('equipment', - sa.Column('muscle_groups', postgresql.ARRAY(muscle_group_enum), nullable=True) - ) - op.add_column('equipment', - sa.Column('accessibility', new_accessibility_enum, nullable=True) - ) - -def downgrade(): - # First, delete all equipment data - op.execute('TRUNCATE TABLE equipment CASCADE') - - # Create old equipment_type enum - old_equipment_type_enum = postgresql.ENUM( - 'cardio', - 'racks_and_benches', - 'selectorized', - 'multi_cable', - 'free_weights', - 'miscellaneous', - 'plate_loaded', - name='equipmenttype' - ) - old_equipment_type_enum.create(op.get_bind()) - - # Drop new columns - op.drop_column('equipment', 'clean_name') - op.drop_column('equipment', 'muscle_groups') - op.drop_column('equipment', 'accessibility') - - # Add back old columns - op.add_column('equipment', - sa.Column('equipment_type', old_equipment_type_enum, nullable=False) - ) - - # Drop new enums - postgresql.ENUM(name='musclegroup').drop(op.get_bind()) - postgresql.ENUM(name='accessibilitytype_new').drop(op.get_bind(), cascade=True) - - # Recreate old accessibility enum and column - old_accessibility_enum = postgresql.ENUM('wheelchair', name='accessibilitytype') - old_accessibility_enum.create(op.get_bind()) - op.add_column('equipment', - sa.Column('accessibility', old_accessibility_enum, nullable=True) - )