[vhffs-dev] [482] renamed vhffs_dns_global to vhffs_dns, merged vhffs_dns_soa to vhffs_dns, created a view vhffs_dns_soa, deleted a lot of redontants fields

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 482
Author:   gradator
Date:     2007-02-18 21:42:15 +0000 (Sun, 18 Feb 2007)

Log Message:
-----------
renamed vhffs_dns_global to vhffs_dns, merged vhffs_dns_soa to vhffs_dns, created a view vhffs_dns_soa, deleted a lot of redontants fields

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/DNS.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Stats.pm
    branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql
    branches/vhffs_4.1/vhffs-compat/4.0.sql
    branches/vhffs_4.1/vhffs-robots/src/create_dns.pl


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm	2007-02-18 21:42:15 UTC (rev 482)
@@ -7,7 +7,7 @@
 
 use constant
 {
-    VHFFS_VERSION => '4.1-alpha (Revision: 443)',
+    VHFFS_VERSION => '4.1-alpha (Revision: 481)',
     VHFFS_RELEASE_NAME => "hippocampus",
     
     WAITING_FOR_VALIDATION => 1,

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2007-02-18 21:42:15 UTC (rev 482)
@@ -398,7 +398,7 @@
 
 	if( $config->use_dns == 1 )
 	{
-		$query ='SELECT COUNT(*) FROM vhffs_dns_global WHERE owner_gid=';
+		$query ='SELECT COUNT(*) FROM vhffs_dns WHERE owner_gid=';
 	    $request = $self->{'db'}->prepare( $query );
 	    $request->execute( $self->get_gid );
         ($rows) = $request->fetchrow();

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/DNS.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/DNS.pm	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/DNS.pm	2007-02-18 21:42:15 UTC (rev 482)
@@ -51,7 +51,7 @@
 {
     my( $main , $query , $request);
     $main = shift;
-    $query = "SELECT n.domain , o.description ,  u.username , g.groupname , o.object_id FROM vhffs_dns_global n, vhffs_object o , vhffs_users u , vhffs_groups g  WHERE u.uid=n.owner_uid AND g.gid=n.owner_gid AND n.object_id=o.object_id AND o.state='".Vhffs::Constants::WAITING_FOR_VALIDATION."'";
+    $query = "SELECT n.domain , o.description ,  u.username , g.groupname , o.object_id FROM vhffs_dns n, vhffs_object o , vhffs_users u , vhffs_groups g  WHERE u.uid=n.owner_uid AND g.gid=n.owner_gid AND n.object_id=o.object_id AND o.state='".Vhffs::Constants::WAITING_FOR_VALIDATION."'";
 	$request = $main->{'db'}->prepare( $query );
 
     return undef if ( $request->execute <= 0 );
@@ -69,11 +69,11 @@
 
     if( defined $name )
         {
-                $query = "SELECT ns.domain, ns.object_id, ns.owner_gid, o.state  FROM vhffs_dns_global ns, vhffs_object o WHERE o.object_id=ns.object_id AND ns.domain LIKE '".$name."'";
+                $query = "SELECT ns.domain, ns.object_id, ns.owner_gid, o.state  FROM vhffs_dns ns, vhffs_object o WHERE o.object_id=ns.object_id AND ns.domain LIKE '".$name."'";
         }
         else
         {
-                $query = "SELECT ns.domain, ns.object_id, ns.owner_gid, o.state  FROM vhffs_dns_global ns, vhffs_object o WHERE o.object_id=ns.object_id";
+                $query = "SELECT ns.domain, ns.object_id, ns.owner_gid, o.state  FROM vhffs_dns ns, vhffs_object o WHERE o.object_id=ns.object_id";
         }
         my $request = $main->{'db'}->prepare( $query ) or return -1;
 
@@ -111,7 +111,7 @@
 
 	return undef if ( ! defined $user );
 
-	my $query = "SELECT ns.domain, ns.object_id FROM vhffs_dns_global ns, vhffs_acl acl ,vhffs_users WHERE vhffs_users.object_id=acl.oid_src AND acl.oid_dst=ns.object_id AND vhffs_users.username='".$user->{'username'}."'";
+	my $query = "SELECT ns.domain, ns.object_id FROM vhffs_dns ns, vhffs_acl acl ,vhffs_users WHERE vhffs_users.object_id=acl.oid_src AND acl.oid_dst=ns.object_id AND vhffs_users.username='".$user->{'username'}."'";
 
 	my $request = $main->{'db'}->prepare( $query ) or return -1;
 
@@ -127,7 +127,7 @@
 
 	return undef if ( $group->fetch < 0 );
 
-	my $query = "SELECT ns.domain, ns.object_id , o.object_id, o.state  FROM vhffs_dns_global ns , vhffs_object o WHERE o.object_id=ns.object_id AND ns.owner_gid='".$group->get_gid."'";
+	my $query = "SELECT ns.domain, ns.object_id , o.object_id, o.state  FROM vhffs_dns ns , vhffs_object o WHERE o.object_id=ns.object_id AND ns.owner_gid='".$group->get_gid."'";
 	my $request = $main->{'db'}->prepare( $query ) or return -1;
 
 	return undef if ( $request->execute() <= 0);

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm	2007-02-18 21:42:15 UTC (rev 482)
@@ -92,7 +92,7 @@
     my $result;
     my $tmp;
 
-	$query = "SELECT n.domain, n.object_id FROM  vhffs_dns_global n, vhffs_object o WHERE n.object_id = o.object_id";
+	$query = "SELECT n.domain, n.object_id FROM  vhffs_dns n, vhffs_object o WHERE n.object_id = o.object_id";
     $query.= " AND o.state='".$state."'" if( defined $state );
     $query.= " AND n.domain LIKE '%".$name."%'" if( defined $name );
     $query.= " AND n.owner_gid='".$group->get_gid."'" if( defined $group );
@@ -126,7 +126,7 @@
     
 
     #Check if the DNS object already exists
-    my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_global WHERE domain='" . $self->{'domain'} . "'");
+    my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns WHERE domain='" . $self->{'domain'} . "'");
     my $rows = $request->execute;
     return -1 if ( $rows != 0 );
     
@@ -140,19 +140,16 @@
 
     #Get the max dns_id and compute the new dns_id
     my $dns_id = 1;
-    $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_global where domain='".$self->{'domain'}."'") or return -1;
-    my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(dns_id) FROM vhffs_dns_global");
+    $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns where domain='".$self->{'domain'}."'") or return -1;
+    my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(dns_id) FROM vhffs_dns");
     $dns_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
     $dns_id++;
     $self->{'dns_id'} = $dns_id;
     
-
-    
     #Finally, create the object
-    my $text = "INSERT INTO vhffs_dns_global VALUES( '".$dns_id."' , '".$self->{'domain'}."', '".$self->{'group'}->get_gid."' , '".$self->{'user'}->get_uid."' , '".$oid."' )";
+    my $text = "INSERT INTO vhffs_dns VALUES( '".$dns_id."' , '".$self->{'domain'}."', '".$self->{'group'}->get_gid."' , '".$self->{'user'}->get_uid."' , '".$oid."' , '".$conf->{default_ns1}."' , '".$conf->{default_mbox}."' , '".$conf->{default_serial}."' , '".$conf->{default_refresh}."' , '".$conf->{default_retry}."' , '".$conf->{default_expire}."' , '".$conf->{default_minimum}."' )";
     $request = $self->{'db'}->prepare( $text );
     $request->execute or return -2;
-    $self->{SOA}->{origin} = $self->{domain} . ".";
     $self->commit;
     
     
@@ -216,20 +213,13 @@
     
     return -1 if( $self->fetch < 0);
     
-    # Destroy the SOA part
-    $query = "DELETE FROM vhffs_dns_soa WHERE id='".$self->{'dns_id'}."'";
-    $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
-
-
     # Destroy the RR part (A, NS, PTR, ...)
     $query = "DELETE FROM vhffs_dns_rr WHERE zone='".$self->{'dns_id'}."'";
     $request = $self->{'db'}->prepare($query);
     $request->execute or return -1;
-    
 
     # Destroy the main part of the DNS
-    $query = "DELETE FROM vhffs_dns_global WHERE dns_id='".$self->{'dns_id'}."'";
+    $query = "DELETE FROM vhffs_dns WHERE dns_id='".$self->{'dns_id'}."'";
     $request = $self->{'db'}->prepare($query);
     $request->execute or return -1;
     
@@ -249,7 +239,7 @@
     
     
     #First, get informations in the dns database, in dns_global
-    my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_global where domain='".$self->{'domain'}."'") or return -1;
+    my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns where domain='".$self->{'domain'}."'") or return -1;
     my $rows = $request->execute() or return -3;
     return -1 if ( $rows == 0 );
     
@@ -261,17 +251,6 @@
 	$self->{$_} = $result->{$_}
     }
     
-    #Second, get the SOA part
-    $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_soa where id='".$self->{'dns_id'}."'");
-    $request->execute();
-    $result = $request->fetchrow_hashref();
-    
-    foreach ( keys %{$result} )
-    {
-	$self->{SOA}->{$_} = $result->{$_}
-    }
-    
-    
     #Get the A TYPE
     $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_rr where zone='".$self->{'dns_id'}."' AND type='A'") or return -1;
     $request->execute() or return -3;
@@ -671,16 +650,7 @@
     $request2->execute or return -2;
 }
 
-# Simply activate a domain. This is only an option for MyDNS
-sub activate
-{
-    my $self = shift;
-    $self->{SOA}->{'active'} = 1;
-}
 
-
-
-
 # Submit changes to the backend
 sub commit
 {
@@ -696,7 +666,6 @@
     return -1 if ( ! defined $self->{'dns_id'} );
 
     #Set some defaults values if not defined
-    $self->{SOA}->{'origin'} = $self->{'domain'} if( ! defined $self->{SOA}->{'origin'} );
     $self->{SOA}->{'ttl'} = $conf->{default_ttl} if( ! defined $self->{SOA}->{'ttl'} );
     $self->{SOA}->{'ns'} = $conf->{default_ns1} if( ! defined $self->{SOA}->{'ns'} );
     $self->{SOA}->{'mbox'} = $conf->{default_mbox} if( ! defined $self->{SOA}->{'mbox'} );
@@ -705,7 +674,6 @@
     $self->{SOA}->{'retry'} = $conf->{default_retry} if( ! defined $self->{SOA}->{'retry'} );
     $self->{SOA}->{'expire'} = $conf->{default_expire} if( ! defined $self->{SOA}->{'expire'} );
     $self->{SOA}->{'minimum'} = $conf->{default_minimum} if( ! defined $self->{SOA}->{'minimum'} );
-    $self->{SOA}->{'active'} = 0 if( ! defined $self->{SOA}->{'active'} );
 
 
     #Convert the mail to the mailbox domain for DNS files
@@ -725,17 +693,8 @@
 	}
     
     #First, commit the SOA
-    my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_soa WHERE id='" . $self->{'dns_id'} . "'");
-    my $rows = $request->execute;
-    if ( $rows != 0 )
-    {
-	$query = "UPDATE vhffs_dns_soa SET origin='".$self->{SOA}->{'origin'}."', ns='".$self->{SOA}->{'ns'}."', mbox='".$self->{SOA}->{'mbox'}."', serial='".$self->{SOA}->{'serial'}."', refresh='".$self->{SOA}->{'refresh'}."', retry='".$self->{SOA}->{'retry'}."', expire='".$self->{SOA}->{'expire'}."', minimum='".$self->{SOA}->{'minimum'}."', ttl='".$self->{SOA}->{'ttl'}."', active='".$self->{SOA}->{'active'}."' WHERE id=$self->{'dns_id'}";
-    }
-    else
-    {
-	$query = "INSERT INTO vhffs_dns_soa VALUES ( '$self->{dns_id}' , '$self->{SOA}->{origin}' , '$self->{SOA}->{ns}' , '$self->{SOA}->{mbox}' , '$self->{SOA}->{serial}' , '$self->{SOA}->{refresh}' ,  '$self->{SOA}->{retry}' ,  '$self->{SOA}->{expire}' ,  '$self->{SOA}->{minimum}' ,  '$self->{SOA}->{ttl}' ,  '$self->{SOA}->{active}' )"; 
-    }
-    $request = $self->{'db'}->prepare( $query );
+    $query = "UPDATE vhffs_dns SET ns='".$self->{SOA}->{'ns'}."', mbox='".$self->{SOA}->{'mbox'}."', serial='".$self->{SOA}->{'serial'}."', refresh='".$self->{SOA}->{'refresh'}."', retry='".$self->{SOA}->{'retry'}."', expire='".$self->{SOA}->{'expire'}."', minimum='".$self->{SOA}->{'minimum'}."', ttl='".$self->{SOA}->{'ttl'}."' WHERE dns_id=$self->{'dns_id'}";
+    my $request = $self->{'db'}->prepare( $query );
     $request->execute or return -2;
 
 
@@ -940,13 +899,6 @@
     $self->{SOA}->{'ttl'} = $value;
 }
 
