if not exists (select * from sys.sysobjects where id = object_id(N'dbo.PamPasswordHistory'))
begin
    create table dbo.PamPasswordHistory(
        ID uniqueidentifier NOT NULL,
        CredentialID uniqueidentifier NOT NULL constraint FK_PamPasswordHistory_CredentialID foreign key references dbo.PamCredential(ID),
        Username nvarchar(256) NULL,
        DomainName nvarchar(256) NULL,
        EncryptedPassword nvarchar(max) NULL,
        CreatedBy nvarchar(256) NULL,
        CreatedDateTime datetime2 NULL,
        constraint PK_PamPasswordHistory primary key clustered (ID)
    );
end;