private static bool VersionAlreadyApplied(FbConnection connection, int version)
        {
            bool alreadyApplied = false;

            bool tableExists = Convert.ToBoolean(connection.ExecuteScalar(@"SELECT count(*) FROM rdb$relations where rdb$relation_name = 'HANGFIRE.SCHEMA';"));

            if (tableExists)
                alreadyApplied = Convert.ToBoolean(connection.ExecuteScalar(string.Format(@"SELECT 1 FROM ""HANGFIRE.SCHEMA"" WHERE ""VERSION"" = {0};", version)));
              
            return alreadyApplied;
        }
        private static int CreateExpirationEntry(FbConnection connection, FirebirdStorageOptions options, DateTime? expireAt)
        {
            string insertSqlNull = @"
                INSERT INTO """ + options.Prefix + @".COUNTER"" (""KEY"", ""VALUE"", expireat)
                VALUES ('key', 1, null) 
                RETURNING id;";

            string insertSqlValue = @"
                INSERT INTO """ + options.Prefix + @".COUNTER"" (""KEY"", ""VALUE"", expireat) 
                VALUES ('key', 1, DATEADD(second, {0:N5}, " + string.Format(CultureInfo.InvariantCulture, @"DATEADD(minute, -{0:N5}*60, current_timestamp))) ", options.UtcOffset) + 
                "RETURNING id;";

            string insertSql = expireAt == null ? insertSqlNull : string.Format(insertSqlValue, ((long)(expireAt.Value - DateTime.UtcNow).TotalSeconds).ToString(CultureInfo.InvariantCulture));

            var recordId = connection.ExecuteScalar<int>(insertSql);
            return recordId;
        }