Changeset 891 for trunk/Packages/Common


Ignore:
Timestamp:
Dec 30, 2020, 11:52:07 PM (4 years ago)
Author:
chronos
Message:
  • Added: More modules models installation.
Location:
trunk/Packages/Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/AppModule.php

    r890 r891  
    7373  }
    7474
     75  static function GetModels(): array
     76  {
     77    return array();
     78  }
     79
    7580  function Install(): void
    7681  {
     
    9095    $this->Stop();
    9196    $this->Installed = false;
    92     $List = array();   
     97    $List = array();
    9398    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed));
    9499    $this->Manager->Perform($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed));
     
    200205      else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)';
    201206      else if ($Column->Type == ModelColumnType::Date) $Query .= 'date';
    202       else if ($Column->Type == ModelColumnType::Enum) 
     207      else if ($Column->Type == ModelColumnType::Enum)
    203208      {
    204209        $Query .= 'enum("'.implode('", "', $Column->States).'")';
     
    238243        "ADD CONSTRAINT `".$ModelDesc->Name."_ibfk_".$I."` FOREIGN KEY (`".$Column->Name."`) REFERENCES `".$Column->RefTable."` (`Id`);";
    239244    }
    240     echo($Query);
    241245    $this->Database->query($Query);
    242246  }
  • trunk/Packages/Common/Base.php

    r890 r891  
    6666  }
    6767
     68  function AddText(string $Name): ModelColumnText
     69  {
     70    $Result = new ModelColumnText($Name);
     71    $this->Columns[] = $Result;
     72    return $Result;
     73  }
     74
    6875  function AddInteger(string $Name): ModelColumnInteger
    6976  {
     
    94101  }
    95102
    96   function AddReference(string $Name, string $RefTable): ModelColumnReference
     103  function AddReference(string $Name, string $RefTable, bool $Nullable = true): ModelColumnReference
    97104  {
    98105    $Result = new ModelColumnReference($Name, $RefTable);
    99106    $this->Columns[] = $Result;
     107    $Result->Nullable = $Nullable;
    100108    return $Result;
    101109  }
     
    114122    $Column = $this->AddDateTime('ChangeTime');
    115123    $Column->Nullable = true;
    116     $this->AddInteger('ChangeReplaceId');   
     124    $this->AddInteger('ChangeReplaceId');
    117125  }
    118126}
  • trunk/Packages/Common/Setup.php

    r887 r891  
    412412
    413413    $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=InnoDB DEFAULT 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 ;');
    418418    $this->Database->query("INSERT INTO `".$this->UpdateManager->VersionTable."` (`Id`, `Revision`) VALUES
    419419      (1, ".$DatabaseRevision.");");
    420420    $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`);');
    426444  }
    427445
     
    429447  {
    430448    $this->System->ModuleManager->UninstallAll();
     449    $this->Database->query('DROP TABLE `ModuleModelProperty`');
     450    $this->Database->query('DROP TABLE `ModuleModel`');
    431451    $this->Database->query('DROP TABLE `Module`');
    432452    $this->Database->query('DROP TABLE `'.$this->UpdateManager->VersionTable.'`');
Note: See TracChangeset for help on using the changeset viewer.