Ignore:
Timestamp:
Sep 10, 2015, 9:51:23 PM (9 years ago)
Author:
chronos
Message:
  • Added: More appmodule install/uninstallation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Subject/Subject.php

    r740 r745  
    1111    $this->License = 'GNU/GPL';
    1212    $this->Description = 'Subject management';
    13     $this->Dependencies = array('User');
     13    $this->Dependencies = array('User', 'Map');
    1414  }
    1515
     
    116116    ));
    117117  }
     118
     119  function DoInstall()
     120  {
     121    $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` (
     122  `Id` int(11) NOT NULL AUTO_INCREMENT,
     123  `Name` varchar(64) NOT NULL DEFAULT '',
     124  `AddressStreet` varchar(64) NOT NULL DEFAULT '',
     125  `AddressTown` varchar(64) NOT NULL DEFAULT '',
     126  `AddressPSC` int(11) NOT NULL DEFAULT '0',
     127  `AddressCountry` int(11) NOT NULL,
     128  `IC` varchar(32) NOT NULL,
     129  `DIC` varchar(32) NOT NULL DEFAULT '',
     130  `PayVAT` int(11) NOT NULL,
     131  `MapPosition` int(11) DEFAULT NULL,
     132  `WWW` varchar(255) NOT NULL,
     133  `Note` varchar(255) NOT NULL,
     134  PRIMARY KEY (`Id`)
     135) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     136    $this->Database->query("CREATE TABLE IF NOT EXISTS `Contact` (
     137  `Id` int(11) NOT NULL AUTO_INCREMENT,
     138  `Category` int(11) NOT NULL,
     139  `Value` varchar(255) NOT NULL,
     140  `Subject` int(11) DEFAULT NULL,
     141  `User` int(11) DEFAULT NULL,
     142  `Description` varchar(255) NOT NULL,
     143  `Receive` tinyint(1) NOT NULL,
     144  PRIMARY KEY (`Id`)
     145) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     146    $this->System->Database->query("CREATE TABLE IF NOT EXISTS `ContactCategory` (
     147  `Id` int(11) NOT NULL AUTO_INCREMENT,
     148  `Name` varchar(255) NOT NULL,
     149  PRIMARY KEY (`Id`)
     150) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     151
     152    $this->Database->query("ALTER TABLE `Subject`
     153ADD CONSTRAINT `Subject_ibfk_1` FOREIGN KEY (`AddressCountry`) REFERENCES `Country` (`Id`),
     154ADD CONSTRAINT `Subject_ibfk_2` FOREIGN KEY (`MapPosition`) REFERENCES `MapPosition` (`Id`);");
     155    $this->Database->query("ALTER TABLE `Contact`
     156    ADD CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `ContactCategory` (`Id`),
     157    ADD CONSTRAINT `Contact_ibfk_2` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`),
     158    ADD CONSTRAINT `Contact_ibfk_3` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);");
     159  }
     160
     161  function DoUninstall()
     162  {
     163    $this->Database->query('DROP TABLE `Contact`');
     164    $this->Database->query('DROP TABLE `ContactCategory`');
     165    $this->Database->query('DROP TABLE `Subject`');
     166  }
    118167}
Note: See TracChangeset for help on using the changeset viewer.