START TRANSACTION;

CREATE SEQUENCE USERS_SEQ_ID;
CREATE TABLE USERS (
  ID integer PRIMARY KEY DEFAULT nextval('USERS_SEQ_ID'::regclass),
  LOGIN varchar(32) UNIQUE NOT NULL,
  PASSWORD char(32) NOT NULL,
  STATUS INT NOT NULL DEFAULT 0
);

INSERT INTO USERS(LOGIN, PASSWORD, STATUS) values('test', md5('test'), 1);
INSERT INTO USERS(LOGIN, PASSWORD, STATUS) values('user', md5('user'), 1);

ALTER TABLE DICOM_REQUESTED_PROC ALTER COLUMN ADMISSION_ID TYPE varchar(50);

DROP INDEX OBJECTS_ARCHIVED;
CREATE INDEX OBJECTS_ARCHIVED ON DICOM_OBJECTS(COMPRESSED, UPLOAD_DATE, ID);

COMMIT;
