Changeset 37 for trunk/Module
- Timestamp:
- Mar 8, 2012, 3:11:10 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Module/UModuleSystem.pas
r29 r37 26 26 27 27 uses 28 USystem, USqlDatabase ;28 USystem, USqlDatabase, UChronisClient; 29 29 30 30 { TModuleSystem } … … 86 86 GroupId := AddObjectGroup('System'); 87 87 88 ObjectGroupId := AddObject('Object groups', 'ObjectGroup', Database.Database, GroupId);88 ObjectGroupId := AddObject('Object groups', 'ObjectGroup', Client.Schema, GroupId); 89 89 AddPropertyNumber(ObjectGroupId, 'Id', 'Id', False); 90 90 AddPropertyString(ObjectGroupId, 'Name', 'Name', True); 91 91 ObjectGroupParentId := AddPropertyRelationOne(ObjectGroupId, 'Parent', 'Parent', True, ObjectGroupId); 92 92 93 ObjectId := AddObject('Objects', 'Object', Database.Database, GroupId);93 ObjectId := AddObject('Objects', 'Object', Client.Schema, GroupId); 94 94 AddPropertyNumber(ObjectId, 'Id', 'Id', False); 95 95 AddPropertyString(ObjectId, 'Name', 'Name', True); … … 100 100 AddPropertyNumber(ObjectId, 'Sequence', 'Sequence', True); 101 101 102 PropertyTypeId := AddObject('Property types', 'Type', Database.Database, GroupId);102 PropertyTypeId := AddObject('Property types', 'Type', Client.Schema, GroupId); 103 103 AddPropertyNumber(PropertyTypeId, 'Id', 'Id', False); 104 104 AddPropertyString(PropertyTypeId, 'Name', 'Name', True); … … 106 106 //AddPropertyNumber(ObjectId, 'Parent', 'Parent'); 107 107 108 CustomTypeId := AddObject('Custom types', 'TypeCustom', Database.Database, GroupId);108 CustomTypeId := AddObject('Custom types', 'TypeCustom', Client.Schema, GroupId); 109 109 AddPropertyNumber(CustomTypeId, 'Id', 'Id', False); 110 110 CustomTypeIdType := AddPropertyRelationOne(CustomTypeId, 'Type', 'Type', True, PropertyTypeId); 111 111 112 ObjectPropertyGroupId := AddObject('Property groups', 'PropertyGroup', Database.Database, GroupId);112 ObjectPropertyGroupId := AddObject('Property groups', 'PropertyGroup', Client.Schema, GroupId); 113 113 AddPropertyNumber(ObjectPropertyGroupId, 'Id', 'Id', False); 114 114 115 ObjectPropertyId := AddObject('Properties', 'Property', Database.Database, GroupId);115 ObjectPropertyId := AddObject('Properties', 'Property', Client.Schema, GroupId); 116 116 AddPropertyNumber(ObjectPropertyId, 'Id', 'Id', False); 117 117 AddPropertyString(ObjectPropertyId, 'Name', 'Name', True); … … 127 127 AddPropertyRelationMany(ObjectPropertyGroupId, 'Properties', 'Properties', True, ObjectPropertyIdGroup); 128 128 AddPropertyRelationMany(PropertyTypeId, 'Custom types', 'CustomTypes', True, CustomTypeIdType); 129 ModuleId := AddObject('Modules', 'Module', Database.Database, GroupId); 129 130 ModuleId := AddObject('Modules', 'Module', Client.Schema, GroupId); 130 131 AddPropertyNumber(ModuleId, 'Id', 'Id', False); 131 132 AddPropertyString(ModuleId, 'Name', 'Name', True); … … 149 150 procedure TModuleSystem.InitStructure; 150 151 var 151 DbRows: TDbRows;152 DbRows2: TDbRows;153 152 StructureVersion: string; 154 153 Data: TDictionaryStringString; … … 156 155 Tables: TListString; 157 156 I: Integer; 157 NewProxy: TListProxy; 158 158 begin 159 159 with TChronisBase(System) do 160 160 try 161 DbRows := TDbRows.Create;162 161 Tables := TListString.Create; 163 162 Data := TDictionaryStringString.Create; 164 163 165 Database.Query(DbRows, 'SHOW TABLES'); 166 Tables.Count := DbRows.Count; 167 for I := 0 to DbRows.Count - 1 do 168 Tables[I] := DbRows[I].Items[0].Value; 169 170 if Tables.IndexOf(InformationTable) = -1 then begin 171 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + InformationTable + '` ( ' + 172 '`Version` varchar(255) NOT NULL,' + 173 '`LastUpdateTime` datetime NOT NULL' + 174 ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'); 175 Database.Query(DbRows, 'INSERT INTO `' + InformationTable + '` (`Version`, `LastUpdateTime`) VALUES ' + 176 '("0.1", "0000-00-00 00:00:00");'); 177 end; 178 Database.Select(DbRows, InformationTable); 179 StructureVersion := DbRows[0].Values['Version']; 180 181 if Tables.IndexOf(ObjectTable) = -1 then begin 164 NewProxy := TListProxy.Create; 165 NewProxy.SchemaName := 'information_schema'; 166 NewProxy.ObjectName := 'TABLES'; 167 NewProxy.Condition := 'TABLE_SCHEMA = "' + Client.Schema + '"'; 168 NewProxy.Load; 169 //Database.Query(DbRows, 'SHOW TABLES'); 170 Tables.Count := NewProxy.Objects.Count; 171 for I := 0 to NewProxy.Objects.Count - 1 do 172 Tables[I] := TObjectProxy(NewProxy.Objects[I]).Properties.Values['TABLE']; 173 174 (* if Tables.IndexOf(ObjectTable) = -1 then begin 182 175 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + ObjectTable + '` ( ' + 183 176 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + … … 372 365 'PRIMARY KEY (`Id`)' + 373 366 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 374 end; 367 end; *) 375 368 finally 376 369 Tables.Free; 377 370 Data.Free; 378 DbRows.Free;371 NewProxy.Free; 379 372 end; 380 373 end;
Note:
See TracChangeset
for help on using the changeset viewer.