
synopsis:

   Dump of most recent version of all config-files in the system

description:

    List only the latest revision of all configuration-files for all organizations, including
    file contents and file information

    (See spacewalk.configchannel.lookupFileInfo(chan-label, [paths]) )

columns:

    org_id        Organization identifier
    channel_id    ID of the Configuration channel containing the file
    channel       Configuration channel containing the file
    channel_type  Config-channel type (normal, local_override, server_import)
    path          Path of the config-file
    file_type     Filetype of the cfg-file (file, directory, symlink)
    file_id       File-id of the cfg-file
    revision      Revision of this cfg-file in this channel
    is_binary     true if file is binary (base64-enc) or false if text
    contents      Actual content of this version of this cfg-file in this channel
    delim_start   Sequence used to delimit start-of-macro
    delim_end     Sequence used to delimit end-of-macro
    username      Username file is to be owned-by
    groupname     Groupname of file's grou-owner
    filemode      Filemode of the deployed file
    symbolic_link Path to be linked-to if filetype == symlink
    selinux_ctx   selinux context of delpoyed file

sql:

    select * from (
        select T1.* from (
            select cchan.org_id,
                   cchan.id as channel_id,
                   cchan.label as channel,
                   cct.label as channel_type,
                   cfn.path,
                   cft.label as file_type,
                   cf.id file_id,
                   crev.revision,
                   cc.is_binary,
                   cc.contents,
                   cc.delim_start,
                   cc.delim_end,
                   cfi.username,
                   cfi.groupname,
                   cfi.filemode,
                   cfn2.path as symbolic_link,
                   cfi.selinux_ctx
              from rhnconfigfile cf
                   inner join rhnconfigchannel cchan on cchan.id = cf.config_channel_id
                   inner join rhnconfigchanneltype cct on cct.id = cchan.confchan_type_id
                   inner join rhnconfigfilename cfn on cf.config_file_name_id = cfn.id
                   inner join rhnconfigrevision crev on crev.config_file_id = cf.id
                   left outer join rhnconfigcontent cc on cc.id = crev.config_content_id
                   inner join rhnconfiginfo cfi on cfi.id = crev.config_info_id
                   inner join rhnconfigfiletype cft on cft.id = crev.config_file_type_id
                   left outer join rhnconfigfilename cfn2 on cfn2.id = cfi.symlink_target_filename_id
        ) T1
        left outer join (
            select cchan.org_id,
                   cchan.id as channel_id,
                   cchan.label as channel,
                   cct.label as channel_type,
                   cfn.path,
                   cft.label as file_type,
                   cf.id file_id,
                   crev.revision,
                   cc.is_binary,
                   cc.contents,
                   cc.delim_start,
                   cc.delim_end,
                   cfi.username,
                   cfi.groupname,
                   cfi.filemode,
                   cfn2.path as symbolic_link,
                   cfi.selinux_ctx
              from rhnconfigfile cf
                   inner join rhnconfigchannel cchan on cchan.id = cf.config_channel_id
                   inner join rhnconfigchanneltype cct on cct.id = cchan.confchan_type_id
                   inner join rhnconfigfilename cfn on cf.config_file_name_id = cfn.id
                   inner join rhnconfigrevision crev on crev.config_file_id = cf.id
                   left outer join rhnconfigcontent cc on cc.id = crev.config_content_id
                   inner join rhnconfiginfo cfi on cfi.id = crev.config_info_id
                   inner join rhnconfigfiletype cft on cft.id = crev.config_file_type_id
                   left outer join rhnconfigfilename cfn2 on cfn2.id = cfi.symlink_target_filename_id
       ) T2 on (t1.file_id = t2.file_id and t1.revision < t2.revision)
       where t2.file_id is null
     ) X
 -- where placeholder
 order by org_id, channel, path, revision desc
