elixirmigration.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:reahl 作者: reahl 项目源码 文件源码
def rename_pk(self, table_name, primary_key_columns, old_table_name=None):
        """Schedule changes necessary to rename a primary key (not the column) according to new naming conventions. It recreates the primary key,
           hence needs all info for doing so. 

           :arg table_name: The name of the table to which the primary key belongs.
           :arg primary_key_columns: A list of strings (unicode in Py2, str in Py3) containing the names of the columns that should be included in the primary key.
           :kwarg old_table_name: Specify old_table_name if the table is also renamed during this migration (even if for other reasons).
        """
        old_table_name = old_table_name or table_name
        self.schedule('drop_pk', op.drop_constraint, '%s_pkey' % old_table_name, old_table_name)
        self.schedule('create_pk', op.create_primary_key, 'pk_%s' % table_name, table_name, primary_key_columns)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号