r8607@llin: dpavlin | 2005-10-16 13:14:00 +0200
[BackupPC.git] / bin / BackupPC_updatedb
index 125b6f5..03c837d 100755 (executable)
@@ -143,7 +143,7 @@ sub hest_update {
 
                my $where = '';
                my @data;
-               if ($host_id && $share_id && $num) {
+               if (defined($host_id) && defined($share_id) && defined($num)) {
                        $where = qq{
                        WHERE
                                hosts.id = ? AND
@@ -278,34 +278,28 @@ if ($opt{c}) {
        }
 
        print "creating tables...\n";
-      
-       $dbh->do(qq{
+
+       $dbh->do( qq{
                create table hosts (
                        ID      SERIAL          PRIMARY KEY,
                        name    VARCHAR(30)     NOT NULL,
                        IP      VARCHAR(15)
                );            
-       });
-             
-       $dbh->do(qq{
+
                create table shares (
                        ID      SERIAL          PRIMARY KEY,
                        hostID  INTEGER         NOT NULL references hosts(id),
                        name    VARCHAR(30)     NOT NULL,
                        share   VARCHAR(200)    NOT NULL
                );            
-       });
 
-       $dbh->do(qq{
                create table dvds (
                        ID      SERIAL          PRIMARY KEY, 
                        num     INTEGER         NOT NULL,
                        name    VARCHAR(255)    NOT NULL,
                        mjesto  VARCHAR(255)
                );
-       });
-       
-       $dbh->do(qq{
+
                create table backups (
                        id      serial,
                        hostID  INTEGER         NOT NULL references hosts(id),
@@ -316,11 +310,10 @@ if ($opt{c}) {
                        size    bigint          not null,
                        inc_size bigint         not null default -1,
                        inc_deleted boolean     default false,
+                       parts   integer         not null default 1,
                        PRIMARY KEY(id)
                );            
-       });
 
-       $dbh->do(qq{     
                create table files (
                        ID              SERIAL,
                        shareID         INTEGER NOT NULL references shares(id),
@@ -332,10 +325,7 @@ if ($opt{c}) {
                        size            bigint  NOT NULL,
                        primary key(id)
                );
-       });
 
-
-       $dbh->do( qq{
                create table archive (
                        id              serial,
                        dvd_nr          int not null,
@@ -345,16 +335,21 @@ if ($opt{c}) {
                        date            timestamp default now(),
                        primary key(id)
                );      
-       }
-       );
 
-       $dbh->do( qq{
-               create table archive_backup
-               (
+               create table archive_backup (
                        archive_id      int not null references archive(id) on delete cascade,
                        backup_id       int not null references backups(id),
                        primary key(archive_id, backup_id)
                );
+
+               create table archive_burned (
+                       archive_id      int references archive(id),
+                       date            timestamp default now(),
+                       part            int not null default 1,
+                       copy            int not null default 1,
+                       iso_size bigint default -1
+               );
+
        });
 
        print "creating indexes: ";
@@ -372,6 +367,7 @@ if ($opt{c}) {
                files:date
                files:size
                archive:dvd_nr
+               archive_burned:archive_id
        )) {
                do_index($index);
        }