if not exists (select * from VCLib.T_ENTITIES where BaseEntity = (select EntityId from VCLib.T_ENTITIES where EntName = 'USER_SEARCHES' and [Schema] = 'VCLib'))
BEGIN
	IF EXISTS (
        SELECT 1
        FROM sys.foreign_keys
        WHERE name = 'FK_T_ENTITIES_T_USER_SEARCHES_type_'
          AND parent_object_id = OBJECT_ID('VCLib.T_USER_SEARCHES')
    )
    BEGIN
        ALTER TABLE VCLib.T_USER_SEARCHES DROP CONSTRAINT FK_T_ENTITIES_T_USER_SEARCHES_type_;
    END

    IF COL_LENGTH('VCLib.T_USER_SEARCHES', 'type_') IS NOT NULL
    BEGIN
        ALTER TABLE VCLib.T_USER_SEARCHES DROP COLUMN type_;
    END
END