Ignore:
Timestamp:
Mar 30, 2012, 2:02:51 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Instalace a odinstalace je nyní spravována samostatným skriptem install.php.
  • Upraveno: Částečné řešení odstranění cizích klíčů v průběhu odinstalace před odstraněním samotných tabulek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Modular/Common/Module.php

    r398 r401  
    120120  {
    121121    //DebugLog('Installing modular system core...');
     122    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` (
     123  `Id` int(11) NOT NULL AUTO_INCREMENT,
     124  `Version` varchar(255) COLLATE utf8_czech_ci NOT NULL,
     125  `Description` datetime NOT NULL,
     126  PRIMARY KEY (`Id`)
     127) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
    122128    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModule` (
    123129  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    140146  UNIQUE (`Module` , `DependencyModule`)
    141147) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
    142     $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');
    143     $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)');
     148    $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD CONSTRAINT `SystemModuleDependency_ibfk_1` FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');
     149    $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD CONSTRAINT `SystemModuleDependency_ibfk_2` FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)');
    144150   
    145151    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` (
     
    150156  PRIMARY KEY (`Id`)
    151157) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
    152     $this->Database->query('ALTER TABLE `SystemModel` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');
     158    $this->Database->query('ALTER TABLE `SystemModel` ADD CONSTRAINT `SystemModel_ibfk_1` FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');
    153159   
    154160    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` (
     
    160166  PRIMARY KEY (`Id`)
    161167) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
    162     $this->Database->query('ALTER TABLE `SystemModelProperty` ADD FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)');
     168    $this->Database->query('ALTER TABLE `SystemModelProperty` ADD CONSTRAINT `SystemModelProperty_ibfk_1` FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)');
    163169   
    164170    $this->ReloadList();
     
    178184   
    179185    // Delete tables with reverse order
     186    $this->Database->query('ALTER TABLE `SystemModelProperty` DROP FOREIGN KEY `SystemModelProperty_ibfk_1`');
    180187    $this->Database->query('DROP TABLE IF EXISTS `SystemModelProperty`');
     188    $this->Database->query('ALTER TABLE `SystemModel` DROP FOREIGN KEY `SystemModel_ibfk_1`');
    181189    $this->Database->query('DROP TABLE IF EXISTS `SystemModel`');
     190    $this->Database->query('ALTER TABLE `SystemModuleDependency` DROP FOREIGN KEY `SystemModuleDependency_ibfk_1`');
     191    $this->Database->query('ALTER TABLE `SystemModuleDependency` DROP FOREIGN KEY `SystemModuleDependency_ibfk_2`');
    182192    $this->Database->query('DROP TABLE IF EXISTS `SystemModuleDependency`');
    183193    $this->Database->query('DROP TABLE IF EXISTS `SystemModule`');
     194    $this->Database->query('DROP TABLE IF EXISTS `SystemVersion`');
     195  }
     196 
     197  function IsInstalled()
     198  {
     199    $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables
     200WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";');   
     201    if($DbResult->num_rows > 0) return(true);
     202      else return(false);
    184203  }
    185204 
Note: See TracChangeset for help on using the changeset viewer.