Alternc  latest
Alternc logiel libre pour l'hébergement
1.0.0.sql
Go to the documentation of this file.
1 --
2 -- Because of problems with people using AlternC pre1 ,
3 -- we include 0.9.10.sql in this file
4 
5 ALTER IGNORE TABLE `membres` ADD COLUMN `notes` TEXT NOT NULL AFTER `type`;
6 
7 CREATE TABLE IF NOT EXISTS `policy` (
8  `name` varchar(64) NOT NULL,
9  `minsize` tinyint(3) unsigned NOT NULL,
10  `maxsize` tinyint(3) unsigned NOT NULL,
11  `classcount` tinyint(3) unsigned NOT NULL,
12  `allowlogin` tinyint(3) unsigned NOT NULL,
13  PRIMARY KEY (`name`)
14 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='The password policies for services';
15 
16 
17 INSERT IGNORE INTO `variable` (`name` ,`value` ,`comment`)
18 VALUES (
19 'subadmin_restriction', '',
20 'This variable set the way the account list works for accounts other than "admin" (2000). 0 (default) = admin other than admin/2000 can see their own account, but not the other one 1 = admin other than admin/2000 can see any account by clicking the ''show all accounts'' link. '
21 );
22 
23 --
24 -- TABLES de mémorisation de la taille des dossiers db/listes
25 
26 CREATE TABLE IF NOT EXISTS `size_db` (
27  `db` varchar(255) NOT NULL default '',
28  `size` int(10) unsigned NOT NULL default '0',
29  `ts` timestamp(14) NOT NULL,
30  PRIMARY KEY (`db`),
31  KEY `ts` (`ts`)
32 ) TYPE=MyISAM COMMENT='MySQL Database used space';
33 
34 
35 CREATE TABLE IF NOT EXISTS `size_mailman` (
36  `list` varchar(255) NOT NULL default '',
37  `uid` int(11) NOT NULL default '0',
38  `size` int(10) unsigned NOT NULL default '0',
39  `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
40  PRIMARY KEY (`list`),
41  KEY `ts` (`ts`),
42  KEY `uid` (`uid`)
43 ) ENGINE=MyISAM COMMENT='Mailman Lists used space';
44 
45 -- IPv6 compatibility :
46 ALTER TABLE `slaveip` CHANGE `ip` `ip` VARCHAR(40);
47 ALTER TABLE `sessions` CHANGE `ip` `ip` VARCHAR( 40 ) NULL;
48 
49 -- type subdomain evolution
50 ALTER TABLE `sub_domaines` CHANGE `type` `type` VARCHAR(30);
51 ALTER TABLE `sub_domaines_standby` CHANGE `type` `type` VARCHAR(30);
52 
53 -- END OF 0.9.10.sql
54 
55 -- Alter table to allow use of ipv6, cname and txt in dns record
56 ALTER TABLE sub_domaines DROP PRIMARY KEY;
57 ALTER TABLE sub_domaines ADD CONSTRAINT pk_SubDomaines PRIMARY KEY (compte,domaine,sub,type,valeur);
58 
59 -- Alter table mail_domain to add support of temporary mail
60 ALTER TABLE mail_domain ADD expiration_date datetime DEFAULT null;
61 
62 -- Domains type
63 CREATE TABLE IF NOT EXISTS `domaines_type` (
64  `name` VARCHAR (255) NOT NULL, -- Uniq name
65  `description` TEXT, -- Human description
66  `target` enum ('NONE', 'URL', 'DIRECTORY', 'IP', 'IPV6', 'DOMAIN', 'TXT') NOT NULL DEFAULT 'NONE', -- Target type
67  `entry` VARCHAR (255) DEFAULT '', -- BIND entry
68  `compatibility` VARCHAR (255) DEFAULT '', -- Which type can be on the same subdomains
69  `enable` enum ('ALL', 'NONE', 'ADMIN') NOT NULL DEFAULT 'ALL', -- Show this option to who ?
70  `only_dns` BOOLEAN DEFAULT FALSE, -- Update_domains modify just the dns, no web configuration
71  `need_dns` BOOLEAN DEFAULT TRUE, -- The server need to be the DNS to allow this service
72  `advanced` BOOLEAN DEFAULT TRUE, -- It's an advanced option
73 PRIMARY KEY ( `name` )
74 ) COMMENT = 'Type of domains allowed';
75 
76 INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns, advanced, enable) values
77 ('vhost','Locally hosted', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt,defmx,defmx2,mx,mx2', false, false, false, 'ALL'),
78 ('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt,defmx,defmx2', true, false, false, 'ALL'),
79 ('ip','IPv4 redirect', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt,mx,mx2,defmx,defmx2', false, true, false, 'ALL'),
80 ('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false, 'ALL'),
81 ('ipv6','IPv6 redirect', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt,mx,mx2,defmx,defmx2',true, true, true , 'ALL'),
82 ('cname', 'CNAME DNS entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt,mx,mx2,defmx,defmx2',true, true, true , 'ALL'),
83 ('txt', 'TXT DNS entry', 'TXT', '%SUB% IN TXT "%TARGET%"','vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2,defmx,defmx2',true, true, true, 'ALL'),
84 ('mx', 'MX DNS entry', 'DOMAIN', '%SUB% IN MX 5 %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL'),
85 ('mx2', 'secondary MX DNS entry', 'DOMAIN', '%SUB% IN MX 10 %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL'),
86 ('defmx', 'Default mail server', 'NONE', '%SUB% IN MX 5 @@DEFAULT_MX@@.', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx2',true, false, true, 'ADMIN'),
87 ('defmx2', 'Default backup mail server', 'NONE', '%SUB% IN MX 10 @@DEFAULT_SECONDARY_MX@@.', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx',true, false, true, 'ADMIN'),
88 ('panel', 'AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2,defmx,defmx2',true, false, true, 'ALL')
89 ;
90 
91 -- Changing standby use
92 ALTER TABLE domaines ADD COLUMN dns_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE';
93 ALTER TABLE domaines ADD COLUMN dns_result varchar(255) not null default '';
94 ALTER TABLE sub_domaines ADD COLUMN web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE';
95 ALTER TABLE sub_domaines ADD COLUMN web_result varchar(255) not null default '';
96 ALTER TABLE sub_domaines ADD COLUMN enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED';
97 DROP TABLE sub_domaines_standby;
98 DROP TABLE domaines_standby;
99 
100 UPDATE sub_domaines SET type='VHOST' WHERE type='0'; -- We decide to drop massvhost.
101 UPDATE sub_domaines SET type='URL' WHERE type='1';
102 UPDATE sub_domaines SET type='IP' WHERE type='2';
103 UPDATE sub_domaines SET type='WEBMAIL' WHERE type='3';
104 UPDATE sub_domaines SET type='IPV6' WHERE type='4';
105 UPDATE sub_domaines SET type='CNAME' WHERE type='5';
106 UPDATE sub_domaines SET type='TXT' WHERE type='6';
107 UPDATE sub_domaines SET web_action='UPDATE';
108 
109 -- not needed : it's now a subdomain with defmx and/or defmx2 type (this type is admin-only) :
110 -- ALTER TABLE `domaines` DROP `mx` ;
111 -- BUT we will remove it in a distant future version : we need it for the migration to take place fluently ...
112