diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4cc40e6..a2cd9f0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -67,13 +67,20 @@ jobs: username: ${{ secrets.SSH_DEV_USERNAME }} key: ${{ secrets.SSH_DEPLOY_DEV }} script: | - cd devops + # Ensure we have max disk space + docker rm -fv $(docker ps -aq) docker rmi -f $(docker images -f "dangling=true" -q) + docker volume rm -f $(docker volume ls -f "dangling=true" -q) + # Update the service docker compose pull backend gradio docker compose stop backend gradio && docker compose up -d --wait && docker compose exec backend alembic upgrade head + # Check update docker inspect -f '{{ .Created }}' $(docker compose images -q backend) docker inspect -f '{{ .Created }}' $(docker compose images -q gradio) + # Clean up + docker rm -fv $(docker ps -aq) docker rmi -f $(docker images -f "dangling=true" -q) + docker volume rm -f $(docker volume ls -f "dangling=true" -q) - name: Ping server env: DEV_ENDPOINT: ${{ secrets.DEV_ENDPOINT }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 452d6ac..69b047e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,7 +55,10 @@ jobs: GH_OAUTH_SECRET: ${{ secrets.GH_OAUTH_SECRET }} OLLAMA_MODEL: tinydolphin:1.1b-v2.8-q3_K_M run: | - docker compose -f docker-compose.dev.yml up -d --build --wait + docker compose -f docker-compose.dev.yml up -d --build + sleep 20 + docker compose -f docker-compose.dev.yml logs backend + docker compose -f docker-compose.dev.yml up -d --wait # debug docker compose -f docker-compose.dev.yml exec -T backend alembic current docker compose -f docker-compose.dev.yml exec -T backend alembic history --verbose diff --git a/src/alembic/versions/2023-11-07-15-35_eb1a6567456c.py b/src/alembic/versions/2023-11-07-15-35_eb1a6567456c.py index cd4fca2..c9a449e 100755 --- a/src/alembic/versions/2023-11-07-15-35_eb1a6567456c.py +++ b/src/alembic/versions/2023-11-07-15-35_eb1a6567456c.py @@ -9,6 +9,7 @@ import sqlalchemy as sa from alembic import op from sqlalchemy.dialects import postgresql +from sqlalchemy.sql import text # revision identifiers, used by Alembic. revision = "eb1a6567456c" @@ -26,7 +27,7 @@ def upgrade(): session = sa.orm.Session(bind=bind) try: # Update is_active to True where removed_at is NULL - session.execute("UPDATE repository SET is_active = (removed_at IS NULL)") + session.execute(text("UPDATE repository SET is_active = (removed_at IS NULL)")) session.commit() finally: session.close() @@ -46,7 +47,7 @@ def downgrade(): # Set removed_at to a specific time where is_active is False # You may choose to leave it as NULL or set it to a specific timestamp session.execute( - "UPDATE repository SET removed_at = CASE WHEN is_active = false THEN CURRENT_TIMESTAMP ELSE NULL END" + text("UPDATE repository SET removed_at = CASE WHEN is_active = false THEN CURRENT_TIMESTAMP ELSE NULL END") ) session.commit() finally: diff --git a/src/alembic/versions/2024-02-23-11-56_4c08af871a9e.py b/src/alembic/versions/2024-02-23-11-56_4c08af871a9e.py index 54e733f..438a0a9 100755 --- a/src/alembic/versions/2024-02-23-11-56_4c08af871a9e.py +++ b/src/alembic/versions/2024-02-23-11-56_4c08af871a9e.py @@ -8,7 +8,7 @@ import sqlalchemy as sa from alembic import op -from sqlalchemy.sql import func +from sqlalchemy.sql import func, text # import sqlalchemy_utils # import sqlmodel # added @@ -42,7 +42,8 @@ def upgrade(): op.add_column("guideline", sa.Column("creator_id", sa.Integer(), nullable=True)) # Enforce the foreign key after initializing it op.execute( - """ + text( + """ DO $$ DECLARE first_user_id INT; @@ -56,6 +57,7 @@ def upgrade(): END IF; END $$; """ + ) ) op.drop_column("guideline", "repo_id") op.drop_column("guideline", "title") @@ -79,7 +81,7 @@ def downgrade(): op.add_column("repository", sa.Column("is_active", sa.Boolean(), nullable=False)) op.add_column("repository", sa.Column("installed_by", sa.Integer(), nullable=False)) # User table modifications - op.execute('DELETE FROM "user" WHERE provider_user_id IS NULL') + op.execute(text('DELETE FROM "user" WHERE provider_user_id IS NULL')) op.drop_column("user", "created_at") op.alter_column("user", "login", nullable=False) op.alter_column("user", "hashed_password", nullable=False)