Files
2026-02-05 10:15:46 +08:00

83 lines
2.6 KiB
Python

"""062_system_variable
Revision ID: ed947895d470
Revises: 547df942eb90
Create Date: 2026-01-26 10:16:59.877303
"""
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from alembic import op
from sqlalchemy import String, BigInteger, DateTime
from sqlalchemy.dialects import postgresql
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.sql import table, column
# revision identifiers, used by Alembic.
revision = 'ed947895d470'
down_revision = 'c8751179a8de'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('system_variable',
sa.Column('id', sa.BigInteger(), sa.Identity(always=True), nullable=False),
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False),
sa.Column('var_type', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False),
sa.Column('type', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False),
sa.Column('value', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('create_time', sa.DateTime(), nullable=True),
sa.Column('create_by', sa.BigInteger(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
variable_table = table(
"system_variable",
column("id", BigInteger),
column("name", String),
column("var_type", String),
column("type", String),
column("value", JSONB),
column("create_time", DateTime),
column("create_by", BigInteger),
)
op.bulk_insert(
variable_table,
[
{
"name": "i18n_variable.name",
"var_type": "text",
"type": "system",
"value": ["name"],
"create_time": None,
"create_by": None
},
{
"name": "i18n_variable.account",
"var_type": "text",
"type": "system",
"value": ["account"],
"create_time": None,
"create_by": None
},
{
"name": "i18n_variable.email",
"var_type": "text",
"type": "system",
"value": ["email"],
"create_time": None,
"create_by": None
}
]
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('system_variable')
# ### end Alembic commands ###