Skip to content

Commit 14cfac3

Browse files
committed
feat: add database fields for compression tracking
- Add is_compressed boolean flag to PasteEntity - Add original_size integer field (nullable) - Create Alembic migration for new columns - Backward compatible: existing pastes get is_compressed=false
1 parent d481b1c commit 14cfac3

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""add compression fields
2+
3+
Revision ID: 6c5a2c764fb8
4+
Revises: 0ed6c1042110
5+
Create Date: 2025-12-25 13:23:44.911166
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = '6c5a2c764fb8'
16+
down_revision: Union[str, Sequence[str], None] = '0ed6c1042110'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
"""Upgrade schema."""
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.add_column('pastes', sa.Column('is_compressed', sa.Boolean(), server_default='false', nullable=False))
25+
op.add_column('pastes', sa.Column('original_size', sa.Integer(), nullable=True))
26+
# ### end Alembic commands ###
27+
28+
29+
def downgrade() -> None:
30+
"""Downgrade schema."""
31+
# ### commands auto generated by Alembic - please adjust! ###
32+
op.drop_column('pastes', 'original_size')
33+
op.drop_column('pastes', 'is_compressed')
34+
# ### end Alembic commands ###

backend/app/db/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sqlalchemy import TIMESTAMP, UUID, Column, Integer, String, func, text
1+
from sqlalchemy import TIMESTAMP, UUID, Boolean, Column, Integer, String, func, text
22

33
from app.db.base import Base
44

@@ -18,6 +18,8 @@ class PasteEntity(Base):
1818
)
1919

2020
content_size = Column(Integer, nullable=False)
21+
is_compressed = Column(Boolean, nullable=False, server_default='false')
22+
original_size = Column(Integer, nullable=True)
2123

2224
creator_ip = Column(String)
2325
creator_user_agent = Column(String)

0 commit comments

Comments
 (0)