Commits

Guido Draheim committed 9d4f631

create usernotes_info tables

Comments (0)

Files changed (2)

src/usernotes/db/db2.py

+from sqlalchemy import Column, Integer, String, DateTime
+from sqlalchemy.ext.declarative import declarative_base
+UserNotesModel = declarative_base()
+
+class NotesMail(UserNotesModel):
+    __tablename__ = "usernotes_mail"
+    created_by = Column(String)
+    created_on = Column(DateTime)
+    mail_domain = Column(String, primary_key=True)
+    mail_from = Column(String, primary_key=True)
+    mail_user = Column(String, primary_key=True)
+    mail_date = Column(DateTime, primary_key=True)
+    mail_call = Column(String)
+    mail_text = Column(String)
+    mail_info = Column(String)
+    mimetype = Column(String)
+    encrypted = Column(String)
+
+class NotesInfo(UserNotesModel):
+    __tablename__ = "usernotes_info"
+    modified_by = Column(String)
+    modified_on = Column(DateTime)
+    note_domain = Column(String, primary_key=True)
+    note_user = Column(String, primary_key=True)
+    note_field = Column(String, primary_key=True)
+    note_string = Column(String)
+    note_number = Column(Integer)
+    note_date = Column(DateTime)
+
+class NotesFields(UserNotesModel):
+    __tablename__ = "usernotes_fields"
+    modified_by = Column(String)
+    modified_on = Column(DateTime)
+    note_domain = Column(String, primary_key=True)
+    note_field = Column(String, primary_key=True)
+    note_typed = Column(String)
+    note_range = Column(String)
+
+metadata = UserNotesModel.metadata
+
+def create_all(env, cursor):
+    import session
+    session = session.context(env)
+    metadata.create_all(bind=session.bind)
+
+def upgrade(env, cursor):
+    import schemachange
+    try:
+        for sql in schemachange.migrate_AtoB(old_metadata(), metadata, env, excludeTables = None):
+            print sql
+    except Exception, e:
+        import traceback
+        traceback.print_exc(e)
+        raise
+
+def downgrade(env, cursor):
+    import schemachange
+    for sql in schemachange.migrate_BtoA(old_metadata(), metadata, env, excludeTables = None):
+        print sql
+
+def old_metadata():
+    import db1
+    return db1.metadata
+
+if __name__ == "__main__":
+    from sqlalchemy import create_engine
+    engine = create_engine('sqlite:///:memory:', echo=True)
+    UserNotesModel.metadata.create_all(engine) 

src/usernotes/db/version.py

-number = 1
+number = 2