$should_update_db = 1 if $db_mtime < $archive_mtime;
}
- unlink $db_file if -e $db_file and $should_update_db;
-
$self->schema( BackPAN::Index::Schema->connect("dbi:SQLite:dbname=$db_file") );
return unless $should_update_db;
$self->_setup_database;
- $should_update_db = 1 if $self->_database_is_empty;
-
- return unless $should_update_db;
-
my $dbh = $self->_dbh;
$self->_log("Populating database...");
)
SQL
);
+ my %delete_for = (
+ files => 'DELETE FROM files',
+ releases => 'DELETE FROM releases',
+ dists => 'DELETE FROM dists',
+ );
my $dbh = $self->_dbh;
- for my $sql (values %create_for) {
- $dbh->do($sql);
+ for my $table_name (keys %create_for) {
+ $dbh->do($create_for{$table_name});
+ $dbh->do($delete_for{$table_name});
}
$self->schema->rescan;