-- Скрипт для полной очистки базы данных smartsoltech_db
-- ВНИМАНИЕ: Этот скрипт удалит ВСЕ данные из базы данных!

-- Отключаем проверку внешних ключей
SET session_replication_role = replica;

-- Удаляем все таблицы Django приложений
DROP TABLE IF EXISTS django_migrations CASCADE;
DROP TABLE IF EXISTS django_content_type CASCADE;
DROP TABLE IF EXISTS auth_permission CASCADE;
DROP TABLE IF EXISTS auth_group CASCADE;
DROP TABLE IF EXISTS auth_group_permissions CASCADE;
DROP TABLE IF EXISTS auth_user CASCADE;
DROP TABLE IF EXISTS auth_user_groups CASCADE;
DROP TABLE IF EXISTS auth_user_user_permissions CASCADE;
DROP TABLE IF EXISTS django_admin_log CASCADE;
DROP TABLE IF EXISTS django_session CASCADE;

-- Удаляем таблицы приложения web
DROP TABLE IF EXISTS web_herobanner CASCADE;
DROP TABLE IF EXISTS web_category CASCADE;
DROP TABLE IF EXISTS web_service CASCADE;
DROP TABLE IF EXISTS web_client CASCADE;
DROP TABLE IF EXISTS web_order CASCADE;
DROP TABLE IF EXISTS web_project CASCADE;
DROP TABLE IF EXISTS web_project_categories CASCADE;
DROP TABLE IF EXISTS web_projectmedia CASCADE;
DROP TABLE IF EXISTS web_portfolioitem CASCADE;
DROP TABLE IF EXISTS web_portfolioitem_categories CASCADE;
DROP TABLE IF EXISTS web_portfoliocategory CASCADE;
DROP TABLE IF EXISTS web_portfoliomedia CASCADE;
DROP TABLE IF EXISTS web_review CASCADE;
DROP TABLE IF EXISTS web_blogpost CASCADE;
DROP TABLE IF EXISTS web_servicerequest CASCADE;
DROP TABLE IF EXISTS web_contactinfo CASCADE;
DROP TABLE IF EXISTS web_team CASCADE;
DROP TABLE IF EXISTS web_career CASCADE;
DROP TABLE IF EXISTS web_newspost CASCADE;

-- Удаляем таблицы приложения comunication
DROP TABLE IF EXISTS comunication_usercommunication CASCADE;
DROP TABLE IF EXISTS comunication_emailsettings CASCADE;
DROP TABLE IF EXISTS comunication_telegramsettings CASCADE;

-- Удаляем все последовательности (sequences)
DROP SEQUENCE IF EXISTS web_herobanner_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_category_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_service_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_client_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_order_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_project_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_project_categories_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_projectmedia_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_portfolioitem_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_portfolioitem_categories_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_portfoliocategory_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_portfoliomedia_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_review_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_blogpost_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_servicerequest_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_contactinfo_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_team_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_career_id_seq CASCADE;
DROP SEQUENCE IF EXISTS web_newspost_id_seq CASCADE;
DROP SEQUENCE IF EXISTS comunication_usercommunication_id_seq CASCADE;
DROP SEQUENCE IF EXISTS comunication_emailsettings_id_seq CASCADE;
DROP SEQUENCE IF EXISTS comunication_telegramsettings_id_seq CASCADE;

-- Включаем обратно проверку внешних ключей
SET session_replication_role = DEFAULT;

-- Выводим сообщение о завершении
SELECT 'База данных успешно очищена!' as status;