if exists (select * from sys.indexes where name = 'idx__address_addr_id') drop index address.idx__address_addr_id;
if exists (select * from sys.indexes where name = 'idx__address_city_state') drop index address.idx__address_city_state;
if exists (select * from sys.indexes where name = 'idx__address_zip') drop index address.idx__address_zip;
create unique index idx__address_addr_id on address (addr_id);
create index idx__address_city_state on address (__city, __state, id);
create index idx__address_zip on address (__zip_code, id);
if exists (select * from sys.indexes where name = 'idx__book_book_id') drop index book.idx__book_book_id;
if exists (select * from sys.indexes where name = 'idx__book_author_id') drop index book.idx__book_author_id;
if exists (select * from sys.indexes where name = 'idx__book_isbn') drop index book.idx__book_isbn;
if exists (select * from sys.indexes where name = 'idx__book_pub_date') drop index book.idx__book_pub_date;
if exists (select * from sys.indexes where name = 'idx__book_publisher') drop index book.idx__book_publisher;
create unique index idx__book_book_id on book (book_id);
create unique index idx__book_isbn on book (__isbn);
create index idx__book_author_id on book (author_id, id);
create index idx__book_pub_date on book (pub_date, id);
create index idx__book_publisher on book (__publisher, id);
if exists (select * from sys.indexes where name = 'idx__cs_test_idx_pos') drop index cs_test.idx__cs_test_idx_pos;
create unique index idx__cs_test_idx_pos on cs_test (pos);
if exists (select * from sys.indexes where name = 'idx__pers_addr_person') drop index pers_addr.idx__pers_addr_person;
if exists (select * from sys.indexes where name = 'idx__pers_addr_active') drop index pers_addr.idx__pers_addr_active;
if exists (select * from sys.indexes where name = 'idx__pers_addr_address') drop index pers_addr.idx__pers_addr_address;
if exists (select * from sys.indexes where name = 'idx__pers_addr_link_type') drop index pers_addr.idx__pers_addr_link_type;
create index idx__pers_addr_person on pers_addr (site_id, emp_num, id);
create index idx__pers_addr_active on pers_addr (active, id);
create index idx__pers_addr_address on pers_addr (addr_id, id);
create index idx__pers_addr_link_type on pers_addr (__link_type, id);
if exists (select * from sys.indexes where name = 'idx__person_site_emp') drop index person.idx__person_site_emp;
if exists (select * from sys.indexes where name = 'idx__person_emp_ssn') drop index person.idx__person_emp_ssn;
if exists (select * from sys.indexes where name = 'idx__person_exten') drop index person.idx__person_exten;
if exists (select * from sys.indexes where name = 'idx__person_hire_date') drop index person.idx__person_hire_date;
if exists (select * from sys.indexes where name = 'idx__person_name') drop index person.idx__person_name;
if exists (select * from sys.indexes where name = 'idx__person_pay_type') drop index person.idx__person_pay_type;
if exists (select * from sys.indexes where name = 'idx__person_phone') drop index person.idx__person_phone;
if exists (select * from sys.indexes where name = 'idx__person_term_date') drop index person.idx__person_term_date;
create unique index idx__person_exten on person (__extension);
create unique index idx__person_site_emp on person (site_id, emp_num);
create unique index idx__person_emp_ssn on person (__ssn);
create index idx__person_hire_date on person (hire_date, id);
create index idx__person_name on person (__last_name, __first_name, __middle_init, id);
create index idx__person_pay_type on person (__pay_type, id);
create index idx__person_phone on person (__area_code, __phone_number, __extension);
create index idx__person_term_date on person (term_date, id);
if exists (select * from sys.indexes where name = 'idx__simple_pi_number') drop index simple.idx__simple_pi_number;
create unique index idx__simple_pi_number on simple (number);
if exists (select * from sys.indexes where name = 'idx__vehicle_pi_make_model') drop index vehicle.idx__vehicle_pi_make_model;
if exists (select * from sys.indexes where name = 'idx__vehicle_si_vin') drop index vehicle.idx__vehicle_si_vin;
create unique index idx__vehicle_si_vin on vehicle (__vin_number);
create unique index idx__vehicle_pi_make_model on vehicle (__make, __model);
if exists (select * from sys.indexes where name = 'idx__vehicle_driver_pi_name') drop index vehicle_driver.idx__vehicle_driver_pi_name;
if exists (select * from sys.indexes where name = 'idx__vehicle_driver_si_vin') drop index vehicle_driver.idx__vehicle_driver_si_vin;
create unique index idx__vehicle_driver_pi_name on vehicle_driver (__name);
create index idx__vehicle_driver_si_vin on vehicle_driver (__vin_number, id);
if exists (select * from sys.indexes where name = 'idx__vehicle_owner_pi_name') drop index vehicle_owner.idx__vehicle_owner_pi_name;
if exists (select * from sys.indexes where name = 'idx__vehicle_owner_si_vin') drop index vehicle_owner.idx__vehicle_owner_si_vin;
create unique index idx__vehicle_owner_pi_name on vehicle_owner (__name);
create unique index idx__vehicle_owner_si_vin on vehicle_owner (__vin_number);
if exists (select * from sys.sequences where name = 'p2j_id_generator_sequence' and type='SO') drop sequence p2j_id_generator_sequence;
create sequence p2j_id_generator_sequence start with 10000;
