0008_to_version_1.py 文件源码

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

项目:vaultier 作者: Movile 项目源码 文件源码
def migrate_from_workspaces(apps, schema_editor):

    if not workspace_exists():
        return

    cursor = connection.cursor()
    cursor.execute("ALTER TABLE public.vaultier_member ALTER COLUMN workspace_id DROP NOT NULL;")
    cursor.execute("SELECT * FROM vaultier_workspace")
    nodes = []
    for w in _dictfetchall(cursor):
        node = Node(
            name=w['name'],
            meta=json.dumps({'description': w['description']}),
            created_by_id=w['created_by_id'],
            type=1


        )
        node.save()
        node.acl.initialize_node()
        node._workspace = w['id']
        nodes.append(node)
        _migrate_members(node)
        _migrate_vaults(node)
        _migrate_acl('workspace', w['id'], node)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号