24 lines
927 B
Python
Executable File
24 lines
927 B
Python
Executable File
import subprocess
|
||
|
||
def run_service():
|
||
# 激活虚拟环境并运行服务
|
||
# 注意:这里的命令被组合成了一个bash脚本字符串
|
||
# 首先激活虚拟环境,然后改变目录,最后执行alembic命令
|
||
bash_cmd = f"""
|
||
source /home/lqs1/app/venv/bin/activate && \
|
||
cd /home/lqs1/app/backend/database && \
|
||
alembic revision -m "Add shuai column"
|
||
|
||
"""
|
||
|
||
# 使用 Popen 执行bash命令
|
||
# 注意:这里使用shell=True,因为我们正在执行一个bash脚本
|
||
# executable='/bin/bash' 是可选的,因为默认就是bash,但明确指出也无妨
|
||
subprocess.Popen(bash_cmd, shell=True, executable='/bin/bash')
|
||
|
||
if __name__ == '__main__':
|
||
run_service()
|
||
# alembic revision --autogenerate -m "Add is_superuser column to admin table2" && \
|
||
# alembic revision -m "Initial migration" --autogenerate && \
|
||
# alembic upgrade head
|