# patch  create.irt-tables.sql.patch should be applied first

# Drop some indexes

ALTER TABLE auth DROP INDEX auth;

ALTER TABLE auth_override DROP INDEX date;

ALTER TABLE ifaddr DROP INDEX ifaddr;

ALTER TABLE mnt_nfy DROP INDEX mnt_nfy;

ALTER TABLE upd_to DROP INDEX upd_to;

ALTER TABLE admin_c DROP INDEX thread_id;

ALTER TABLE tech_c DROP INDEX thread_id;

ALTER TABLE zone_c DROP INDEX thread_id;

# Some MAIN tables' inconsistencies

ALTER TABLE inet_rtr MODIFY inet_rtr varchar(254) DEFAULT '' NOT NULL;
ALTER TABLE domain   MODIFY domain varchar(254) DEFAULT '' NOT NULL;
ALTER TABLE last     MODIFY pkey varchar(254) default '' NOT NULL;
ALTER TABLE history  MODIFY pkey varchar(254) default '' NOT NULL;

# Other tables fields modifications

ALTER TABLE auth     MODIFY auth varchar(90) binary DEFAULT '' NOT NULL;
ALTER TABLE rev_srv  MODIFY rev_srv varchar(254) DEFAULT '' NOT NULL; 
ALTER TABLE nserver  MODIFY host varchar(254) DEFAULT '' NOT NULL;
ALTER TABLE sub_dom  MODIFY domain varchar(254) DEFAULT '' NOT NULL;
ALTER TABLE mnt_nfy  MODIFY mnt_nfy varchar(80) DEFAULT '' NOT NULL;
ALTER TABLE upd_to   MODIFY upd_to varchar(80) DEFAULT '' NOT NULL;


# PK modifications

ALTER TABLE mnt_routes DROP PRIMARY KEY;
ALTER TABLE mnt_routes ADD PRIMARY KEY (mnt_id,object_id);

ALTER TABLE auth DROP PRIMARY KEY;
ALTER TABLE auth ADD PRIMARY KEY (auth(90),object_id);

ALTER TABLE auth_override DROP PRIMARY KEY;
ALTER TABLE auth_override ADD PRIMARY KEY (date, object_id);

ALTER TABLE ifaddr DROP PRIMARY KEY;
ALTER TABLE ifaddr ADD PRIMARY KEY (ifaddr, object_id);

ALTER TABLE mnt_nfy DROP PRIMARY KEY;
ALTER TABLE mnt_nfy ADD PRIMARY KEY (mnt_nfy(80), object_id);

ALTER TABLE upd_to DROP PRIMARY KEY;
ALTER TABLE upd_to ADD PRIMARY KEY (upd_to(80),object_id);

ALTER TABLE refer DROP PRIMARY KEY;
ALTER TABLE refer ADD PRIMARY KEY (object_id,host(80),port,type);

ALTER TABLE rev_srv DROP PRIMARY KEY;
ALTER TABLE rev_srv ADD PRIMARY KEY (rev_srv(254),object_id);

ALTER TABLE nserver DROP PRIMARY KEY;
ALTER TABLE nserver ADD PRIMARY KEY (host(254),object_id);

ALTER TABLE sub_dom DROP PRIMARY KEY;
ALTER TABLE sub_dom ADD PRIMARY KEY (domain(254),object_id);

ALTER TABLE e_mail DROP PRIMARY KEY;
ALTER TABLE e_mail ADD PRIMARY KEY (e_mail(80),object_id);

ALTER TABLE notify DROP PRIMARY KEY;
ALTER TABLE notify ADD PRIMARY KEY (notify(80),object_id);


# LEAF tables indexes

ALTER TABLE auth ADD  INDEX  (object_id);

ALTER TABLE auth_override ADD  INDEX  (object_id);

ALTER TABLE ifaddr ADD  INDEX  (object_id);

ALTER TABLE mnt_nfy ADD  INDEX  (object_id);

ALTER TABLE upd_to ADD  INDEX  (object_id);






