|
@@ -5,7 +5,7 @@ from Database.sqlwrapper import SqlWrapper
|
5
|
5
|
class SQLSetup(object):
|
6
|
6
|
|
7
|
7
|
def initDb(self, dbconfname = 'default'):
|
8
|
|
- db = SqlWrapper(read_db = dbconfname, write_db = dbconfname)
|
|
8
|
+ db = SqlWrapper(read_db = dbconfname, write_db = dbconfname, alchemy_logs=True)
|
9
|
9
|
tables = self.get_schema()
|
10
|
10
|
db.dropAll()
|
11
|
11
|
db.createAllFromConf(tables)
|
|
@@ -14,7 +14,7 @@ class SQLSetup(object):
|
14
|
14
|
tables = []
|
15
|
15
|
|
16
|
16
|
default_columns = [
|
17
|
|
- {"name":"uid", "type":"VARCHAR(50)", "extra":{"foreignkey":"uids.uid", "nullable":False, "primarykey":True}},
|
|
17
|
+ {"name":"uid", "type":"INTEGER", "extra":{"foreignkey":"uids.uid", "nullable":False, "primarykey":True}},
|
18
|
18
|
{"name":"name", "type":"VARCHAR(50)", "extra":{"nullable":False, "unique":True}},
|
19
|
19
|
{"name":"string", "type":"TEXT"},
|
20
|
20
|
{"name":"help", "type":"TEXT"},
|
|
@@ -47,7 +47,7 @@ class SQLSetup(object):
|
47
|
47
|
# Table listing the types
|
48
|
48
|
em_type = {"name":"em_type"}
|
49
|
49
|
em_type['columns'] = default_columns + [
|
50
|
|
- {"name":"class_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_class.uid", "nullable":False}},
|
|
50
|
+ {"name":"class_id", "type":"INTEGER", "extra":{"foreignkey":"em_class.uid", "nullable":False}},
|
51
|
51
|
{"name":"sortcolumn", "type":"VARCHAR(50)", "extra":{"default":"rank"}},
|
52
|
52
|
{"name":"icon", "type":"INTEGER"},
|
53
|
53
|
]
|
|
@@ -56,8 +56,8 @@ class SQLSetup(object):
|
56
|
56
|
# relation between types: which type can be a child of another
|
57
|
57
|
em_type_hierarchy = {"name":"em_type_hierarchy"}
|
58
|
58
|
em_type_hierarchy['columns'] = [
|
59
|
|
- {"name":"superior_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_type.uid", "nullable":False, "primarykey":True}},
|
60
|
|
- {"name":"subordinate_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_type.uid", "nullable":False, "primarykey":True}},
|
|
59
|
+ {"name":"superior_id", "type":"INTEGER", "extra":{"foreignkey":"em_type.uid", "nullable":False, "primarykey":True}},
|
|
60
|
+ {"name":"subordinate_id", "type":"INTEGER", "extra":{"foreignkey":"em_type.uid", "nullable":False, "primarykey":True}},
|
61
|
61
|
{"name":"nature", "type":"VARCHAR(50)"},
|
62
|
62
|
]
|
63
|
63
|
tables.append(em_type_hierarchy)
|
|
@@ -65,17 +65,17 @@ class SQLSetup(object):
|
65
|
65
|
# Table listing the fieldgroups of a class
|
66
|
66
|
em_fieldgroup = {"name":"em_fieldgroup"}
|
67
|
67
|
em_fieldgroup['columns'] = default_columns + [
|
68
|
|
- {"name":"class_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_class.uid", "nullable":False}},
|
|
68
|
+ {"name":"class_id", "type":"INTEGER", "extra":{"foreignkey":"em_class.uid", "nullable":False}},
|
69
|
69
|
]
|
70
|
70
|
tables.append(em_fieldgroup)
|
71
|
71
|
|
72
|
72
|
# Table listing the fields of a fieldgroup
|
73
|
73
|
em_field = {"name":"em_field"}
|
74
|
74
|
em_field['columns'] = default_columns + [
|
75
|
|
- {"name":"fieldtype_id", "type":"VARCHAR(50)", "extra":{"nullable":False}},
|
76
|
|
- {"name":"fieldgroup_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_fieldgroup.uid", "nullable":False}},
|
77
|
|
- {"name":"rel_to_type_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_type.uid", "nullable":False}}, # if relational: type this field refer to
|
78
|
|
- {"name":"rel_field_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_type.uid", "nullable":False}}, # if relational: field that specify the rel_to_type_id
|
|
75
|
+ {"name":"fieldtype_id", "type":"INTEGER", "extra":{"nullable":False}},
|
|
76
|
+ {"name":"fieldgroup_id", "type":"INTEGER", "extra":{"foreignkey":"em_fieldgroup.uid", "nullable":False}},
|
|
77
|
+ {"name":"rel_to_type_id", "type":"INTEGER", "extra":{"foreignkey":"em_type.uid", "nullable":False}}, # if relational: type this field refer to
|
|
78
|
+ {"name":"rel_field_id", "type":"INTEGER", "extra":{"foreignkey":"em_type.uid", "nullable":False}}, # if relational: field that specify the rel_to_type_id
|
79
|
79
|
{"name":"optional", "type":"BOOLEAN"},
|
80
|
80
|
{"name":"internal", "type":"BOOLEAN"},
|
81
|
81
|
{"name":"icon", "type":"INTEGER"},
|
|
@@ -85,8 +85,8 @@ class SQLSetup(object):
|
85
|
85
|
# selected field for each type
|
86
|
86
|
em_field_type = {"name":"em_field_type"}
|
87
|
87
|
em_field_type['columns'] = [
|
88
|
|
- {"name":"type_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_type.uid", "nullable":False, "primarykey":True}},
|
89
|
|
- {"name":"field_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_field.uid", "nullable":False, "primarykey":True}},
|
|
88
|
+ {"name":"type_id", "type":"INTEGER", "extra":{"foreignkey":"em_type.uid", "nullable":False, "primarykey":True}},
|
|
89
|
+ {"name":"field_id", "type":"INTEGER", "extra":{"foreignkey":"em_field.uid", "nullable":False, "primarykey":True}},
|
90
|
90
|
]
|
91
|
91
|
tables.append(em_field_type)
|
92
|
92
|
|
|
@@ -94,10 +94,10 @@ class SQLSetup(object):
|
94
|
94
|
objects = {
|
95
|
95
|
"name":"objects",
|
96
|
96
|
"columns":[
|
97
|
|
- {"name":"uid", "type":"VARCHAR(50)", "extra":{"foreignkey":"uids.uid", "nullable":False, "primarykey":True}},
|
|
97
|
+ {"name":"uid", "type":"INTEGER", "extra":{"foreignkey":"uids.uid", "nullable":False, "primarykey":True}},
|
98
|
98
|
{"name":"string", "type":"VARCHAR(50)"},
|
99
|
|
- {"name":"class_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_class.uid"}},
|
100
|
|
- {"name":"type_id", "type":"VARCHAR(50)", "extra":{"foreignkey":"em_type.uid"}},
|
|
99
|
+ {"name":"class_id", "type":"INTEGER", "extra":{"foreignkey":"em_class.uid"}},
|
|
100
|
+ {"name":"type_id", "type":"INTEGER", "extra":{"foreignkey":"em_type.uid"}},
|
101
|
101
|
{"name":"date_update", "type":"DATE"},
|
102
|
102
|
{"name":"date_create", "type":"DATE"},
|
103
|
103
|
{"name":"history", "type":"TEXT"}
|
|
@@ -110,7 +110,7 @@ class SQLSetup(object):
|
110
|
110
|
files = {
|
111
|
111
|
"name":"files",
|
112
|
112
|
"columns":[
|
113
|
|
- {"name":"uid", "type":"VARCHAR(50)", "extra":{"foreignkey":"uids.uid", "nullable":False, "primarykey":True}},
|
|
113
|
+ {"name":"uid", "type":"INTEGER", "extra":{"foreignkey":"uids.uid", "nullable":False, "primarykey":True}},
|
114
|
114
|
{"name":"field1", "type":"VARCHAR(50)"}
|
115
|
115
|
]
|
116
|
116
|
}
|