<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 参考 https://sqlalchemy-migrate.readthedocs.org/en/latest/versioning.html#writing-for-a-specific-database</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 0.作用</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 可对数据库进行版本升级/降级</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 新版本的代码,数据库表结构发生变化。采用migrate可直接改变数据库的表结构而不影响原有的数据。</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 一。 SQLALchemy 迁移提供两种方式</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 1)api方式 migrate.versioning API</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 2)migrate 命令行方式</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 二。涉及概念<em><br> </em></p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> repository : 数据库迁移所需要的配置文件、脚本等保存的目录</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> <img alt="" height="78" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-49f45a5e905b0c201b18c50626a1b74a" style="border:none; max-width:100%" width="764"><br> </p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 三。迁移的工作流程</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> <span style="color:rgb(255,0,0)"><strong>命令行方式</strong></span><br> </p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 1.建立repository <br> </p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> </p>
<div class="dp-highlighter bg_plain" style="font-family:Consolas,'Courier New',Courier,mono,serif; background-color:rgb(231,229,220); width:687.0499877929688px; overflow:auto; padding-top:1px; margin:18px 0px!important; color:rgb(51,51,51); line-height:26px">
<div class="bar" style="padding-left:45px">
<div class="tools" style="padding:3px 8px 10px 10px; font-size:9px; line-height:normal; font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; color:silver; background-color:rgb(248,248,248); border-left-width:3px; border-left-style:solid; border-left-color:rgb(108,226,108)">
<strong>[plain]</strong>
<a class="ViewSource" href="http://blog.csdn.net/bellwhl/article/details/11529139#" rel="noopener noreferrer" style="color:rgb(160,160,160); text-decoration:none; background-color:inherit; border:none; padding:1px; margin:0px 10px 0px 0px; font-size:9px; display:inline-block; width:16px; height:16px; text-indent:-2000px" target="_blank" title="view plain">view plain</a>
<a class="CopyToClipboard" href="http://blog.csdn.net/bellwhl/article/details/11529139#" rel="noopener noreferrer" style="color:rgb(160,160,160); text-decoration:none; background-color:inherit; border:none; padding:1px; margin:0px 10px 0px 0px; font-size:9px; display:inline-block; width:16px; height:16px; text-indent:-2000px" target="_blank" title="copy">copy</a>
<div style="position:absolute; left:734px; top:959px; width:18px; height:18px; z-index:99">
</div>
</div>
</div>
<ol start="1" style="margin:0px 0px 1px 45px!important; padding:0px; border:none; list-style-position:initial; background-color:rgb(255,255,255); color:rgb(92,92,92)"><li class="alt" style="margin:0px!important; padding:0px 3px 0px 10px!important; border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px"> <span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit"><span style="margin:0px; padding:0px; border:none; background-color:inherit">migrate create /home/cloud/your_repository "example project" </span></span></li></ol>
</div>
<br style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">
<span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">在创建新的repository(/home/cloud/your_repository),名为'example project'</span>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> </p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> 目录下的内容</p>
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> </p>
<div class="dp-highlighter bg_plain" style="font-family:Consolas,'Courier New',Courier,mono,serif; background-color:rgb(231,229,220); width:687.0499877929688px; overflow:auto; padding-top:1px; margin:18px 0px!important; color:rgb(51,51,51); line-height:26px">
<div class="bar" style="padding-left:45px">
<div class="tools" style="padding:3px 8px 10px 10px; font-size:9px; line-height:normal; font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; color:silver; background-color:rgb(248,248,248); border-left-width:3px; border-left-style:solid; border-left-color:rgb(108,226,108)">
<strong>[plain]</strong>
<a class="ViewSource" href="http://blog.csdn.net/bellwhl/artic |
|