Commit c3b97fdd239b516cbc0308762a130f103e7c2f1a

Fix db create error in MySQL

  - MySQL needs fixed lengths in VARCHAR datatypes. Fixing code to have that
    for MySQL.
  • Diff rendering mode:
  • inline
  • side by side

dbsetup.py

2020
21# Import all modules which represents a SQLAlchemy model;21# Import all modules which represents a SQLAlchemy model;
22# they have corresponding tables that are needed to be created22# they have corresponding tables that are needed to be created
23from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients
23from swtstore.classes.models import Sweet, Context, Client
24from swtstore.classes.models.um import User, Group, Membership24from swtstore.classes.models.um import User, Group, Membership
2525
26# Create them!
27db.create_all()
26
27if __name__ == '__main__':
28 # Create them!
29 db.create_all()

swtstore/classes/models/sweet.py

25 context_id = db.Column(db.Integer, db.ForeignKey('contexts.id'))25 context_id = db.Column(db.Integer, db.ForeignKey('contexts.id'))
26 what = db.relationship('Context')26 what = db.relationship('Context')
2727
28 where = db.Column(db.String, nullable=False)
28 where = db.Column(db.UnicodeText, nullable=False)
2929
30 how = db.Column(JSONType)30 how = db.Column(JSONType)
3131

swtstore/classes/models/types.py

15 similarly, convert string to dict while loading from database15 similarly, convert string to dict while loading from database
16 """16 """
1717
18 impl = types.Unicode
18 impl = types.UnicodeText
1919
20 def process_bind_param(self, value, dialect):20 def process_bind_param(self, value, dialect):
21 return json.dumps(value)21 return json.dumps(value)