推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ivenlee
V2EX  ›  Python

sqlalchemy 模型改变了怎样同步到数据库。

  •  
  •   ivenlee · Apr 3, 2016 · 5329 views
    This topic created in 3693 days ago, the information mentioned may be changed or developed.
    http://www.zhihu.com/question/27551008/answer/68916625
    在知乎看到这样的回答,请问你们用的是哪一种?
    12 replies    2016-04-05 16:45:49 +08:00
    linnchord
        1
    linnchord  
       Apr 3, 2016
    一个严肃软件工程项目的一环, 3 。
    一个小的手工作坊式或信奉 dirty+quick 的软件项目, 2 。
    自己随便捣腾个新项目, 1 。
    ivenlee
        2
    ivenlee  
    OP
       Apr 3, 2016
    @linnchord 我也觉得在开发环境 把 table drop 掉是最快的。
    janxin
        3
    janxin  
       Apr 3, 2016 via iPhone
    开发环境是 drop 然后 create , flask-script 做个命令挺方便的。

    回到线上环境, 3 是比较靠近实际的方案
    clino
        4
    clino  
       Apr 3, 2016
    用过 alembic 感觉很方便,但貌似有时候会出点问题
    不行就自己写 sql 了
    orvice
        5
    orvice  
       Apr 3, 2016
    开发环境随便搞
    显示不是要给 dba 操作么
    wklken
        6
    wklken  
       Apr 3, 2016
    alembic 完美解决.....跟 django migration 差不多
    Livid
        7
    Livid  
    MOD
    PRO
       Apr 3, 2016
    每一个表结构的更改语句 ALTER TABLE ,都用一个文件记录下来,文件名是日期加功能的关键字,比如:

    sql/20160401_feature.sql

    然后这个文件和代码一起入版本控制。
    monkeylyf
        8
    monkeylyf  
       Apr 4, 2016
    alembic
    ivenlee
        9
    ivenlee  
    OP
       Apr 4, 2016
    @Livid 说的怎么跟 migration 那么像呢? 类似 alter table drop column 之前一般要备份吗? 前意识总觉得需要先备份一下(最起码备份被改动的表)
    ivenlee
        10
    ivenlee  
    OP
       Apr 4, 2016
    @wklken @clino @monkeylyf 好的,谢谢。 我回头了解一下 alembic
    Dik1s
        11
    Dik1s  
       Apr 5, 2016 via iPhone
    flask 有个 migrate
    wingyiu
        12
    wingyiu  
       Apr 5, 2016
    让 alembic 帮你做
    或者像 @Livid 那样自己动手
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1044 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 18:41 · PVG 02:41 · LAX 11:41 · JFK 14:41
    ♥ Do have faith in what you're doing.