From: Kern Sibbald Date: Sat, 17 Apr 2010 12:02:20 +0000 (+0200) Subject: Fix badly named index X-Git-Tag: Release-5.2.1~1466 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=81c8389ff06aae8ef157b6a842176d8111c61e55;p=bacula%2Fbacula Fix badly named index --- diff --git a/bacula/src/cats/make_ingres_tables.in b/bacula/src/cats/make_ingres_tables.in index 3a3dcb6410..132629ae59 100755 --- a/bacula/src/cats/make_ingres_tables.in +++ b/bacula/src/cats/make_ingres_tables.in @@ -9,431 +9,427 @@ db_user=${db_user:-@db_user@} sql -u${db_user} $* ${db_name} <.dbms.private.*.cache.p8k_status: ON --- ii..dbms.private.*.cache.p16k_status: ON --- ii..dbms.private.*.cache.p32k_status: ON --- ii..dbms.private.*.cache.p64k_status: ON --- ii..rcp.dmf_cache_size8k: 200 --- ii..rcp.dmf_cache_size16k: 200 --- ii..rcp.dmf_cache_size32k: 200 --- ii..rcp.dmf_cache_size64k: 200 --- - SET AUTOCOMMIT ON\g -CREATE SEQUENCE Filename_Seq; -CREATE TABLE Filename +CREATE SEQUENCE filename_seq; +CREATE TABLE filename ( - FilenameId INTEGER NOT NULL DEFAULT Filename_Seq.nextval, - Name VARBYTE(32000) NOT NULL, - PRIMARY KEY (FilenameId) + filenameid integer not null default filename_seq.nextval, + name varchar(256) not null, + primary key (filenameid) ); -CREATE UNIQUE INDEX (filename_name_idx ON filename (Name) WITH STRUCTURE=HASH,PAGE_SIZE=32768); +-- ALTER TABLE filename ALTER COLUMN name SET STATISTICS 1000; +CREATE UNIQUE INDEX filename_name_idx on filename (name); -CREATE SEQUENCE Path_Seq; +CREATE SEQUENCE path_seq; CREATE TABLE path ( - Pathid INTEGER NOT NULL DEFAULT Path_Seq.nextval, - Path VARBYTE(32000) NOT NULL, - PRIMARY KEY (Pathid) + pathid integer not null default path_seq.nextval, + path varchar(256) not null, + primary key (pathid) ); -CREATE UNIQUE INDEX (path_name_idx ON path (Path) WITH STRUCTURE=HASH,PAGE_SIZE=32768); +-- ALTER TABLE path ALTER COLUMN path SET STATISTICS 1000; +CREATE UNIQUE INDEX path_name_idx on path (path); -CREATE SEQUENCE File_Seq; +CREATE SEQUENCE file_seq; CREATE TABLE file ( - FileId BIGINT NOT NULL DEFAULT File_Seq.nextval, - FileIndex INTEGER NOT NULL DEFAULT 0, - JobId INTEGER NOT NULL, - PathId INTEGER NOT NULL, - FilenameId INTEGER NOT NULL, - MarkId INTEGER NOT NULL DEFAULT 0, - Lstat VARBYTE(255) NOT NULL, - Md5 VARBYTE(255) NOT NULL, - PRIMARY KEY (fileid) + fileid integer8 not null default file_seq.nextval, + fileindex integer not null default 0, + jobid integer not null, + pathid integer not null, + filenameid integer not null, + markid integer not null default 0, + lstat varchar(256) not null, + md5 varchar(256) not null, + primary key (fileid) ); -CREATE INDEX file_jpfid_idx ON File (jobid, pathid, filenameid); +CREATE INDEX file_jpfid_idx on file (jobid, pathid, filenameid); -- If you need performances, you can remove this index -- the database engine is able to use the composite index -- to find all records with a given JobId -CREATE INDEX file_jobid_idx ON File(jobid); - -CREATE INDEX restore_jobid_idx ON File(JobId); - -CREATE SEQUENCE RestoreObject_Seq; -CREATE TABLE RestoreObject ( - RestoreObjectId INTEGER NOT NULL DEFAULT RestoreObject_Seq.nextval, - Fname VARBYTE(32000) NOT NULL, - Path VARBYTE(32000) NOT NULL, - RestoreObject VARBYTE(32000) NOT NULL, - PluginName VARBYTE(128) NOT NULL, - ObjectIndex INTEGER DEFAULT 0, - ObjectType INTEGER DEFAULT 0, - FileIndex INTEGER DEFAULT 0, - JobId INTEGER, - PRIMARY KEY(RestoreObjectId) -); +CREATE INDEX file_jobid_idx on file(jobid); + +-- +-- Add this if you have a good number of job +-- that run at the same time +-- ALTER SEQUENCE file_fileid_seq CACHE 1000; + +-- +-- Possibly add one or more of the following indexes +-- if your Verifies are too slow. +-- +-- CREATE INDEX file_pathid_idx on file(pathid); +-- CREATE INDEX file_filenameid_idx on file(filenameid); -CREATE SEQUENCE Job_Seq; +-- +-- ***FIXME*** this needs to be corrected and turned on +--CREATE TABLE RestoreObject ( +-- RestoreObjectId INTEGER NOT NULL DEFAULT RestoreObject_seq.nextval, +-- ObjectName TEXT NOT NULL, +-- RestoreObject TEXT NOT NULL, +-- PluginName TEXT NOT NULL, +-- ObjectIndex INTEGER DEFAULT 0, +-- ObjectType INTEGER DEFAULT 0, +-- FileIndex INTEGER UNSIGNED DEFAULT 0, +-- JobId INTEGER UNSIGNED, +-- ObjectCompression INTEGER DEFAULT 0, +-- PRIMARY KEY(RestoreObjectId), +-- ); +--CREATE INDEX restore_jobid_idx on RestoreObject(JobId); +-- + + +CREATE SEQUENCE Job_seq; CREATE TABLE Job ( - JobId INTEGER NOT NULL DEFAULT Job_Seq.nextval, - Job VARBYTE(128) NOT NULL, - Name VARBYTE(128) NOT NULL, - Type CHAR(1) NOT NULL, - Level CHAR(1) NOT NULL, - ClientId INTEGER DEFAULT 0, - JobStatus CHAR(1) NOT NULL, - SchedTime TIMESTAMP WITHOUT TIME ZONE, - StartTime TIMESTAMP WITHOUT TIME ZONE, - EndTime TIMESTAMP WITHOUT TIME ZONE, - RealEndTime TIMESTAMP WITHOUT TIME ZONE, - JobTDate BIGINT DEFAULT 0, - VolSessionId INTEGER DEFAULT 0, - volSessionTime INTEGER DEFAULT 0, - JobFiles INTEGER DEFAULT 0, - JobBytes BIGINT DEFAULT 0, - ReadBytes BIGINT DEFAULT 0, - JobErrors INTEGER DEFAULT 0, - JobMissingFiles INTEGER DEFAULT 0, - PoolId INTEGER DEFAULT 0, - FilesetId INTEGER DEFAULT 0, - PriorJobid INTEGER DEFAULT 0, - PurgedFiles SMALLINT DEFAULT 0, - HasBase SMALLINT DEFAULT 0, - HasCache SMALLINT DEFAULT 0, - Reviewed SMALLINT DEFAULT 0, - Comment VARBYTE(4096), - PRIMARY KEY (JobId) + JobId integer not null default Job_seq.nextval, + Job varchar(256) not null, + Name varchar(256) not null, + Type char(1) not null, + Level char(1) not null, + ClientId integer default 0, + JobStatus char(1) not null, + SchedTime timestamp without time zone, + StartTime timestamp without time zone, + EndTime timestamp without time zone, + RealEndTime timestamp without time zone, + JobTDate bigint default 0, + VolSessionId integer default 0, + volSessionTime integer default 0, + JobFiles integer default 0, + JobBytes bigint default 0, + ReadBytes bigint default 0, + JobErrors integer default 0, + JobMissingFiles integer default 0, + PoolId integer default 0, + FilesetId integer default 0, + PriorJobid integer default 0, + PurgedFiles smallint default 0, + HasBase smallint default 0, + HasCache smallint default 0, + Reviewed smallint default 0, + Comment varchar(256), + primary key (jobid) ); -CREATE INDEX job_name_idx ON Job (Name); +CREATE INDEX job_name_idx on job (name); -- Create a table like Job for long term statistics -CREATE SEQUENCE JobHisto_Seq; +CREATE SEQUENCE JobHisto_seq; CREATE TABLE JobHisto ( - JobId INTEGER NOT NULL DEFAULT JobHisto_Seq.nextval, - Job VARBYTE(128) NOT NULL, - Name VARBYTE(128) NOT NULL, - Type CHAR(1) NOT NULL, - Level CHAR(1) NOT NULL, - ClientId INTEGER DEFAULT 0, - JobStatus CHAR(1) NOT NULL, - SchedTime TIMESTAMP WITHOUT TIME ZONE, - StartTime TIMESTAMP WITHOUT TIME ZONE, - EndTime TIMESTAMP WITHOUT TIME ZONE, - RealEndTime TIMESTAMP WITHOUT TIME ZONE, - JobTDate BIGINT DEFAULT 0, - VolSessionId INTEGER DEFAULT 0, - volSessionTime INTEGER DEFAULT 0, - JobFiles INTEGER DEFAULT 0, - JobBytes BIGINT DEFAULT 0, - ReadBytes BIGINT DEFAULT 0, - JobErrors INTEGER DEFAULT 0, - JobMissingFiles INTEGER DEFAULT 0, - PoolId INTEGER DEFAULT 0, - FilesetId INTEGER DEFAULT 0, - PriorJobid INTEGER DEFAULT 0, - PurgedFiles SMALLINT DEFAULT 0, - HasBase SMALLINT DEFAULT 0, - HasCache SMALLINT DEFAULT 0, - Reviewed SMALLINT DEFAULT 0, - Comment VARBYTE(4096), - PRIMARY KEY (JobId) + JobId integer not null default JobHisto_seq.nextval, + Job varchar(256) not null, + Name varchar(256) not null, + Type char(1) not null, + Level char(1) not null, + ClientId integer default 0, + JobStatus char(1) not null, + SchedTime timestamp without time zone, + StartTime timestamp without time zone, + EndTime timestamp without time zone, + RealEndTime timestamp without time zone, + JobTDate bigint default 0, + VolSessionId integer default 0, + volSessionTime integer default 0, + JobFiles integer default 0, + JobBytes bigint default 0, + ReadBytes bigint default 0, + JobErrors integer default 0, + JobMissingFiles integer default 0, + PoolId integer default 0, + FilesetId integer default 0, + PriorJobid integer default 0, + PurgedFiles smallint default 0, + HasBase smallint default 0, + HasCache smallint default 0, + Reviewed smallint default 0, + Comment varchar(256), + primary key (jobid) ); -CREATE INDEX jobhisto_idx ON JobHisto (StartTime); +CREATE INDEX jobhisto_idx on JobHisto ( StartTime ); + -CREATE SEQUENCE Location_Seq; +CREATE SEQUENCE Location_seq; CREATE TABLE Location ( - LocationId INTEGER NOT NULL DEFAULT Location_Seq.nextval, - Location VARBYTE(128) NOT NULL, - Cost INTEGER DEFAULT 0, - Enabled SMALLINT, - PRIMARY KEY (LocationId) + LocationId integer not null default Location_seq.nextval, + Location varchar(256) not null, + Cost integer default 0, + Enabled smallint, + primary key (LocationId) ); -CREATE SEQUENCE Fileset_Seq; -CREATE TABLE Fileset +CREATE SEQUENCE fileset_seq; +CREATE TABLE fileset ( - FilesetId INTEGER NOT NULL DEFAULT Fileset_Seq.nextval, - Fileset VARBYTE(128) NOT NULL, - Md5 VARBYTE(128) NOT NULL, - Createtime TIMESTAMP WITHOUT TIME ZONE NOT NULL, - PRIMARY KEY (filesetid) + filesetid integer not null default fileset_seq.nextval, + fileset varchar(256) not null, + md5 varchar(256) not null, + createtime timestamp without time zone not null, + primary key (filesetid) ); -CREATE INDEX fileset_name_idx ON Fileset (fileset); +CREATE INDEX fileset_name_idx on fileset (fileset); -CREATE SEQUENCE JobMedia_Seq; -CREATE TABLE JobMedia +CREATE SEQUENCE jobmedia_seq; +CREATE TABLE jobmedia ( - JobMediaId INTEGER NOT NULL DEFAULT JobMedia_Seq.nextval, - JobId INTEGER NOT NULL, - MediaId INTEGER NOT NULL, - FirstIndex INTEGER DEFAULT 0, - LastIndex INTEGER DEFAULT 0, - StartFile INTEGER DEFAULT 0, - EndFile INTEGER DEFAULT 0, - StartBlock BIGINT DEFAULT 0, - EndBlock BIGINT DEFAULT 0, - VolIndex INTEGER DEFAULT 0, - PRIMARY KEY (jobmediaid) + jobmediaid integer not null default jobmedia_seq.nextval, + jobid integer not null, + mediaid integer not null, + firstindex integer default 0, + lastindex integer default 0, + startfile integer default 0, + endfile integer default 0, + startblock bigint default 0, + endblock bigint default 0, + volindex integer default 0, + primary key (jobmediaid) ); -CREATE INDEX job_media_job_id_media_id_idx ON JobMedia (jobid, mediaid); +CREATE INDEX job_media_job_id_media_id_idx on jobmedia (jobid, mediaid); -CREATE SEQUENCE Media_Seq; -CREATE TABLE Media +CREATE SEQUENCE media_seq; +CREATE TABLE media ( - MediaId INTEGER NOT NULL DEFAULT Media_Seq.nextval, - VolumeName VARBYTE(128) NOT NULL, - Slot INTEGER DEFAULT 0, - PoolId INTEGER DEFAULT 0, - MediaType VARBYTE(128) NOT NULL, - MediaTypeId INTEGER DEFAULT 0, - LabelType INTEGER DEFAULT 0, - FirstWritten TIMESTAMP WITHOUT TIME ZONE, - LastWritten TIMESTAMP WITHOUT TIME ZONE, - LabelDate TIMESTAMP WITHOUT TIME ZONE, - VolJobs INTEGER DEFAULT 0, - VolFiles INTEGER DEFAULT 0, - VolBlocks INTEGER DEFAULT 0, - VolMounts INTEGER DEFAULT 0, - VolBytes BIGINT DEFAULT 0, - VolParts INTEGER DEFAULT 0, - VolErrors INTEGER DEFAULT 0, - VolWrites INTEGER DEFAULT 0, - VolCapacitybytes BIGINT DEFAULT 0, - VolStatus VARBYTE(128) NOT NULL - CHECK (volstatus in ('Full','Archive','Append', + mediaid integer not null default media_seq.nextval, + volumename varchar(256) not null, + slot integer default 0, + poolid integer default 0, + mediatype varchar(256) not null, + mediatypeid integer default 0, + labeltype integer default 0, + firstwritten timestamp without time zone, + lastwritten timestamp without time zone, + labeldate timestamp without time zone, + voljobs integer default 0, + volfiles integer default 0, + volblocks integer default 0, + volmounts integer default 0, + volbytes bigint default 0, + volparts integer default 0, + volerrors integer default 0, + volwrites integer default 0, + volcapacitybytes bigint default 0, + volstatus varchar(256) not null + check (volstatus in ('Full','Archive','Append', 'Recycle','Purged','Read-Only','Disabled', 'Error','Busy','Used','Cleaning','Scratch')), - Enabled SMALLINT DEFAULT 1, - Recycle SMALLINT DEFAULT 0, - ActionOnPurge SMALLINT DEFAULT 0, - VolRetention BIGINT DEFAULT 0, - VolUseDuration BIGINT DEFAULT 0, - MaxVolJobs INTEGER DEFAULT 0, - MaxVolFiles INTEGER DEFAULT 0, - MaxVolBytes BIGINT DEFAULT 0, - InChanger SMALLINT DEFAULT 0, - StorageId BIGINT DEFAULT 0, - DeviceId INTEGER DEFAULT 0, - MediaAddressing SMALLINT DEFAULT 0, - VolReadTime BIGINT DEFAULT 0, - VolWriteTime BIGINT DEFAULT 0, - EndFile INTEGER DEFAULT 0, - EndBlock BIGINT DEFAULT 0, - LocationId INTEGER DEFAULT 0, - RecycleCount INTEGER DEFAULT 0, - InitialWrite TIMESTAMP WITHOUT TIME ZONE, - ScratchPoolId INTEGER DEFAULT 0, - RecyclePoolId INTEGER DEFAULT 0, - Comment VARBYTE(4096), - PRIMARY KEY (mediaid) + enabled smallint default 1, + recycle smallint default 0, + ActionOnPurge smallint default 0, + volretention bigint default 0, + voluseduration bigint default 0, + maxvoljobs integer default 0, + maxvolfiles integer default 0, + maxvolbytes bigint default 0, + inchanger smallint default 0, + StorageId bigint default 0, + DeviceId integer default 0, + mediaaddressing smallint default 0, + volreadtime bigint default 0, + volwritetime bigint default 0, + endfile integer default 0, + endblock bigint default 0, + LocationId integer default 0, + recyclecount integer default 0, + initialwrite timestamp without time zone, + scratchpoolid integer default 0, + recyclepoolid integer default 0, + comment varchar(256), + primary key (mediaid) ); -CREATE UNIQUE INDEX media_volumename_id ON Media (VolumeName); +create unique index media_volumename_id on media (volumename); -CREATE SEQUENCE MediaType_Seq; +CREATE SEQUENCE MediaType_seq; CREATE TABLE MediaType ( - MediaTypeId INTEGER NOT NULL DEFAULT MediaType_Seq.nextval, - MediaType VARBYTE(128) NOT NULL, - ReadOnly INTEGER NOT NULL DEFAULT 0, + MediaTypeId INTEGER NOT NULL DEFAULT MediaType_seq.nextval, + MediaType varchar(256) NOT NULL, + ReadOnly INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(MediaTypeId) -); + ); -CREATE SEQUENCE Storage_Seq; +CREATE SEQUENCE Storage_seq; CREATE TABLE Storage ( - StorageId INTEGER NOT NULL DEFAULT Storage_Seq.nextval, - Name VARBYTE(128) NOT NULL, - AutoChanger INTEGER NOT NULL DEFAULT 0, + StorageId INTEGER NOT NULL DEFAULT Storage_seq.nextval, + Name varchar(256) NOT NULL, + AutoChanger INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(StorageId) -); + ); -CREATE SEQUENCE Device_Seq; +CREATE SEQUENCE Device_seq; CREATE TABLE Device ( - DeviceId INTEGER NOT NULL DEFAULT Device_Seq.nextval, - Name VARBYTE(128) NOT NULL, - MediaTypeId INTEGER NOT NULL, - StorageId INTEGER NOT NULL, - DevMounts INTEGER NOT NULL DEFAULT 0, - DevReadBytes BIGINT NOT NULL DEFAULT 0, - DevWriteBytes BIGINT NOT NULL DEFAULT 0, - DevReadBytesSinceCleaning BIGINT NOT NULL DEFAULT 0, - DevWriteBytesSinceCleaning BIGINT NOT NULL DEFAULT 0, - DevReadTime BIGINT NOT NULL DEFAULT 0, - DevWriteTime BIGINT NOT NULL DEFAULT 0, - DevReadTimeSinceCleaning BIGINT NOT NULL DEFAULT 0, - DevWriteTimeSinceCleaning BIGINT NOT NULL DEFAULT 0, - CleaningDate TIMESTAMP WITHOUT TIME ZONE, - CleaningPeriod BIGINT NOT NULL DEFAULT 0, + DeviceId INTEGER NOT NULL DEFAULT Device_seq.nextval, + Name varchar(256) NOT NULL, + MediaTypeId INTEGER NOT NULL, + StorageId INTEGER NOT NULL, + DevMounts INTEGER NOT NULL DEFAULT 0, + DevReadBytes BIGINT NOT NULL DEFAULT 0, + DevWriteBytes BIGINT NOT NULL DEFAULT 0, + DevReadBytesSinceCleaning BIGINT NOT NULL DEFAULT 0, + DevWriteBytesSinceCleaning BIGINT NOT NULL DEFAULT 0, + DevReadTime BIGINT NOT NULL DEFAULT 0, + DevWriteTime BIGINT NOT NULL DEFAULT 0, + DevReadTimeSinceCleaning BIGINT NOT NULL DEFAULT 0, + DevWriteTimeSinceCleaning BIGINT NOT NULL DEFAULT 0, + CleaningDate timestamp without time zone, + CleaningPeriod BIGINT NOT NULL DEFAULT 0, PRIMARY KEY(DeviceId) -); + ); -CREATE SEQUENCE Pool_Seq; -CREATE TABLE Pool +CREATE SEQUENCE pool_seq; +CREATE TABLE pool ( - PoolId INTEGER NOT NULL DEFAULT pool_Seq.nextval, - Name VARBYTE(128) NOT NULL, - NumVols INTEGER DEFAULT 0, - MaxVols INTEGER DEFAULT 0, - UseOnce SMALLINT DEFAULT 0, - UseCatalog SMALLINT DEFAULT 0, - AcceptAnyVolume SMALLINT DEFAULT 0, - VolRetention BIGINT DEFAULT 0, - VolUseDuration BIGINT DEFAULT 0, - MaxVolJobs INTEGER DEFAULT 0, - MaxVolFiles INTEGER DEFAULT 0, - MaxVolBytes BIGINT DEFAULT 0, - AutoPrune SMALLINT DEFAULT 0, - Recycle SMALLINT DEFAULT 0, - ActionOnPurge SMALLINT DEFAULT 0, - PoolType VARBYTE(32) - CHECK (pooltype in ('Backup','Copy','Cloned','Archive','Migration','Scratch')), - LabelType INTEGER DEFAULT 0, - LabelFormat VARBYTE(128) NOT NULL, - Enabled SMALLINT DEFAULT 1, - ScratchPoolId INTEGER DEFAULT 0, - RecyclePoolId INTEGER DEFAULT 0, - NextPoolId INTEGER DEFAULT 0, - MigrationHighBytes BIGINT DEFAULT 0, - MigrationLowBytes BIGINT DEFAULT 0, - MigrationTime BIGINT DEFAULT 0, - PRIMARY KEY (poolid) + poolid integer not null default pool_seq.nextval, + name varchar(256) not null, + numvols integer default 0, + maxvols integer default 0, + useonce smallint default 0, + usecatalog smallint default 0, + acceptanyvolume smallint default 0, + volretention bigint default 0, + voluseduration bigint default 0, + maxvoljobs integer default 0, + maxvolfiles integer default 0, + maxvolbytes bigint default 0, + autoprune smallint default 0, + recycle smallint default 0, + ActionOnPurge smallint default 0, + pooltype varchar(256) + check (pooltype in ('Backup','Copy','Cloned','Archive','Migration','Scratch')), + labeltype integer default 0, + labelformat varchar(256) not null, + enabled smallint default 1, + scratchpoolid integer default 0, + recyclepoolid integer default 0, + NextPoolId integer default 0, + MigrationHighBytes BIGINT DEFAULT 0, + MigrationLowBytes BIGINT DEFAULT 0, + MigrationTime BIGINT DEFAULT 0, + primary key (poolid) ); -CREATE INDEX pool_name_idx ON Pool (name); +CREATE INDEX pool_name_idx on pool (name); -CREATE SEQUENCE Client_Seq; -CREATE TABLE Client +CREATE SEQUENCE client_seq; +CREATE TABLE client ( - ClientId INTEGER NOT NULL DEFAULT Client_Seq.nextval, - Name VARBYTE(128) NOT NULL, - Uname VARBYTE(256) NOT NULL, - AutoPrune SMALLINT DEFAULT 0, - FileRetention BIGINT DEFAULT 0, - JobRetention BIGINT DEFAULT 0, - PRIMARY KEY (clientid) + clientid integer not null default client_seq.nextval, + name varchar(256) not null, + uname varchar(256) not null, + autoprune smallint default 0, + fileretention bigint default 0, + jobretention bigint default 0, + primary key (clientid) ); -CREATE UNIQUE INDEX client_name_idx ON Client (Name); +create unique index client_name_idx on client (name); -CREATE SEQUENCE Log_Seq; +CREATE SEQUENCE Log_seq; CREATE TABLE Log ( - LogId INTEGER NOT NULL DEFAULT Log_Seq.nextval, - JobId INTEGER NOT NULL, - Time TIMESTAMP WITHOUT TIME ZONE, - LogText VARBYTE(4096) NOT NULL, - PRIMARY KEY (LogId) + LogId integer not null default Log_seq.nextval, + JobId integer not null, + Time timestamp without time zone, + LogText varchar(256) not null, + primary key (LogId) ); -CREATE INDEX log_name_idx ON Log (JobId); +create index log_name_idx on Log (JobId); -CREATE SEQUENCE LocationLog_Seq; +CREATE SEQUENCE LocationLog_seq; CREATE TABLE LocationLog ( - LocLogId INTEGER NOT NULL DEFAULT LocationLog_Seq.nextval, - Date TIMESTAMP WITHOUT TIME ZONE, - Comment VARBYTE(4096) NOT NULL, - MediaId INTEGER DEFAULT 0, - LocationId INTEGER DEFAULT 0, - NewVolStatus VARBYTE(32) NOT NULL - CHECK (newvolstatus in ('Full','Archive','Append', + LocLogId INTEGER NOT NULL DEFAULT LocationLog_seq.nextval, + Date timestamp without time zone, + Comment varchar(256) NOT NULL, + MediaId INTEGER DEFAULT 0, + LocationId INTEGER DEFAULT 0, + newvolstatus varchar(256) not null + check (newvolstatus in ('Full','Archive','Append', 'Recycle','Purged','Read-Only','Disabled', 'Error','Busy','Used','Cleaning','Scratch')), - NewEnabled SMALLINT, + newenabled smallint, PRIMARY KEY(LocLogId) ); -CREATE TABLE Counters +CREATE TABLE counters ( - Counter VARBYTE(128) NOT NULL, - MinValue INTEGER DEFAULT 0, - MaxValue INTEGER DEFAULT 0, - CurrentValue INTEGER DEFAULT 0, - WrapCounter VARBYTE(128) NOT NULL, - PRIMARY KEY (counter) + counter varchar(256) not null, + minvalue integer default 0, + maxvalue integer default 0, + currentvalue integer default 0, + wrapcounter varchar(256) not null, + primary key (counter) ); -CREATE SEQUENCE BaseFiles_Seq; -CREATE TABLE BaseFiles +CREATE SEQUENCE basefiles_seq; +CREATE TABLE basefiles ( - BaseId INTEGER NOT NULL DEFAULT BaseFiles_Seq.nextval, - JobId INTEGER NOT NULL, - FileId BIGINT NOT NULL, - FileIndex INTEGER, - BaseJobid INTEGER, - PRIMARY KEY (BaseId) + baseid integer not null default basefiles_seq.nextval, + jobid integer not null, + fileid bigint not null, + fileindex integer , + basejobid integer , + primary key (baseid) ); -CREATE INDEX basefiles_jobid_idx ON BaseFiles (JobId); +CREATE INDEX basefiles_jobid_idx ON BaseFiles ( JobId ); CREATE TABLE unsavedfiles ( - UnsavedId INTEGER NOT NULL, - JobId INTEGER NOT NULL, - PathId INTEGER NOT NULL, - FilenameId INTEGER NOT NULL, - PRIMARY KEY (UnsavedId) + UnsavedId integer not null, + jobid integer not null, + pathid integer not null, + filenameid integer not null, + primary key (UnsavedId) ); CREATE TABLE CDImages ( - MediaId INTEGER NOT NULL, - LastBurn TIMESTAMP WITHOUT TIME ZONE NOT NULL, - PRIMARY KEY (MediaId) + MediaId integer not null, + LastBurn timestamp without time zone not null, + primary key (MediaId) ); + CREATE TABLE PathHierarchy ( - PathId INTEGER NOT NULL, - PPathId INTEGER NOT NULL, - CONSTRAINT pathhierarchy_pkey PRIMARY KEY (PathId) + PathId integer NOT NULL, + PPathId integer NOT NULL, + CONSTRAINT pathhierarchy_pkey PRIMARY KEY (PathId) ); -CREATE INDEX pathhierarchy_ppathid ON PathHierarchy (PPathId); +CREATE INDEX pathhierarchy_ppathid + ON PathHierarchy (PPathId); CREATE TABLE PathVisibility ( - PathId INTEGER NOT NULL, - JobId INTEGER NOT NULL, - Size BIGINT DEFAULT 0, - Files INTEGER DEFAULT 0, - CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId) + PathId integer NOT NULL, + JobId integer NOT NULL, + Size int8 DEFAULT 0, + Files int4 DEFAULT 0, + CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId) ); -CREATE INDEX pathvisibility_jobid ON PathVisibility (JobId); +CREATE INDEX pathvisibility_jobid + ON PathVisibility (JobId); CREATE TABLE version ( - versionid INTEGER NOT NULL + versionid integer not null ); CREATE TABLE Status ( - JobStatus CHAR(1) NOT NULL, - JobStatusLong VARBYTE(128), - Severity INTEGER, + JobStatus CHAR(1) NOT NULL, + JobStatusLong varchar(256), + Severity int, PRIMARY KEY (JobStatus) -); + ); \g diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index dae28e4c8a..bdf6efe3da 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -73,7 +73,7 @@ CREATE TABLE RestoreObject ( ObjectCompression INTEGER DEFAULT 0, PRIMARY KEY(RestoreObjectId), ); -CREATE INDEX restore_jobid_idx on file(JobId); +CREATE INDEX restore_jobid_idx on RestoreObject(JobId); CREATE TABLE Job