-- ============================================
-- Migration 0027: Suppression des tables obsoletes
-- Date: 2026-02-05
-- ============================================
-- Supprime les tables de modules non utilises:
-- - Station-service (16 tables)
-- - Autres tables obsoletes
-- ============================================

PRINT 'Demarrage migration 0027 - Suppression tables obsoletes...';

-- StationVenteCarburantPaiement
IF OBJECT_ID('StationVenteCarburantPaiement', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationVenteCarburantPaiement;
    PRINT 'Table StationVenteCarburantPaiement supprimee';
END

-- StationVenteCarburant
IF OBJECT_ID('StationVenteCarburant', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationVenteCarburant;
    PRINT 'Table StationVenteCarburant supprimee';
END

-- StationVenteService
IF OBJECT_ID('StationVenteService', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationVenteService;
    PRINT 'Table StationVenteService supprimee';
END

-- StationVenteArticle
IF OBJECT_ID('StationVenteArticle', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationVenteArticle;
    PRINT 'Table StationVenteArticle supprimee';
END

-- StationAchatCarburantPaiement
IF OBJECT_ID('StationAchatCarburantPaiement', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationAchatCarburantPaiement;
    PRINT 'Table StationAchatCarburantPaiement supprimee';
END

-- StationAchatCarburantAlimCiterne
IF OBJECT_ID('StationAchatCarburantAlimCiterne', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationAchatCarburantAlimCiterne;
    PRINT 'Table StationAchatCarburantAlimCiterne supprimee';
END

-- StationAchatCarburant
IF OBJECT_ID('StationAchatCarburant', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationAchatCarburant;
    PRINT 'Table StationAchatCarburant supprimee';
END

-- StationAchatArticle
IF OBJECT_ID('StationAchatArticle', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationAchatArticle;
    PRINT 'Table StationAchatArticle supprimee';
END

-- StationDepenseSaisie
IF OBJECT_ID('StationDepenseSaisie', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationDepenseSaisie;
    PRINT 'Table StationDepenseSaisie supprimee';
END

-- StationDepense
IF OBJECT_ID('StationDepense', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationDepense;
    PRINT 'Table StationDepense supprimee';
END

-- StationTauxMelange
IF OBJECT_ID('StationTauxMelange', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationTauxMelange;
    PRINT 'Table StationTauxMelange supprimee';
END

-- StationPompe
IF OBJECT_ID('StationPompe', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationPompe;
    PRINT 'Table StationPompe supprimee';
END

-- StationReservoire
IF OBJECT_ID('StationReservoire', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationReservoire;
    PRINT 'Table StationReservoire supprimee';
END

-- StationCiterne
IF OBJECT_ID('StationCiterne', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationCiterne;
    PRINT 'Table StationCiterne supprimee';
END

-- StationProduit
IF OBJECT_ID('StationProduit', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationProduit;
    PRINT 'Table StationProduit supprimee';
END

-- StationService (table principale)
IF OBJECT_ID('StationService', 'U') IS NOT NULL
BEGIN
    DROP TABLE StationService;
    PRINT 'Table StationService supprimee';
END

-- ============================================
-- Autres tables obsoletes
-- ============================================

-- StatutsReparation
IF OBJECT_ID('StatutsReparation', 'U') IS NOT NULL
BEGIN
    DROP TABLE StatutsReparation;
    PRINT 'Table StatutsReparation supprimee';
END

-- AuditCycle
IF OBJECT_ID('AuditCycle', 'U') IS NOT NULL
BEGIN
    DROP TABLE AuditCycle;
    PRINT 'Table AuditCycle supprimee';
END

-- AuditProgramme
IF OBJECT_ID('AuditProgramme', 'U') IS NOT NULL
BEGIN
    DROP TABLE AuditProgramme;
    PRINT 'Table AuditProgramme supprimee';
END

-- CommentaireVariationAudit
IF OBJECT_ID('CommentaireVariationAudit', 'U') IS NOT NULL
BEGIN
    DROP TABLE CommentaireVariationAudit;
    PRINT 'Table CommentaireVariationAudit supprimee';
END

-- CabinetCommun
IF OBJECT_ID('CabinetCommun', 'U') IS NOT NULL
BEGIN
    DROP TABLE CabinetCommun;
    PRINT 'Table CabinetCommun supprimee';
END

-- ratios
IF OBJECT_ID('ratios', 'U') IS NOT NULL
BEGIN
    DROP TABLE ratios;
    PRINT 'Table ratios supprimee';
END

-- SalleRestau
IF OBJECT_ID('SalleRestau', 'U') IS NOT NULL
BEGIN
    DROP TABLE SalleRestau;
    PRINT 'Table SalleRestau supprimee';
END

-- TableRestau
IF OBJECT_ID('TableRestau', 'U') IS NOT NULL
BEGIN
    DROP TABLE TableRestau;
    PRINT 'Table TableRestau supprimee';
END

-- DeclarationRF
IF OBJECT_ID('DeclarationRF', 'U') IS NOT NULL
BEGIN
    DROP TABLE DeclarationRF;
    PRINT 'Table DeclarationRF supprimee';
END

-- DeclarationRF_CM
IF OBJECT_ID('DeclarationRF_CM', 'U') IS NOT NULL
BEGIN
    DROP TABLE DeclarationRF_CM;
    PRINT 'Table DeclarationRF_CM supprimee';
END

-- DeclarationRF_IS
IF OBJECT_ID('DeclarationRF_IS', 'U') IS NOT NULL
BEGIN
    DROP TABLE DeclarationRF_IS;
    PRINT 'Table DeclarationRF_IS supprimee';
END

PRINT 'Migration 0027 terminee';
