Ignore:
Timestamp:
Dec 24, 2015, 12:46:37 AM (9 years ago)
Author:
chronos
Message:
  • Added: Some VPS related tables.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Updates.php

    r769 r770  
    16731673  $Manager->Execute('ALTER TABLE `NetworkDomainView`
    16741674  ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomainView`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     1675}
     1676
     1677function UpdateTo770($Manager)
     1678{
     1679  $Manager->Execute("CREATE TABLE IF NOT EXISTS `OS` (
     1680      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1681      `Name` varchar(255) NOT NULL,
     1682      `Subject` int(11) DEFAULT NULL,
     1683      `Web` varchar(255) NOT NULL,
     1684      PRIMARY KEY (`Id`),
     1685      KEY `Subject` (`Subject`)
     1686  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1687
     1688  $Manager->Execute("INSERT INTO `OS` (`Id`, `Name`, `Subject`, `Web`) VALUES
     1689  (3, 'Ubuntu', NULL, 'http://www.ubuntu.com/'),
     1690  (4, 'Fedora', NULL, 'https://getfedora.org/'),
     1691  (5, 'OpenSUSE', NULL, 'https://www.opensuse.org/'),
     1692  (6, 'Arch Linux', NULL, 'https://www.archlinux.org/'),
     1693  (7, 'Debian', NULL, 'https://www.debian.org/');");
     1694
     1695  $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSArchitecture` (
     1696      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1697      `Name` varchar(255) NOT NULL,
     1698      PRIMARY KEY (`Id`)
     1699  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1700
     1701  $Manager->Execute("INSERT INTO `OSArchitecture` (`Id`, `Name`) VALUES
     1702  (1, 'i386'),
     1703  (2, 'x86_64,amd64');");
     1704
     1705  $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSTemplate` (
     1706      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1707      `Name` varchar(255) NOT NULL,
     1708      `Type` int(11) NOT NULL,
     1709      `Size` bigint(11) NOT NULL,
     1710      `OSVersion` int(11) NOT NULL,
     1711      `Public` int(11) NOT NULL,
     1712      `Architecture` int(11) NOT NULL,
     1713      PRIMARY KEY (`Id`),
     1714      KEY `OSVersion` (`OSVersion`),
     1715      KEY `Architecture` (`Architecture`),
     1716      KEY `Type` (`Type`)
     1717  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1718
     1719  $Manager->Execute("INSERT INTO `OSTemplate` (`Id`, `Name`, `Type`, `Size`, `OSVersion`, `Public`, `Architecture`) VALUES
     1720  (2, 'Ubuntu 15.10 i386', 1, 200000000, 1, 1, 1);");
     1721
     1722  $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSVersion` (
     1723      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1724      `Name` varchar(255) NOT NULL,
     1725      `OS` int(11) NOT NULL,
     1726      `Version` varchar(255) NOT NULL,
     1727      `ReleaseDate` date NOT NULL,
     1728      `CodeName` varchar(255) NOT NULL,
     1729      `EndOfLife` date DEFAULT NULL,
     1730      PRIMARY KEY (`Id`),
     1731      KEY `OS` (`OS`)
     1732  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1733
     1734  $Manager->Execute("INSERT INTO `OSVersion` (`Id`, `Name`, `OS`, `Version`, `ReleaseDate`, `CodeName`, `EndOfLife`) VALUES
     1735  (1, 'Ubuntu 15.10', 3, '15.10', '2015-10-23', 'Wily Werewolf', NULL),
     1736  (2, 'Ubuntu 14.04', 3, '14.04', '2014-04-17', 'Trusty Tahr', NULL);");
     1737
     1738  $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSVirtType` (
     1739      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1740      `Name` varchar(255) NOT NULL,
     1741      PRIMARY KEY (`Id`)
     1742  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1743
     1744  $Manager->Execute("INSERT INTO `OSVirtType` (`Id`, `Name`) VALUES
     1745  (1, 'LXC'),
     1746  (2, 'OpenVZ'),
     1747  (3, 'KVM'),
     1748  (4, 'Xen'),
     1749  (5, 'Hardware');");
     1750
     1751  $Manager->Execute("CREATE TABLE IF NOT EXISTS `VPS` (
     1752      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1753      `Name` varchar(255) NOT NULL,
     1754      `NetworkDevice` int(11) NOT NULL,
     1755      `OSTemplate` int(11) NOT NULL,
     1756      `Limits` int(11) NOT NULL,
     1757      `AutoStart` int(11) NOT NULL,
     1758      PRIMARY KEY (`Id`),
     1759      KEY `NetworkDevice` (`NetworkDevice`),
     1760      KEY `OSTemplate` (`OSTemplate`),
     1761      KEY `Limit` (`Limits`)
     1762  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1763
     1764  $Manager->Execute("CREATE TABLE IF NOT EXISTS `VPSLimit` (
     1765      `Id` int(11) NOT NULL AUTO_INCREMENT,
     1766      `Name` varchar(255) NOT NULL,
     1767      `Memory` bigint(11) NOT NULL,
     1768      `Storage` bigint(11) NOT NULL,
     1769      `NetworkDown` int(11) NOT NULL,
     1770      `NetworkUp` int(11) NOT NULL,
     1771      `CPUSockets` int(11) NOT NULL,
     1772      PRIMARY KEY (`Id`)
     1773  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     1774
     1775  $Manager->Execute("ALTER TABLE `OS`
     1776  ADD CONSTRAINT `OS_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);");
     1777
     1778  $Manager->Execute("ALTER TABLE `OSTemplate`
     1779  ADD CONSTRAINT `OSTemplate_ibfk_1` FOREIGN KEY (`OSVersion`) REFERENCES `OSVersion` (`Id`),
     1780  ADD CONSTRAINT `OSTemplate_ibfk_2` FOREIGN KEY (`Architecture`) REFERENCES `OSArchitecture` (`Id`),
     1781  ADD CONSTRAINT `OSTemplate_ibfk_3` FOREIGN KEY (`Type`) REFERENCES `OSVirtType` (`Id`);");
     1782
     1783  $Manager->Execute("ALTER TABLE `OSVersion`
     1784  ADD CONSTRAINT `OSVersion_ibfk_1` FOREIGN KEY (`OS`) REFERENCES `OS` (`Id`);");
     1785
     1786  $Manager->Execute("ALTER TABLE `VPS`
     1787  ADD CONSTRAINT `VPS_ibfk_1` FOREIGN KEY (`NetworkDevice`) REFERENCES `NetworkDevice` (`Id`),
     1788  ADD CONSTRAINT `VPS_ibfk_2` FOREIGN KEY (`OSTemplate`) REFERENCES `OSTemplate` (`Id`),
     1789  ADD CONSTRAINT `VPS_ibfk_3` FOREIGN KEY (`Limits`) REFERENCES `VPSLimit` (`Id`);");
    16751790}
    16761791
     
    17541869      763 => array('Revision' => 765, 'Function' => 'UpdateTo765'),
    17551870      765 => array('Revision' => 768, 'Function' => 'UpdateTo768'),
     1871      768 => array('Revision' => 770, 'Function' => 'UpdateTo770'),
    17561872    ));
    17571873  }
Note: See TracChangeset for help on using the changeset viewer.