Changeset 891 for trunk/Packages/Common
- Timestamp:
- Dec 30, 2020, 11:52:07 PM (4 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/AppModule.php
r890 r891 73 73 } 74 74 75 static function GetModels(): array 76 { 77 return array(); 78 } 79 75 80 function Install(): void 76 81 { … … 90 95 $this->Stop(); 91 96 $this->Installed = false; 92 $List = array(); 97 $List = array(); 93 98 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed)); 94 99 $this->Manager->Perform($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed)); … … 200 205 else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)'; 201 206 else if ($Column->Type == ModelColumnType::Date) $Query .= 'date'; 202 else if ($Column->Type == ModelColumnType::Enum) 207 else if ($Column->Type == ModelColumnType::Enum) 203 208 { 204 209 $Query .= 'enum("'.implode('", "', $Column->States).'")'; … … 238 243 "ADD CONSTRAINT `".$ModelDesc->Name."_ibfk_".$I."` FOREIGN KEY (`".$Column->Name."`) REFERENCES `".$Column->RefTable."` (`Id`);"; 239 244 } 240 echo($Query);241 245 $this->Database->query($Query); 242 246 } -
trunk/Packages/Common/Base.php
r890 r891 66 66 } 67 67 68 function AddText(string $Name): ModelColumnText 69 { 70 $Result = new ModelColumnText($Name); 71 $this->Columns[] = $Result; 72 return $Result; 73 } 74 68 75 function AddInteger(string $Name): ModelColumnInteger 69 76 { … … 94 101 } 95 102 96 function AddReference(string $Name, string $RefTable ): ModelColumnReference103 function AddReference(string $Name, string $RefTable, bool $Nullable = true): ModelColumnReference 97 104 { 98 105 $Result = new ModelColumnReference($Name, $RefTable); 99 106 $this->Columns[] = $Result; 107 $Result->Nullable = $Nullable; 100 108 return $Result; 101 109 } … … 114 122 $Column = $this->AddDateTime('ChangeTime'); 115 123 $Column->Nullable = true; 116 $this->AddInteger('ChangeReplaceId'); 124 $this->AddInteger('ChangeReplaceId'); 117 125 } 118 126 } -
trunk/Packages/Common/Setup.php
r887 r891 412 412 413 413 $this->Database->query('CREATE TABLE IF NOT EXISTS `'.$this->UpdateManager->VersionTable.'` ( 414 `Id` int(11) NOT NULL AUTO_INCREMENT,415 `Revision` int(11) NOT NULL,416 PRIMARY KEY (`Id`)417 ) ENGINE=InnoDBDEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');414 `Id` int(11) NOT NULL AUTO_INCREMENT, 415 `Revision` int(11) NOT NULL, 416 PRIMARY KEY (`Id`) 417 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); 418 418 $this->Database->query("INSERT INTO `".$this->UpdateManager->VersionTable."` (`Id`, `Revision`) VALUES 419 419 (1, ".$DatabaseRevision.");"); 420 420 $this->Database->query("CREATE TABLE IF NOT EXISTS `Module` ( 421 `Id` int(11) NOT NULL AUTO_INCREMENT, 422 `Name` varchar(255) NOT NULL, 423 `Title` varchar(255) NOT NULL, 424 PRIMARY KEY (`Id`) 425 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 421 `Id` int(11) NOT NULL AUTO_INCREMENT, 422 `Name` varchar(255) NOT NULL, 423 `Title` varchar(255) NOT NULL, 424 PRIMARY KEY (`Id`) 425 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 426 $this->Database->query("CREATE TABLE IF NOT EXISTS `ModuleModel` ( 427 `Id` int(11) NOT NULL AUTO_INCREMENT, 428 `Name` varchar(255) NOT NULL, 429 `Module` int(11) NOT NULL, 430 PRIMARY KEY (`Id`) 431 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 432 $this->Database->query('ALTER TABLE `ModuleModel` 433 ADD CONSTRAINT `ModuleModel_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);'); 434 $this->Database->query("CREATE TABLE IF NOT EXISTS `ModuleModelProperty` ( 435 `Id` int(11) NOT NULL AUTO_INCREMENT, 436 `Name` varchar(255) NOT NULL, 437 `Model` int(11) NOT NULL, 438 `Type` int(11) NOT NULL, 439 `Nullable` tinyint(1) NOT NULL, 440 PRIMARY KEY (`Id`) 441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 442 $this->Database->query('ALTER TABLE `ModuleModelProperty` 443 ADD CONSTRAINT `ModuleModelProperty_ibfk_1` FOREIGN KEY (`Model`) REFERENCES `ModuleModel` (`Id`);'); 426 444 } 427 445 … … 429 447 { 430 448 $this->System->ModuleManager->UninstallAll(); 449 $this->Database->query('DROP TABLE `ModuleModelProperty`'); 450 $this->Database->query('DROP TABLE `ModuleModel`'); 431 451 $this->Database->query('DROP TABLE `Module`'); 432 452 $this->Database->query('DROP TABLE `'.$this->UpdateManager->VersionTable.'`');
Note:
See TracChangeset
for help on using the changeset viewer.