Skip to content

Commit

Permalink
Database Changes
Browse files Browse the repository at this point in the history
----------------
- Add a boolean flag to the dataset table to indicate a particular dataset is stale
  and should not be used in new transform requests

- Take this opportuity to remove the did column from the transform_result table
  it is never used and is a foreign key
  • Loading branch information
BenGalewsky committed Nov 11, 2024
1 parent 6c70eba commit c723331
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
30 changes: 30 additions & 0 deletions servicex_app/migrations/versions/v1_5_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Mark dataset rows as stale
Revision ID: v1_5_5
Revises: v1_3_0
Create Date: 2024-11-11 16:06:00.000000
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'v1_5_5'
down_revision = 'v1_3_0'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('datasets', sa.Column('stale',
sa.Boolean(),
nullable=False,
server_default='false'))
# This was never used, so a fine time to delete it
op.drop_column('transform_result', 'did')


def downgrade():
op.drop_column('datasets', 'stale')
# No need to add the transform_result.did column back in
2 changes: 0 additions & 2 deletions servicex_app/servicex_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ class TransformationResult(db.Model):
__tablename__ = 'transform_result'

id = db.Column(db.Integer, primary_key=True)
did = db.Column(db.String(512), unique=False, nullable=False)
file_id = db.Column(db.Integer, ForeignKey('files.id'))
file_path = db.Column(db.String(512), unique=False, nullable=False)
request_id = db.Column(db.String(48), unique=False, nullable=False)
Expand All @@ -378,7 +377,6 @@ def to_json(cls, x):
return {
'id': x.id,
'request-id': x.request_id,
'did': x.did,
'file-id': x.id,
'file-path': x.file_path,
'transform_status': x.transform_status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def record_file_complete(logger: Logger, request_id: str, info: dict[str, str])
)
def save_transform_result(transform_req: TransformRequest, info: dict[str, str]):
rec = TransformationResult(
did=transform_req.did,
file_id=info['file-id'],
request_id=transform_req.request_id,
file_path=info['file-path'],
Expand Down

0 comments on commit c723331

Please sign in to comment.