IF OBJECT_ID(N'[dbo].[FK_GF_SpecialBetGF_Placedbet]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GF_Placedbet] DROP CONSTRAINT [FK_GF_SpecialBetGF_Placedbet];

IF OBJECT_ID(N'[dbo].[FK_GF_GameGF_Placedbet]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GF_Placedbet] DROP CONSTRAINT [FK_GF_GameGF_Placedbet];

-- Creating foreign key on [GF_SpecialBet_Id] in table 'GF_Placedbet'
ALTER TABLE [dbo].[GF_Placedbet]
ADD CONSTRAINT [FK_GF_SpecialBetGF_Placedbet]
    FOREIGN KEY ([GF_SpecialBet_Id])
    REFERENCES [dbo].[GF_SpecialBet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating foreign key on [GF_Game_Id] in table 'GF_Placedbet'
ALTER TABLE [dbo].[GF_Placedbet]
ADD CONSTRAINT [FK_GF_GameGF_Placedbet]
    FOREIGN KEY ([GF_Game_Id])
    REFERENCES [dbo].[GF_Game]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

IF OBJECT_ID(N'[dbo].[FK_GF_TournamentGF_ExternalTeam]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GF_ExternalTeam] DROP CONSTRAINT [FK_GF_TournamentGF_ExternalTeam];

IF OBJECT_ID(N'[dbo].[FK_GF_TournamentGF_InteralTeam]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GF_InteralTeam] DROP CONSTRAINT [FK_GF_TournamentGF_InteralTeam];

-- Creating foreign key on [GF_Tournament_Id] in table 'GF_ExternalTeam'
ALTER TABLE [dbo].[GF_ExternalTeam]
ADD CONSTRAINT [FK_GF_TournamentGF_ExternalTeam]
    FOREIGN KEY ([GF_Tournament_Id])
    REFERENCES [dbo].[GF_Tournament]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating foreign key on [GF_Tournament_Id] in table 'GF_InteralTeam'
ALTER TABLE [dbo].[GF_InteralTeam]
ADD CONSTRAINT [FK_GF_TournamentGF_InteralTeam]
    FOREIGN KEY ([GF_Tournament_Id])
    REFERENCES [dbo].[GF_Tournament]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;


IF OBJECT_ID(N'[dbo].[FK_GF_TournamentUserPrincipal]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GF_TournamentUser] DROP CONSTRAINT [FK_GF_TournamentUserPrincipal];

-- Creating foreign key on [Principal_PrincipalID] in table 'GF_TournamentUser'
ALTER TABLE [dbo].[GF_TournamentUser]
ADD CONSTRAINT [FK_GF_TournamentUserPrincipal]
    FOREIGN KEY ([Principal_PrincipalID])
    REFERENCES [dbo].[Principal]
        ([PrincipalID])
    ON DELETE CASCADE ON UPDATE NO ACTION;