-sub set_soa_active
-{
-    my $self  = shift;
-
-    $self->{SOA}->{'active'} = "Y";
-}
-
 sub set_user
 {
     my $self  = shift;

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Stats.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Stats.pm	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Stats.pm	2007-02-18 21:42:15 UTC (rev 482)
@@ -107,13 +107,13 @@
 
 
     ### DNS Stats
-    $query = 'SELECT COUNT(*) FROM vhffs_dns_global w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::ACTIVATED;
+    $query = 'SELECT COUNT(*) FROM vhffs_dns w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::ACTIVATED;
     ($self->{'dns'}{'activated'}) = @{$self->{'db'}->selectrow_arrayref( $query )};
 
-    $query = 'SELECT COUNT(*) FROM vhffs_dns_global w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::WAITING_FOR_VALIDATION;
+    $query = 'SELECT COUNT(*) FROM vhffs_dns w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::WAITING_FOR_VALIDATION;
     ($self->{'dns'}{'awaiting_validation'}) = @{$self->{'db'}->selectrow_arrayref( $query )};
     
-    $query = 'SELECT COUNT(*) FROM vhffs_dns_global w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::WAITING_FOR_CREATION;
+    $query = 'SELECT COUNT(*) FROM vhffs_dns w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::WAITING_FOR_CREATION;
     ($self->{'dns'}{'awaiting_creation'}) = @{$self->{'db'}->selectrow_arrayref( $query )};
 
 

Modified: branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql
===================================================================
--- branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql	2007-02-18 21:42:15 UTC (rev 482)
@@ -35,7 +35,7 @@
 	object_id serial,
 	owner_uid int4,
 	date_creation timestamp,
-	state varchar NOT NULL,
+	state int4 NOT NULL,
 	description TEXT,
 	type int4 DEFAULT 0,
 	CONSTRAINT vhffs_object_pkey PRIMARY KEY (object_id)
@@ -124,14 +124,22 @@
 	CONSTRAINT vhffs_cvs_pkey PRIMARY KEY (cvs_id)
 ) WITH OIDS;
 
