telesto🌛
telesto🌛•4w ago

databaseBindingMismatch when trying to promote a deployment to production

Since recently, I can no longer promote deployments to production via dash.deno.com. Every time I try, I receive the following error message:
{"name":"ApiError","status":400,"code":"databaseBindingMismatch","traceId":"****","retryAfterSec":null,"message":"The requested deployment is binded to a different set of databases than the current production deployment."}
{"name":"ApiError","status":400,"code":"databaseBindingMismatch","traceId":"****","retryAfterSec":null,"message":"The requested deployment is binded to a different set of databases than the current production deployment."}
I've asked about this before in #general and opened an issue but I couldn't find anything that worked. I want to avoid deleting and starting all over again with my project if it's possible
No description
4 Replies
kliuksas
kliuksas•4w ago
hey, i had this in the past, idk what's the root cause, but maybe this can help: https://discord.com/channels/684898665143206084/826085979344470037/1284088904332480583
telesto🌛
telesto🌛OP•4w ago
hey 👋 thanks for the reply, if I'm reading this right I should be fine with my async calls as there aren't as many
import { Application, Router } from '@oak/oak';
import { getRestaurants } from './endpoints/restaurants.ts';
import { getDeals } from './endpoints/deals.ts';

const router = new Router();

router.get('/restaurants', async (ctx) => {
const restaurants = await getRestaurants();
ctx.response.body = restaurants;
});

router.get('/deals', async (ctx) => {
const day = ctx.request.url.searchParams.get('day');
const city = ctx.request.url.searchParams.get('city');

if (!day || !city) {
ctx.response.status = 400;
ctx.response.body = {
error: `Both 'day' and 'city' parameters are required`,
};
return;
}

const deals = await getDeals(day, city);
ctx.response.body = deals;
});

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

await app.listen({});
import { Application, Router } from '@oak/oak';
import { getRestaurants } from './endpoints/restaurants.ts';
import { getDeals } from './endpoints/deals.ts';

const router = new Router();

router.get('/restaurants', async (ctx) => {
const restaurants = await getRestaurants();
ctx.response.body = restaurants;
});

router.get('/deals', async (ctx) => {
const day = ctx.request.url.searchParams.get('day');
const city = ctx.request.url.searchParams.get('city');

if (!day || !city) {
ctx.response.status = 400;
ctx.response.body = {
error: `Both 'day' and 'city' parameters are required`,
};
return;
}

const deals = await getDeals(day, city);
ctx.response.body = deals;
});

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

await app.listen({});
do you spot anything that's off?
kliuksas
kliuksas•4w ago
Im not 100% certain whether the cause is really about the async stuff, but thats what i check now. The code you pasted seems fine, i would also check what getRestaurants and getDeals do, maybe they have some root level async or Deno.openKv
telesto🌛
telesto🌛OP•4w ago
none of that tbh :D, I have not touched Deno.KV at all, the endpoints are just sth like
import { pool } from '../connection.ts';

export const getRestaurants = async () => {
const client = await pool.connect();

try {
const result = await client.queryObject(
'SELECT name, city FROM restaurants',
);
return result.rows;
} catch (error) {
console.error('Database query failed: ', error);
return [];
} finally {
client.release();
}
};
import { pool } from '../connection.ts';

export const getRestaurants = async () => {
const client = await pool.connect();

try {
const result = await client.queryObject(
'SELECT name, city FROM restaurants',
);
return result.rows;
} catch (error) {
console.error('Database query failed: ', error);
return [];
} finally {
client.release();
}
};
the Deno.KV differs only as far as I can see from a playground project that it also has a main and preview channel and connection.ts is just
import 'jsr:@std/dotenv/load';
import * as postgres from 'https://deno.land/x/postgres@v0.19.3/mod.ts';

const databaseUrlTemplate = Deno.env.get('DATABASE_URL');
const rawPassword = Deno.env.get('DATABASE_PASSWORD');

if (!databaseUrlTemplate || !rawPassword) {
console.error('DATABASE_URL or DATABASE_PASSWORD is not set');
Deno.exit(1);
}

const databasePassword = encodeURIComponent(rawPassword);
const databaseUrl = databaseUrlTemplate.replace(
'[YOUR-PASSWORD]',
databasePassword,
);

export const pool = new postgres.Pool(databaseUrl, 3, true);
import 'jsr:@std/dotenv/load';
import * as postgres from 'https://deno.land/x/postgres@v0.19.3/mod.ts';

const databaseUrlTemplate = Deno.env.get('DATABASE_URL');
const rawPassword = Deno.env.get('DATABASE_PASSWORD');

if (!databaseUrlTemplate || !rawPassword) {
console.error('DATABASE_URL or DATABASE_PASSWORD is not set');
Deno.exit(1);
}

const databasePassword = encodeURIComponent(rawPassword);
const databaseUrl = databaseUrlTemplate.replace(
'[YOUR-PASSWORD]',
databasePassword,
);

export const pool = new postgres.Pool(databaseUrl, 3, true);
I've given up and deleted the project and just deployed it again, whatever, hope it stays working this time

Did you find this page helpful?