Commit f4c6cf58 authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

[migration] updated code following latest schema changes

parent 5a2699dd
......@@ -89,10 +89,11 @@ BEGIN
FOR DGN IN (SELECT dgn FROM Vmgr_tape_dgnmap) LOOP
-- The very first time insert the logical libraries found on VMGR
BEGIN
INSERT INTO Logical_Library (logical_library_name, user_comment,
INSERT INTO Logical_Library (logical_library_id, logical_library_name, user_comment,
creation_log_user_name, creation_log_host_name, creation_log_time,
last_update_user_name, last_update_host_name, last_update_time)
VALUES (
(SELECT Logical_Library_id_seq.NEXTVAL FROM Dual),
DGN.dgn,
'Imported from CASTOR',
'CASTOR', 'CASTOR', getTime(),
......@@ -104,7 +105,7 @@ BEGIN
END LOOP;
BEGIN
SELECT TAPE_POOL_ID_SEQ.NEXTVAL INTO varTapePoolId FROM Dual;
SELECT Tape_Pool_id_seq.NEXTVAL INTO varTapePoolId FROM Dual;
INSERT INTO Tape_Pool (tape_pool_id, tape_pool_name, vo, nb_partial_tapes, is_encrypted, user_comment,
creation_log_user_name, creation_log_host_name, creation_log_time, last_update_user_name,
last_update_host_name, last_update_time)
......@@ -137,9 +138,9 @@ BEGIN
AND TI.model = DGN.model
AND BITAND(TS.status, 2) = 0 AND BITAND(TS.status, 32) = 0 -- not already EXPORTED or ARCHIVED
AND TS.poolname = inTapePool) LOOP
INSERT INTO Tape (vid, media_type, vendor, logical_library_name, tape_pool_id,
INSERT INTO Tape (vid, media_type, vendor, logical_library_id, tape_pool_id,
encryption_key_name, capacity_in_bytes, data_in_bytes, last_fseq,
is_disabled, is_full, is_read_only, is_from_castor,
is_disabled, is_full, is_read_only, is_archived, is_exported, is_from_castor,
label_drive, label_time, last_read_drive, last_read_time, read_mount_count,
last_write_drive, last_write_time, write_mount_count,
user_comment, creation_log_user_name, creation_log_host_name, creation_log_time,
......@@ -155,7 +156,7 @@ BEGIN
'15TC', '3592JD',
'UNDEFINED'),
T.manufacturer,
T.dgn,
(SELECT logical_library_id FROM Logical_Library WHERE logical_library_name = T.dgn),
varTapePoolId,
NULL, -- empty encryption key name
decode(T.density, -- capacity: only one of the options below (see #488)
......@@ -171,6 +172,8 @@ BEGIN
decode(BITAND(T.status, 1), 1, '1', '0'), -- DISABLED flag
decode(BITAND(T.status, 8), 8, '1', '0'), -- FULL flag
decode(BITAND(T.status, 16), 16, '1', '0'), -- RDONLY flag
'0', -- ARCHIVED flag
'0', -- EXPORTED flag
'1', -- is_from_castor flag
'CASTOR', 0, -- label drive and time (unknown)
T.rhost, T.rtime, T.rcount, -- last read drive/time and count
......@@ -237,12 +240,12 @@ BEGIN
INSERT /*+ APPEND PARALLEL(Archive_File) */ INTO Archive_File
(archive_file_id, disk_instance_name, disk_file_id, disk_file_path,
disk_file_uid, disk_file_gid, size_in_bytes, checksum_adler32,
storage_class_id, creation_time, reconciliation_time) (
storage_class_id, creation_time, reconciliation_time, is_deleted) (
SELECT /*+ PARALLEL(F) PARALLEL(D) */
F.fileid, inEOSCTAInstance, F.fileid,
'/eos/' || varNamespacePrefix
|| substr(D.path, varLenCastorPrefix) || '/' || F.filename,
F.disk_uid, F.disk_gid, F.filesize, F.checksum, F.classid, F.btime, 0
F.disk_uid, F.disk_gid, F.filesize, F.checksum, F.classid, F.btime, 0, '0'
FROM CNS_CTAFilesHelper F, CNS_Dirs_Full_Path D
WHERE F.parent_fileid = D.fileid
-- no need to exclude already existing files because of dual copies
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment