DROP TABLE IF EXISTS Files_@HOST@_@DIRECTORY@;

CREATE TABLE Files_@HOST@_@DIRECTORY@ (
  filename   CHAR(255) PRIMARY KEY,
  neb_ins_id BIGINT(20) NOT NULL,
  subdirname CHAR(3) NOT NULL,
  INDEX(subdirname),
  nebkey     CHAR(255),
  INDEX(nebkey),
  size       INT DEFAULT -1,
  md5sum     CHAR(33) DEFAULT NULL,
  role       ENUM('undefined', 'unknown', 'deleted', 'b1fits', 'b1jpg', 'b2fits', 
               'b2jpg', 'bttable', 'bundle', 'catalog', 
             'fits', 'compfits', 'kernel', 'log', 'logupdate', 'mask', 'mdc', 'mdl', 
             'miscfits', 'png', 'psf', 'ptn', 'skycell', 'stats',
             'trace', 'weight', 'other')
        NOT NULL DEFAULT 'undefined',
  INDEX(role),
  stage ENUM( 'undefined', 'unknown', 'raw', 'chip', 'cam', 'fake', 'detrend',
  	                            'warp', 'stack', 'diff', 'magic', 'destreak', 
        			    'dist', 'pub', 'staticsky', 'chipbackground',
                                    'other' )
        NOT NULL DEFAULT 'undefined',
  INDEX(stage),
  lifetime   ENUM('undefined', 'permanent', 'ephemeral', 'raw', 'unknown') NOT NULL DEFAULT 'undefined',
  creation_date TIMESTAMP DEFAULT 0,
  last_check TIMESTAMP DEFAULT 0
);