-CREATE TABLE vhffs_dns_global
+CREATE TABLE vhffs_dns
 (
 	dns_id serial,
 	domain varchar(255) NOT NULL,
 	owner_gid int4,
 	owner_uid int4,
 	object_id int4,
-	CONSTRAINT vhffs_dns_pkey4 PRIMARY KEY ( dns_id )
+	ns varchar(255) NOT NULL,
+	mbox varchar(255) NOT NULL,
+	serial INTEGER NOT NULL DEFAULT 1,
+	refresh INTEGER NOT NULL DEFAULT 28800,
+	retry INTEGER NOT NULL DEFAULT 7200,
+	expire INTEGER NOT NULL DEFAULT 604800,
+	minimum INTEGER NOT NULL DEFAULT 86400,
+	ttl INTEGER NOT NULL DEFAULT 86400,
+	CONSTRAINT vhffs_dns_pkey4 PRIMARY KEY (id)
 ) WITH OIDS;
 
 CREATE TABLE vhffs_dns_rr (
@@ -145,22 +153,6 @@
 	CONSTRAINT vhffs_dns_rr_pkey PRIMARY KEY (id)
 ) WITH OIDS;	
 
-CREATE TABLE vhffs_dns_soa
-(
-	id serial,
-	origin varchar(255) NOT NULL,
-	ns varchar(255) NOT NULL,
-	mbox varchar(255) NOT NULL,
-	serial INTEGER NOT NULL DEFAULT 1,
-	refresh INTEGER NOT NULL DEFAULT 28800,
-	retry INTEGER NOT NULL DEFAULT 7200,
-	expire INTEGER NOT NULL DEFAULT 604800,
-	minimum INTEGER NOT NULL DEFAULT 86400,
-	ttl INTEGER NOT NULL DEFAULT 86400,
-	active INTEGER,
-	CONSTRAINT vhffs_dns_soa_pkey PRIMARY KEY (id)
-) WITH OIDS;
-
 CREATE TABLE vhffs_forward
 (
 	domain varchar NOT NULL,
@@ -335,11 +327,11 @@
 ALTER TABLE vhffs_cvs ADD CONSTRAINT fk_vhffs_cvs_vhffs_groups FOREIGN KEY (owner_gid) REFERENCES vhffs_groups(gid);
 ALTER TABLE vhffs_cvs ADD CONSTRAINT fk_vhffs_cvs_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
 
-ALTER TABLE vhffs_dns_global ADD CONSTRAINT fk_vhffs_dns_vhffs_users FOREIGN KEY (owner_uid) REFERENCES vhffs_users(uid);
-ALTER TABLE vhffs_dns_global ADD CONSTRAINT fk_vhffs_dns_vhffs_groups FOREIGN KEY (owner_gid) REFERENCES vhffs_groups(gid);
-ALTER TABLE vhffs_dns_global ADD CONSTRAINT fk_vhffs_dns_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
+ALTER TABLE vhffs_dns ADD CONSTRAINT fk_vhffs_dns_vhffs_users FOREIGN KEY (owner_uid) REFERENCES vhffs_users(uid);
+ALTER TABLE vhffs_dns ADD CONSTRAINT fk_vhffs_dns_vhffs_groups FOREIGN KEY (owner_gid) REFERENCES vhffs_groups(gid);
+ALTER TABLE vhffs_dns ADD CONSTRAINT fk_vhffs_dns_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
 
-ALTER TABLE vhffs_dns_rr ADD CONSTRAINT fk_vhffs_dns_rr_vhffs_dns FOREIGN KEY (zone) REFERENCES vhffs_dns_global(dns_id) ON DELETE CASCADE;
+ALTER TABLE vhffs_dns_rr ADD CONSTRAINT fk_vhffs_dns_rr_vhffs_dns FOREIGN KEY (zone) REFERENCES vhffs_dns(id) ON DELETE CASCADE;
 ALTER TABLE vhffs_dns_rr ADD CONSTRAINT fk_vhffs_dns_rr_chk_type CHECK (type='A' OR type='AAAA' OR type='CNAME' OR type='HINFO' OR type='MX' OR type='NS' OR type='PTR' OR type='RP' OR type='SRV' OR type='TXT');
 
 ALTER TABLE vhffs_httpd ADD CONSTRAINT fk_vhffs_httpd_vhffs_users FOREIGN KEY (owner_uid) REFERENCES vhffs_users(uid);
@@ -390,3 +382,7 @@
 SELECT users.username, users.passwd, users.firstname, users.lastname, users.mail, users.date_creation, object.state
 FROM vhffs_users users, vhffs_object object
 WHERE object.object_id=users.object_id;
+
+CREATE VIEW vhffs_dns_soa AS
+SELECT dns.dns_id AS id, dns.domain || '.' AS origin , dns.ns, dns.mbox, dns.serial, dns.refresh, dns.retry, dns.expire, dns.minimum, dns.ttl, (o.state = 6) AS active                     
+FROM vhffs_dns dns, vhffs_object o WHERE o.object_id=dns.object_id;

Modified: branches/vhffs_4.1/vhffs-compat/4.0.sql
===================================================================
--- branches/vhffs_4.1/vhffs-compat/4.0.sql	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-compat/4.0.sql	2007-02-18 21:42:15 UTC (rev 482)
@@ -125,8 +125,78 @@
 
 -- DROP TABLE vhffs_ml_lang;
 
+-- rename vhffs_dns_global to vhffs_dns
+ALTER TABLE vhffs_dns_global RENAME TO vhffs_dns;
+
+-- merge vhffs_dns_soa to vhffs_dns(ex vhffs_dns_global)
+ALTER TABLE vhffs_dns ADD COLUMN ns varchar(255);
+UPDATE vhffs_dns SET ns = soa.ns FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN ns SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN mbox varchar(255);
+UPDATE vhffs_dns SET mbox = soa.mbox FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN mbox SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN serial INTEGER;
+ALTER TABLE vhffs_dns ALTER COLUMN serial SET DEFAULT 1;
+UPDATE vhffs_dns SET serial = soa.serial FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN serial SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN refresh INTEGER;
+ALTER TABLE vhffs_dns ALTER COLUMN refresh SET DEFAULT 28800;
+UPDATE vhffs_dns SET refresh = soa.refresh FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN refresh SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN retry INTEGER;
+ALTER TABLE vhffs_dns ALTER COLUMN retry SET DEFAULT 7200;
+UPDATE vhffs_dns SET retry = soa.retry FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN retry SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN expire INTEGER;
+ALTER TABLE vhffs_dns ALTER COLUMN expire SET DEFAULT 604800;
+UPDATE vhffs_dns SET expire = soa.expire FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN expire SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN minimum INTEGER;
+ALTER TABLE vhffs_dns ALTER COLUMN minimum SET DEFAULT 86400;
+UPDATE vhffs_dns SET minimum = soa.minimum FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN minimum SET NOT NULL;
+
+ALTER TABLE vhffs_dns ADD COLUMN ttl INTEGER;
+ALTER TABLE vhffs_dns ALTER COLUMN ttl SET DEFAULT 86400;
+UPDATE vhffs_dns SET ttl = soa.ttl FROM vhffs_dns_soa soa WHERE soa.id = vhffs_dns.dns_id;
+ALTER TABLE vhffs_dns ALTER COLUMN ttl SET NOT NULL;
+
+-- DROP TABLE vhffs_dns_soa;
+
+-- change the type of vhffs_object.state from varchar to int4 ..... (no comments allowed please)
+BEGIN;
+DROP VIEW vhffs_forum;
+ALTER TABLE vhffs_object ADD COLUMN state_new int4;
+UPDATE vhffs_object SET state_new = '0';
+UPDATE vhffs_object SET state_new = '1' WHERE state='1';
+UPDATE vhffs_object SET state_new = '2' WHERE state='2';
+UPDATE vhffs_object SET state_new = '3' WHERE state='3';
+UPDATE vhffs_object SET state_new = '4' WHERE state='4';
+UPDATE vhffs_object SET state_new = '5' WHERE state='5';
+UPDATE vhffs_object SET state_new = '6' WHERE state='6';
+UPDATE vhffs_object SET state_new = '7' WHERE state='7';
+UPDATE vhffs_object SET state_new = '8' WHERE state='8';
+UPDATE vhffs_object SET state_new = '9' WHERE state='9';
+UPDATE vhffs_object SET state_new = '10' WHERE state='10';
+UPDATE vhffs_object SET state_new = '11' WHERE state='11';
+UPDATE vhffs_object SET state_new = '12' WHERE state='12';
+ALTER TABLE vhffs_object DROP COLUMN state;
+ALTER TABLE vhffs_object RENAME COLUMN state_new TO state;
+ALTER TABLE vhffs_object ALTER COLUMN state SET NOT NULL;
+COMMIT;
+
+-- create vhffs_dns_soa view
+CREATE VIEW vhffs_dns_soa AS
+SELECT dns.dns_id AS id, dns.domain || '.' AS origin , dns.ns, dns.mbox, dns.serial, dns.refresh, dns.retry, dns.expire, dns.minimum, dns.ttl, (o.state = 6) AS active
+FROM vhffs_dns dns, vhffs_object o WHERE o.object_id=dns.object_id;
+
 -- update vhffs_forum view
-DROP VIEW vhffs_forum;
 CREATE VIEW vhffs_forum AS
 SELECT users.username, users.passwd, users.firstname, users.lastname, users.mail, users.date_creation, object.state
 FROM vhffs_users users, vhffs_object object

Modified: branches/vhffs_4.1/vhffs-robots/src/create_dns.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/create_dns.pl	2007-02-18 19:33:30 UTC (rev 481)
+++ branches/vhffs_4.1/vhffs-robots/src/create_dns.pl	2007-02-18 21:42:15 UTC (rev 482)
@@ -54,7 +54,6 @@
 	foreach $dns ( @{$tocreate} )
 	{
         $dns->set_status( Vhffs::Constants::ACTIVATED );
-        $dns->activate;
         if( $dns->commit > 0 )
 		{
 			Vhffs::Robots::vhffs_log( sprintf( "Create domain %s" , $dns->get_domain  ) , $vhffs);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/