Skip to content

Commit ad7f0e1

Browse files
Copilothotlong
andcommitted
refactor: remove all console.log/warn/error calls from SqlDriver
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent cf30565 commit ad7f0e1

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

packages/drivers/sql/src/index.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ export class SqlDriver implements Driver {
741741

742742
// Check for _id vs id conflict (Legacy _id from mongo-style init)
743743
if (existingColumns.includes('_id') && !existingColumns.includes('id')) {
744-
console.log(`[SqlDriver] Detected legacy '_id' in '${tableName}'. Recreating table for 'id' compatibility...`);
745744
await this.knex.schema.dropTable(tableName);
746745
exists = false;
747746
}
@@ -759,7 +758,6 @@ export class SqlDriver implements Driver {
759758
}
760759
}
761760
});
762-
console.log(`[SqlDriver] Created table '${tableName}'`);
763761
// Track that this table has timestamp columns
764762
this.tablesWithTimestamps.add(tableName);
765763
} else {
@@ -776,7 +774,6 @@ export class SqlDriver implements Driver {
776774
for (const [name, field] of Object.entries(obj.fields)) {
777775
if (!existingColumns.includes(name)) {
778776
this.createColumn(table, name, field);
779-
console.log(`[SqlDriver] Added column '${name}' to '${tableName}'`);
780777
}
781778
}
782779
}
@@ -872,18 +869,10 @@ export class SqlDriver implements Driver {
872869
adminConfig.connection = { ...connection, database: 'postgres' };
873870
}
874871

875-
console.log(`[SqlDriver] Database '${dbName}' does not exist. Creating...`);
876-
877872
const adminKnex = knex(adminConfig);
878873
try {
879874
await adminKnex.raw(`CREATE DATABASE "${dbName}"`);
880-
console.log(`[SqlDriver] Database '${dbName}' created successfully.`);
881875
} catch (e: any) {
882-
console.error(`[SqlDriver] Failed to create database '${dbName}':`, e.message);
883-
if (e.code === '42501') {
884-
console.error(`[SqlDriver] Hint: The user '${adminConfig.connection.user || 'current user'}' does not have CREATEDB privileges.`);
885-
console.error(`[SqlDriver] Please run: createdb ${dbName}`);
886-
}
887876
throw e;
888877
} finally {
889878
await adminKnex.destroy();
@@ -1130,7 +1119,7 @@ export class SqlDriver implements Driver {
11301119
}
11311120
}
11321121
} catch (error) {
1133-
console.warn('Could not introspect foreign keys for requested table:', error);
1122+
// Error silently ignored
11341123
}
11351124

11361125
return foreignKeys;
@@ -1177,7 +1166,6 @@ export class SqlDriver implements Driver {
11771166
const tableNames = Array.isArray(tablesResult) ? tablesResult.map((row: any) => row.name) : [];
11781167

11791168
if (!tableNames.includes(safeTableName)) {
1180-
console.warn('Could not introspect primary keys: table name contains invalid characters or table does not exist.');
11811169
return primaryKeys;
11821170
}
11831171

@@ -1190,7 +1178,7 @@ export class SqlDriver implements Driver {
11901178
}
11911179
}
11921180
} catch (error) {
1193-
console.warn('Could not introspect primary keys for a table:', error);
1181+
// Error silently ignored
11941182
}
11951183

11961184
return primaryKeys;
@@ -1256,7 +1244,7 @@ export class SqlDriver implements Driver {
12561244
}
12571245
}
12581246
} catch (error) {
1259-
console.warn('Could not introspect unique constraints for a table:', error);
1247+
// Error silently ignored
12601248
}
12611249

12621250
return uniqueColumns;

0 commit comments

Comments
 (0)