To make life easier during testing, I wrote the following script to drop al tables (and one sequence) in the PostgreSQL database to start again from scratch after some testing.
#!/bin/sh # Author: Petter Reinholdtsen # License: GPL v2 or later at your choice # # Remove all PostgreSQL tables in reverse dependency order, to start # from scratch during testing. # # Warning, this is very destructive. Remember the files are still on # disk after this.
PGHOST=postgresql.host PGUSER=nikita_noark5_user PGDB=nikita_noark5_db
psql --port 5432 --host $PGHOST --user $PGUSER $PGDB -c " BEGIN TRANSACTION; DROP TABLE as_correspondence_part_internal ; DROP TABLE as_postal_address ; DROP TABLE as_residing_address ; DROP TABLE as_contact_information ; DROP TABLE as_correspondence_part_person ; DROP TABLE as_business_address ; DROP TABLE as_correspondence_part_unit ; DROP TABLE sa_registry_entry_sign_off ; DROP TABLE as_sign_off ; DROP TABLE bsm_base ; DROP TABLE as_correspondence_part ; DROP TABLE sa_case_file_precedence ; DROP TABLE sa_case_file ; DROP TABLE sa_sequence_generator ; DROP TABLE ad_administrative_unit_user ; DROP TABLE ad_administrative_unit ; DROP TABLE ad_user_authority ; DROP TABLE ad_authority ; DROP TABLE as_document_flow ; DROP TABLE log_change_log ; DROP TABLE log_create_log ; DROP TABLE log_delete_log ; DROP TABLE log_read_log ; DROP TABLE log_event_log ; DROP TABLE sa_registry_entry_precedence ; DROP TABLE sa_precedence ; DROP TABLE ad_user ; DROP TABLE as_author ; DROP TABLE as_building ; DROP TABLE as_cadastral ; DROP TABLE as_class_keyword ; DROP TABLE as_cross_reference ; DROP TABLE as_file_comment ; DROP TABLE as_file_keyword ; DROP TABLE as_file_part ; DROP TABLE as_file_storage_location ; DROP TABLE as_d_number ; DROP TABLE as_plan ; DROP TABLE as_position ; DROP TABLE as_social_security_number ; DROP TABLE as_unit ; DROP TABLE as_national_identifier ; DROP TABLE as_record_document_description ; DROP TABLE as_record_keyword ; DROP TABLE as_record_part ; DROP TABLE as_record_storage_location ; DROP TABLE mu_meeting_record ; DROP TABLE as_electronic_signature ; DROP TABLE sa_registry_entry ; DROP TABLE as_record_comment ; DROP TABLE sa_record_note ; DROP TABLE as_record_entity ; DROP TABLE mu_meeting_participant ; DROP TABLE mu_meeting_file ; DROP TABLE as_file ; DROP TABLE as_class ; DROP TABLE as_series_classification_system ; DROP TABLE as_classification_system ; DROP TABLE as_document_description_comment ; DROP TABLE as_document_description_party ; DROP TABLE as_conversion ; DROP TABLE as_document_object ; DROP TABLE as_document_description ; DROP TABLE as_series_storage_location ; DROP TABLE as_series ; DROP TABLE as_classified ; DROP TABLE as_comment ; DROP TABLE as_deletion ; DROP TABLE as_disposal ; DROP TABLE as_disposal_undertaken ; DROP TABLE as_fonds_fonds_creator ; DROP TABLE as_fonds_creator ; DROP TABLE as_fonds_storage_location ; DROP TABLE as_fonds ; DROP TABLE as_keyword ; DROP TABLE as_part_person ; DROP TABLE as_part_unit ; DROP TABLE as_part ; DROP TABLE as_screening_metadata ; DROP TABLE as_screening ; DROP TABLE as_storage_location ; DROP TABLE md_access_category ; DROP TABLE md_access_restriction ; DROP TABLE md_associated_with_record_as ; DROP TABLE md_bsm ; DROP TABLE md_case_status ; DROP TABLE md_classification_type ; DROP TABLE md_classified_code ; DROP TABLE md_comment_type ; DROP TABLE md_coordinate_system ; DROP TABLE md_correspondence_part_type ; DROP TABLE md_country ; DROP TABLE md_deletion_type ; DROP TABLE md_disposal_decision ; DROP TABLE md_document_medium ; DROP TABLE md_document_status ; DROP TABLE md_document_type ; DROP TABLE md_electronic_signature_security_level ; DROP TABLE md_electronic_signature_verified ; DROP TABLE md_event_type ; DROP TABLE md_file_type ; DROP TABLE md_flow_status ; DROP TABLE md_fonds_status ; DROP TABLE md_format ; DROP TABLE md_meeting_file_type ; DROP TABLE md_meeting_participant_function ; DROP TABLE md_meeting_registration_status ; DROP TABLE md_meeting_registration_type ; DROP TABLE md_part_role ; DROP TABLE md_postal_code ; DROP TABLE md_precedence_status ; DROP TABLE md_registry_entry_status ; DROP TABLE md_registry_entry_type ; DROP TABLE md_screening_document ; DROP TABLE md_screening_metadata ; DROP TABLE md_series_status ; DROP TABLE md_sign_off_method ; DROP TABLE md_variant_format ; DROP TABLE ad_organisation CASCADE; DROP TABLE system_id_entity; DROP SEQUENCE authority_seq; END TRANSACTION; "
I checked this into master as b/scripts/psql/nikita-tables-drop-psql.