#!/usr/local/bin/python2.7
# -*- coding: UTF-8 -*-
"""
Update from version 2 to version 3 of Yokadi DB

@author: Sébastien Renard <Sebastien.Renard@digitalfox.org>
@license: GPLv3
"""
import sys
from os.path import dirname, join

from sqlobject import connectionForURI, RelatedJoin, sqlhub, SQLObject

""" This is a fake table (we only need table name) """
class Project(SQLObject):
    pass

def alterProjectTable():
    Project.sqlmeta.addJoin(RelatedJoin("Keyword",
                                          createRelatedTable=False,
                                          intermediateTable="project_keyword",
                                          joinColumn="project_id",
                                          otherColumn="keyword_id"))

def main():
    sqlhub.processConnection = connectionForURI('sqlite:' + sys.argv[1])
    alterProjectTable()


if __name__ == "__main__":
    main()
# vi: ts=4 sw=4 et
