r8205@llin: dpavlin | 2005-09-23 10:52:33 +0200
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 23 Sep 2005 08:54:10 +0000 (08:54 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 23 Sep 2005 08:54:10 +0000 (08:54 +0000)
 fix partial import (using "part")

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@130 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb

index f0e9573..f2a825e 100755 (executable)
@@ -116,15 +116,15 @@ sub hest_update {
        my $offset = 0;
        my $added = 0;
 
-       print " opening index";
+       print " opening index $use_hest";
        if ($index_path) {
                $hest_db = HyperEstraier::Database->new();
                $hest_db->open($TopDir . $index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);
-               print "$index_path directly";
+               print " directly";
        } elsif ($index_node_url) {
                $hest_node ||= HyperEstraier::Node->new($index_node_url);
                $hest_node->set_auth('admin', 'admin');
-               print "$index_node_url via node URL";
+               print " via node URL";
        } else {
                die "don't know how to use HyperEstraier Index $use_hest";
        }
@@ -285,6 +285,15 @@ if ($opt{c}) {
                        localpath VARCHAR(200)      
                );            
        });
+
+       $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 (
@@ -300,14 +309,6 @@ if ($opt{c}) {
 
        #do_index('backups_hostid,num_unique');
 
-       $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 files (
@@ -318,11 +319,104 @@ if ($opt{c}) {
                        path       VARCHAR(255) NOT NULL,
                        date       integer      NOT NULL,
                        type       INTEGER      NOT NULL,
-                       size       INTEGER      NOT NULL,
-                       dvdid      INTEGER      references dvds(id)     
+                       size       INTEGER      NOT NULL
                );
        });
 
+
+       $dbh->do( qq{
+               create table archive
+               (
+                       id                      int not null,
+                       dvd_nr          int not null,
+                       note            text,
+                       username        varchar(20) not null,
+                       date            timestamp,
+                       primary key(id)
+               );      
+       }
+       );
+
+       $dbh->do( qq{
+               create table archive_backup
+               (
+                       archive_id      int not null,
+                       backup_id       int not null,
+                       status          text,
+                       primary key(archive_id, backup_id)
+               );
+       });
+
+       $dbh->do( qq{
+               create table workflows(
+                       id                      int not null,
+                       step_id         int not null,
+                       start           timestamp,
+                       stop            timestamp,
+                       username        varchar(20),
+                       archive_id      int not null,
+                       running         boolean default true,
+                       primary key(id)
+               );
+       });
+
+       $dbh->do( qq{
+               create table workflow_step
+               (
+                       step_id         int not null,
+                       code            text,
+                       next_step       int,
+                       stop            boolean default false,
+                       primary key(step_id)
+               );
+       });
+
+       $dbh->do( qq{
+                       alter table workflow_step
+                               add constraint fk_workflow_next_step
+                               foreign key(next_step)
+                               references workflow_step(step_id);
+       });
+
+       $dbh->do( qq{
+               alter table workflows
+                       add constraint fk_workflows_step_id
+                       foreign key(step_id)
+                       references workflow_step(step_id);
+       });
+       
+       $dbh->do( qq{
+               alter table workflows
+                       add constraint fk_workflows_archive_id
+                       foreign key(archive_id)
+                       references archive(id); 
+       });
+
+       $dbh->do( qq{
+               create table workflow_log
+               (
+                       workflow_id             int not null,
+                       step_id                 int not null,
+                       date                    timestamp not null,
+                       status                  text,
+                       primary key(workflow_id, step_id)
+               );
+       });
+
+       $dbh->do( qq{
+               alter table workflow_log
+                       add constraint fk_workflow_log_workflow_id
+                       foreign key (workflow_id)
+                       references workflows(id);
+               });
+       
+       $dbh->do( qq{
+               alter table workflow_log
+                       add constraint fk_workflow_log_step_id
+                       foreign key (step_id)
+                       references      workflow_step(step_id);
+               });
+
        print "creating indexes:";
 
        foreach my $index (qw(
@@ -455,7 +549,7 @@ foreach my $host_key (keys %{$hosts}) {
                                $hostID,
                                $backupNum,
                                $backup->{'endTime'},
-                               $backup->{'type'},
+                               substr($backup->{'type'},0,4),
                                $shareID,
                                $size,
                        );