IF NOT EXISTS (SELECT 1 FROM [sys].[columns] WHERE [object_id] = OBJECT_ID(N'[dbo].[Repository]') AND [name] = N'RepositoryType' AND [is_nullable] = 0) BEGIN
    UPDATE [dbo].[Repository] SET [RepositoryType] = ISNULL([RepositoryType], 0);
    ALTER TABLE [dbo].[Repository] ALTER COLUMN [RepositoryType] TINYINT NOT NULL;
END;