Merge pull request #128 from GraemeHarris/add-lang-column

Added column to post table for lang with US english set to default.
This commit is contained in:
Yannic Kilcher
2022-12-29 21:33:41 +01:00
committed by GitHub
2 changed files with 32 additions and 0 deletions
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
"""Added lang column for ISO-639-1 codes
Revision ID: ef0b52902560
Revises: 3358eb6834e6
Create Date: 2022-12-28 18:24:21.393973
"""
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision = "ef0b52902560"
down_revision = "3358eb6834e6"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"post", sa.Column("lang", sqlmodel.sql.sqltypes.AutoString(length=200), nullable=False, default="en-US")
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("post", "lang")
# ### end Alembic commands ###
+1
View File
@@ -31,5 +31,6 @@ class Post(SQLModel, table=True):
)
payload_type: str = Field(nullable=False, max_length=200)
payload: PayloadContainer = Field(sa_column=sa.Column(payload_column_type(PayloadContainer), nullable=True))
lang: str = Field(nullable=False, max_length=200, default="en-US")
depth: int = Field(sa_column=sa.Column(sa.Integer, default=0, server_default=sa.text("0"), nullable=False))
children_count: int = Field(sa_column=sa.Column(sa.Integer, default=0, server_default=sa.text("0"), nullable=False))