/[BackupPC]/trunk/bin/BackupPC_updatedb
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_updatedb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 152 by dpavlin, Mon Oct 10 11:43:08 2005 UTC revision 199 by dpavlin, Thu Oct 13 21:19:06 2005 UTC
# Line 143  sub hest_update { Line 143  sub hest_update {
143    
144                  my $where = '';                  my $where = '';
145                  my @data;                  my @data;
146                  if ($host_id && $share_id && $num) {                  if (defined($host_id) && defined($share_id) && defined($num)) {
147                          $where = qq{                          $where = qq{
148                          WHERE                          WHERE
149                                  hosts.id = ? AND                                  hosts.id = ? AND
# Line 278  if ($opt{c}) { Line 278  if ($opt{c}) {
278          }          }
279    
280          print "creating tables...\n";          print "creating tables...\n";
281          
282          $dbh->do(qq{          $dbh->do( qq{
283                  create table hosts (                  create table hosts (
284                          ID      SERIAL          PRIMARY KEY,                          ID      SERIAL          PRIMARY KEY,
285                          name    VARCHAR(30)     NOT NULL,                          name    VARCHAR(30)     NOT NULL,
286                          IP      VARCHAR(15)                          IP      VARCHAR(15)
287                  );                              );            
288          });  
                 
         $dbh->do(qq{  
289                  create table shares (                  create table shares (
290                          ID      SERIAL          PRIMARY KEY,                          ID      SERIAL          PRIMARY KEY,
291                          hostID  INTEGER         NOT NULL references hosts(id),                          hostID  INTEGER         NOT NULL references hosts(id),
292                          name    VARCHAR(30)     NOT NULL,                          name    VARCHAR(30)     NOT NULL,
293                          share   VARCHAR(200)    NOT NULL                          share   VARCHAR(200)    NOT NULL
294                  );                              );            
         });  
295    
         $dbh->do(qq{  
296                  create table dvds (                  create table dvds (
297                          ID      SERIAL          PRIMARY KEY,                          ID      SERIAL          PRIMARY KEY,
298                          num     INTEGER         NOT NULL,                          num     INTEGER         NOT NULL,
299                          name    VARCHAR(255)    NOT NULL,                          name    VARCHAR(255)    NOT NULL,
300                          mjesto  VARCHAR(255)                          mjesto  VARCHAR(255)
301                  );                  );
302          });  
           
         $dbh->do(qq{  
303                  create table backups (                  create table backups (
304                          id      serial,                          id      serial,
305                          hostID  INTEGER         NOT NULL references hosts(id),                          hostID  INTEGER         NOT NULL references hosts(id),
# Line 316  if ($opt{c}) { Line 310  if ($opt{c}) {
310                          size    bigint          not null,                          size    bigint          not null,
311                          inc_size bigint         not null default -1,                          inc_size bigint         not null default -1,
312                          inc_deleted boolean     default false,                          inc_deleted boolean     default false,
313                            parts   integer         not null default 1,
314                          PRIMARY KEY(id)                          PRIMARY KEY(id)
315                  );                              );            
         });  
316    
         $dbh->do(qq{      
317                  create table files (                  create table files (
318                          ID              SERIAL,                          ID              SERIAL,
319                          shareID         INTEGER NOT NULL references shares(id),                          shareID         INTEGER NOT NULL references shares(id),
# Line 332  if ($opt{c}) { Line 325  if ($opt{c}) {
325                          size            bigint  NOT NULL,                          size            bigint  NOT NULL,
326                          primary key(id)                          primary key(id)
327                  );                  );
         });  
328    
   
         $dbh->do( qq{  
329                  create table archive (                  create table archive (
330                          id              serial,                          id              serial,
331                          dvd_nr          int not null,                          dvd_nr          int not null,
# Line 345  if ($opt{c}) { Line 335  if ($opt{c}) {
335                          date            timestamp default now(),                          date            timestamp default now(),
336                          primary key(id)                          primary key(id)
337                  );                        );      
         }  
         );  
338    
339          $dbh->do( qq{                  create table archive_backup (
340                  create table archive_backup                          archive_id      int not null references archive(id) on delete cascade,
                 (  
                         archive_id      int not null references archive(id),  
341                          backup_id       int not null references backups(id),                          backup_id       int not null references backups(id),
342                          primary key(archive_id, backup_id)                          primary key(archive_id, backup_id)
343                  );                  );
344    
345                    create table archive_burned (
346                            archive_id      int references archive(id),
347                            date            date default now(),
348                            part            int not null default 1,
349                            iso_size bigint default -1
350                    );
351    
352          });          });
353    
354          print "creating indexes:";          print "creating indexes: ";
355    
356          foreach my $index (qw(          foreach my $index (qw(
357                  hosts:name                  hosts:name
# Line 372  if ($opt{c}) { Line 366  if ($opt{c}) {
366                  files:date                  files:date
367                  files:size                  files:size
368                  archive:dvd_nr                  archive:dvd_nr
369                    archive_burned:archive_id
370          )) {          )) {
371                  do_index($index);                  do_index($index);
372          }          }
373    
374            print " creating sequence: ";
375            foreach my $seq (qw/dvd_nr/) {
376                    print "$seq ";
377                    $dbh->do( qq{ CREATE SEQUENCE $seq } );
378            }
379    
380    
381          print "...\n";          print "...\n";
382    
383          $dbh->commit;          $dbh->commit;

Legend:
Removed from v.152  
changed lines
  Added in v.199

  ViewVC Help
Powered by ViewVC 1.1.26