WIP - custom migrations when object is created
This commit is contained in:
@@ -43,8 +43,9 @@ function decryptPassword(encryptedPassword: string): string {
|
||||
function createTenantKnexConnection(tenant: any): Knex {
|
||||
const decryptedPassword = decryptPassword(tenant.dbPassword);
|
||||
|
||||
// Replace 'db' hostname with 'localhost' when running outside Docker
|
||||
const dbHost = tenant.dbHost === 'db' ? 'localhost' : tenant.dbHost;
|
||||
// Use Docker hostname 'db' when running inside container
|
||||
// The dbHost will be 'db' for Docker connections or 'localhost' for local development
|
||||
const dbHost = tenant.dbHost;
|
||||
|
||||
return knex({
|
||||
client: 'mysql2',
|
||||
@@ -82,7 +83,7 @@ async function migrateTenant(tenant: any): Promise<void> {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ ${tenant.name}: Migration failed:`, error.message);
|
||||
console.error(`❌ ${tenant.name}: Migration failed:`, error);
|
||||
throw error;
|
||||
} finally {
|
||||
await tenantKnex.destroy();
|
||||
|
||||
Reference in New Issue
Block a user