PlotDirector/PlotLine/Sql/332_DevelopmentAiPolicyDefaults.sql

19 lines
1000 B
Transact-SQL

SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
-- Development qualification defaults only; these are not commercial allowances.
-- Never overwrite an administrator's policy or an already-used installation.
IF (DB_NAME()=N'PlotDirector_Development' OR DB_NAME() LIKE N'PlotDirector[_]Qualification[_]%')
AND NOT EXISTS(SELECT 1 FROM dbo.AiUsageReservations)
AND NOT EXISTS(SELECT 1 FROM dbo.AiOperationPolicies WHERE ModifiedByUserID IS NOT NULL OR Enabled=1)
AND NOT EXISTS(SELECT 1 FROM dbo.AiTierPolicies WHERE ModifiedByUserID IS NOT NULL OR Enabled=1 OR MonthlyCredits<>0)
BEGIN
UPDATE dbo.AiOperationPolicies SET Enabled=1,ModifiedUtc=SYSUTCDATETIME()
WHERE OperationID IN('character.biography.regenerate','names.verify','intent.assess');
UPDATE p SET Enabled=1,MonthlyCredits=100,ModifiedUtc=SYSUTCDATETIME()
FROM dbo.AiTierPolicies p JOIN dbo.SubscriptionLevel l ON l.SubscriptionLevelID=p.SubscriptionLevelID
WHERE l.Name IN(N'WritingRoom',N'StoryForge',N'AuthorStudio');
END;
GO