3 # create_cdimage_table.pl
4 # create the bacula table for CD image management
6 # Copyright (C) 2004 Kern Sibbald
8 # Thu Dec 09 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
9 # ASSIGNMENT OF COPYRIGHT
10 # FOR VALUE RECEIVED, D. Scott Barninger hereby sells, transfers and
11 # assigns unto Kern Sibbald, his successors, assigns and personal representatives,
12 # all right, title and interest in and to the copyright in this software.
13 # D. Scott Barninger warrants good title to said copyright, that it is
14 # free of all liens, encumbrances or any known claims against said copyright.
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public
18 # License version 2 as published by the Free Software Foundation.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 # General Public License for more details.
25 # You should have received a copy of the GNU General Public
26 # License along with this program; if not, write to the Free
27 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 require 5.000; use strict 'vars', 'refs', 'subs';
36 #------------------------------------------------------------------------------------
37 # configuration section
38 my($dbh,$sql,$database,$host,$user,$password,$db_driver,$db_name_param);
43 ## database driver selection - uncomment one set
46 $db_name_param = "database";
49 # $db_name_param = "dbname";
51 # end configuration section
52 #------------------------------------------------------------------------------------
54 # connect to the database
55 $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password",{'RaiseError' => 1}) || die("Unable to connect to database.");
57 if ($db_driver eq "mysql") {
58 $sql = "CREATE TABLE CDImages (
59 MediaId INTEGER UNSIGNED NOT NULL,
60 LastBurn DATETIME NOT NULL,
61 PRIMARY KEY (MediaId))";
64 if ($db_driver eq "Pg") {
65 $sql = "CREATE TABLE CDImages (
66 MediaId integer not null,
67 LastBurn timestamp without time zone not null,
68 primary key (MediaId))";
74 print "\nFinished creating the CDImages table.\n";
77 #-------------------------------------------------------------------#
81 # first functional version
84 # add configuration option for Postgresql driver