fix(db): پهنکردن ستونهای location/usage پروژه به ۲۵۶ نویسه
نشانی انگلیسی ترانویسیشده از ۱۲۸ نویسه بلندتر میشود (بلندترین: ۱۶۱) و درج ترجمهٔ ۶۵ پروژه با خطای StringDataRightTruncation شکست خورد. مدل + مهاجرت ALTER COLUMN TYPE (idempotent) اضافه شد.
This commit is contained in:
@@ -153,6 +153,11 @@ def run_ddl_migrations() -> None:
|
|||||||
conn.execute(
|
conn.execute(
|
||||||
text("ALTER TABLE articles ADD COLUMN IF NOT EXISTS seo_keyphrase VARCHAR(128) NOT NULL DEFAULT ''")
|
text("ALTER TABLE articles ADD COLUMN IF NOT EXISTS seo_keyphrase VARCHAR(128) NOT NULL DEFAULT ''")
|
||||||
)
|
)
|
||||||
|
# نشانی/کاربری پروژه: نشانی انگلیسی (ترانویسی) از ۱۲۸ نویسه بلندتر میشود
|
||||||
|
conn.execute(text("ALTER TABLE projects ALTER COLUMN location TYPE VARCHAR(256)"))
|
||||||
|
conn.execute(text("ALTER TABLE projects ALTER COLUMN location_en TYPE VARCHAR(256)"))
|
||||||
|
conn.execute(text("ALTER TABLE projects ALTER COLUMN usage TYPE VARCHAR(256)"))
|
||||||
|
conn.execute(text("ALTER TABLE projects ALTER COLUMN usage_en TYPE VARCHAR(256)"))
|
||||||
# نام نویسنده و توضیحات سئوی اختصاصی مقاله — فیلدهایی که پنل قبلاً نمایش میداد ولی در دیتابیس نبودند
|
# نام نویسنده و توضیحات سئوی اختصاصی مقاله — فیلدهایی که پنل قبلاً نمایش میداد ولی در دیتابیس نبودند
|
||||||
conn.execute(
|
conn.execute(
|
||||||
text("ALTER TABLE articles ADD COLUMN IF NOT EXISTS author VARCHAR(128) NOT NULL DEFAULT ''")
|
text("ALTER TABLE articles ADD COLUMN IF NOT EXISTS author VARCHAR(128) NOT NULL DEFAULT ''")
|
||||||
|
|||||||
+14
-4
@@ -64,8 +64,8 @@ class Project(Base):
|
|||||||
slug: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
slug: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
||||||
title: Mapped[str] = mapped_column(String(256))
|
title: Mapped[str] = mapped_column(String(256))
|
||||||
title_en: Mapped[str] = mapped_column(String(256), default="")
|
title_en: Mapped[str] = mapped_column(String(256), default="")
|
||||||
location: Mapped[str] = mapped_column(String(128), default="")
|
location: Mapped[str] = mapped_column(String(256), default="")
|
||||||
location_en: Mapped[str] = mapped_column(String(128), default="")
|
location_en: Mapped[str] = mapped_column(String(256), default="")
|
||||||
year: Mapped[str] = mapped_column(String(64), default="")
|
year: Mapped[str] = mapped_column(String(64), default="")
|
||||||
year_en: Mapped[str] = mapped_column(String(64), default="")
|
year_en: Mapped[str] = mapped_column(String(64), default="")
|
||||||
status: Mapped[str] = mapped_column(String(16), default="done") # done | progress
|
status: Mapped[str] = mapped_column(String(16), default="done") # done | progress
|
||||||
@@ -85,12 +85,17 @@ class Project(Base):
|
|||||||
# مشخصات تکمیلی پروژه — به درخواست تیم: نوع پروژه و کاربری
|
# مشخصات تکمیلی پروژه — به درخواست تیم: نوع پروژه و کاربری
|
||||||
project_type: Mapped[str] = mapped_column(String(128), default="")
|
project_type: Mapped[str] = mapped_column(String(128), default="")
|
||||||
project_type_en: Mapped[str] = mapped_column(String(128), default="")
|
project_type_en: Mapped[str] = mapped_column(String(128), default="")
|
||||||
usage: Mapped[str] = mapped_column(String(128), default="")
|
usage: Mapped[str] = mapped_column(String(256), default="")
|
||||||
usage_en: Mapped[str] = mapped_column(String(128), default="")
|
usage_en: Mapped[str] = mapped_column(String(256), default="")
|
||||||
summary: Mapped[str] = mapped_column(Text, default="")
|
summary: Mapped[str] = mapped_column(Text, default="")
|
||||||
summary_en: Mapped[str] = mapped_column(Text, default="")
|
summary_en: Mapped[str] = mapped_column(Text, default="")
|
||||||
body: Mapped[list] = mapped_column(JSON, default=list)
|
body: Mapped[list] = mapped_column(JSON, default=list)
|
||||||
body_en: Mapped[list] = mapped_column(JSON, default=list)
|
body_en: Mapped[list] = mapped_column(JSON, default=list)
|
||||||
|
# آخرین بهروزرسانی رکورد — فقط برای lastmod نقشه سایت؛ ردیفهای قدیمی NULL میمانند
|
||||||
|
# تا lastmod جعلی تولید نشود (با هر ذخیرهٔ پنل پر میشود)
|
||||||
|
updated_at: Mapped[datetime | None] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=utcnow, onupdate=utcnow, nullable=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Article(Base):
|
class Article(Base):
|
||||||
@@ -138,6 +143,11 @@ class Article(Base):
|
|||||||
# هشتگها/برچسبها — هر زبان جدا
|
# هشتگها/برچسبها — هر زبان جدا
|
||||||
tags: Mapped[list] = mapped_column(JSON, default=list)
|
tags: Mapped[list] = mapped_column(JSON, default=list)
|
||||||
tags_en: Mapped[list] = mapped_column(JSON, default=list)
|
tags_en: Mapped[list] = mapped_column(JSON, default=list)
|
||||||
|
# آخرین بهروزرسانی رکورد — فقط برای lastmod نقشه سایت؛ ردیفهای قدیمی NULL میمانند
|
||||||
|
# تا lastmod جعلی تولید نشود (با هر ذخیرهٔ پنل پر میشود)
|
||||||
|
updated_at: Mapped[datetime | None] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=utcnow, onupdate=utcnow, nullable=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Testimonial(Base):
|
class Testimonial(Base):
|
||||||
|
|||||||
Reference in New Issue
Block a user