/* Prevent "cannot alter type of a column used by a view or rule" errors when
cleanup operations are run using in place UPDATE */
DROP VIEW view_all_commnames_code CASCADE;
DROP VIEW view_all_commnames_common CASCADE;
DROP VIEW view_all_commnames_sciname CASCADE;
DROP VIEW view_all_commnames_translated CASCADE;
DROP VIEW view_all_plantnames_code CASCADE;
DROP VIEW view_all_plantnames_common CASCADE;
DROP VIEW view_all_plantnames_sciname CASCADE;
DROP VIEW view_all_plantnames_scinamenoauth CASCADE;
DROP VIEW view_notemb_observation CASCADE;
DROP VIEW view_browseparty_classcontrib CASCADE;
DROP VIEW view_browseparty_obscontrib CASCADE;
DROP VIEW view_browseparty_projectcontrib CASCADE;
DROP VIEW view_browseparty_all CASCADE;
DROP VIEW view_browseparty_all_count CASCADE;
DROP VIEW view_browseparty_classcontrib_count CASCADE;
DROP VIEW view_browseparty_obscontrib_count CASCADE;
DROP VIEW view_browseparty_projectcontrib_count CASCADE;
DROP VIEW view_browseparty_all_count_combined CASCADE;
DROP VIEW view_busrule_duplcovercode CASCADE;
DROP VIEW view_busrule_duplstratumtype CASCADE;
DROP VIEW view_busrule_plotsizeshape CASCADE;
DROP VIEW view_reference_transl CASCADE;
DROP VIEW view_commconcept_transl CASCADE;
DROP VIEW view_notemb_commclass CASCADE;
DROP VIEW view_comminterp_more CASCADE;
DROP VIEW view_csv_taxonimportance_pre CASCADE;
DROP VIEW view_csv_taxonimportance CASCADE;
DROP VIEW view_dbafielddesc_notimpl CASCADE;
DROP VIEW view_emb_embargo_currentfullonly CASCADE;
DROP VIEW view_emb_embargo_complete CASCADE;
DROP VIEW view_keywprojplaces CASCADE;
DROP VIEW view_kwhelper_projcontrib CASCADE;
DROP VIEW view_kwhelper_refjournal CASCADE;
DROP VIEW view_kwhelper_refparty CASCADE;
DROP VIEW view_notemb_classcontributor CASCADE;
DROP VIEW view_notemb_comminterpretation CASCADE;
DROP VIEW view_notemb_disturbanceobs CASCADE;
DROP VIEW view_notemb_plot CASCADE;
DROP VIEW view_notemb_soilobs CASCADE;
DROP VIEW view_notemb_stemcount CASCADE;
DROP VIEW view_notemb_stemlocation CASCADE;
DROP VIEW view_notemb_taxonalt CASCADE;
DROP VIEW view_notemb_taxonimportance CASCADE;
DROP VIEW view_notemb_taxoninterpretation CASCADE;
DROP VIEW view_notemb_taxonobservation CASCADE;
DROP VIEW view_observation_transl CASCADE;
DROP VIEW view_party_public CASCADE;
DROP VIEW view_party_transl CASCADE;
DROP VIEW view_plantconcept_transl CASCADE;
DROP VIEW view_plotall_withembargo CASCADE;
DROP VIEW view_std_commnames_code CASCADE;
DROP VIEW view_std_commnames_common CASCADE;
DROP VIEW view_std_commnames_sciname CASCADE;
DROP VIEW view_std_commnames_translated CASCADE;
DROP VIEW view_std_plantnames_code CASCADE;
DROP VIEW view_std_plantnames_common CASCADE;
DROP VIEW view_std_plantnames_sciname CASCADE;
DROP VIEW view_std_plantnames_scinamenoauth CASCADE;
DROP VIEW view_taxoninterp_more CASCADE;
DROP VIEW view_taxonobs_withmaxcover CASCADE;
DROP VIEW view_taxonobs_distinctid_curr CASCADE;
DROP VIEW view_taxonobs_distinctid_curr_counts CASCADE;
DROP VIEW view_taxonobs_distinctid_curr_counts_plants CASCADE;

-- Prevent "column name specified more than once" errors when tables are joined
ALTER TABLE taxonobservation RENAME accessioncode  TO taxonobservation_accessioncode;
ALTER TABLE taxoninterpretation RENAME plantname_id  TO taxoninterpretation_plantname_id;
ALTER TABLE taxoninterpretation RENAME accessioncode  TO taxoninterpretation_accessioncode;
ALTER TABLE plantconcept RENAME reference_id  TO plantconcept_reference_id;
ALTER TABLE plantconcept RENAME accessioncode  TO plantconcept_accessioncode;
