chore(migrations): Update upload_files.source_url

This commit is contained in:
-LAN- 2024-11-01 14:30:12 +08:00
parent 68a44f8260
commit 537b46fa24
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,41 @@
"""update upload_files.source_url
Revision ID: f4d7ce70a7ca
Revises: 93ad8c19c40b
Create Date: 2024-11-01 05:40:03.531751
"""
from alembic import op
import models as models
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'f4d7ce70a7ca'
down_revision = '93ad8c19c40b'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('upload_files', schema=None) as batch_op:
batch_op.alter_column('source_url',
existing_type=sa.VARCHAR(length=255),
type_=sa.TEXT(),
existing_nullable=False,
existing_server_default=sa.text("''::character varying"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('upload_files', schema=None) as batch_op:
batch_op.alter_column('source_url',
existing_type=sa.TEXT(),
type_=sa.VARCHAR(length=255),
existing_nullable=False,
existing_server_default=sa.text("''::character varying"))
# ### end Alembic commands ###

View File

@ -6,6 +6,7 @@ from datetime import datetime
from enum import Enum from enum import Enum
from typing import Any, Literal, Optional from typing import Any, Literal, Optional
import sqlalchemy as sa
from flask import request from flask import request
from flask_login import UserMixin from flask_login import UserMixin
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -1384,7 +1385,7 @@ class UploadFile(db.Model):
used_by: Mapped[str | None] = db.Column(StringUUID, nullable=True) used_by: Mapped[str | None] = db.Column(StringUUID, nullable=True)
used_at: Mapped[datetime | None] = db.Column(db.DateTime, nullable=True) used_at: Mapped[datetime | None] = db.Column(db.DateTime, nullable=True)
hash: Mapped[str | None] = db.Column(db.String(255), nullable=True) hash: Mapped[str | None] = db.Column(db.String(255), nullable=True)
source_url: Mapped[str] = db.Column(db.String(255), nullable=False, server_default="") source_url: Mapped[str] = mapped_column(sa.TEXT, default="")
def __init__( def __init__(
self, self,