Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

fix: Remove implicit trailing whitespace from the agents.architecture column #559

Merged
merged 4 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/559.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Alter type of model `agents.architecture` column from CHAR to String
2 changes: 1 addition & 1 deletion src/ai/backend/manager/models/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AgentStatus(enum.Enum):
sa.Column('lost_at', sa.DateTime(timezone=True), nullable=True),

sa.Column('version', sa.String(length=64), nullable=False),
sa.Column('architecture', sa.CHAR(length=32), nullable=False),
sa.Column('architecture', sa.String(length=32), nullable=False),
sa.Column('compute_plugins', pgsql.JSONB(), nullable=False, default={}),
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""change char col to str

Revision ID: 11146ba02235
Revises: 0f7a4b643940
Create Date: 2022-03-25 12:32:05.637628

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql.expression import bindparam

# revision identifiers, used by Alembic.
revision = '11146ba02235'
down_revision = '0f7a4b643940'
branch_labels = None
depends_on = None


def upgrade():
conn = op.get_bind()
op.alter_column('agents', column_name='architecture', type_=sa.String(length=32))
query = '''
UPDATE agents
SET architecture = TRIM (architecture);
'''
conn.execute(query)

def downgrade():
op.alter_column('agents', column_name='architecture', type_=sa.CHAR(length=32))