Commit c3b97fdd239b516cbc0308762a130f103e7c2f1a
Fix db create error in MySQL
- MySQL needs fixed lengths in VARCHAR datatypes. Fixing code to have that
for MySQL.
| | | | 20 | | 20 | |
---|
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 created | 22 | # they have corresponding tables that are needed to be created |
---|
23 | from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients | | from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients |
---|
| | 23 | from swtstore.classes.models import Sweet, Context, Client | 24 | from swtstore.classes.models.um import User, Group, Membership | 24 | from swtstore.classes.models.um import User, Group, Membership |
---|
25 | | 25 | |
---|
26 | # Create them! | | # Create them! |
---|
27 | db.create_all() | | db.create_all() |
---|
| | 26 | | | | 27 | if __name__ == '__main__': |
---|
| | 28 | # Create them! |
---|
| | 29 | db.create_all() |
---|
| | | | 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') |
---|
27 | | 27 | |
---|
28 | where = db.Column(db.String, nullable=False) | | where = db.Column(db.String, nullable=False) |
---|
| | 28 | where = db.Column(db.UnicodeText, nullable=False) | 29 | | 29 | |
---|
30 | how = db.Column(JSONType) | 30 | how = db.Column(JSONType) |
---|
31 | | 31 | |
---|
| | | | 15 | similarly, convert string to dict while loading from database | 15 | similarly, convert string to dict while loading from database |
---|
16 | """ | 16 | """ |
---|
17 | | 17 | |
---|
18 | impl = types.Unicode | | impl = types.Unicode |
---|
| | 18 | impl = types.UnicodeText | 19 | | 19 | |
---|
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) |
---|