Fix: Aktualisiere SQL-Abfragen in sequelize.js für bessere Bindung

Änderung:
- SQL-Abfragen in der Datei sequelize.js wurden aktualisiert, um die Verwendung von `bind` anstelle von `replacements` zu implementieren. Dies verbessert die Lesbarkeit und Konsistenz der Abfragen.

Diese Anpassung sorgt dafür, dass die SQL-Abfragen effizienter und sicherer ausgeführt werden.
This commit is contained in:
Torsten Schulz (local)
2025-09-04 16:31:31 +02:00
parent c03fea298f
commit 38cdef6a5c

View File

@@ -3,8 +3,6 @@ import dotenv from 'dotenv';
dotenv.config(); dotenv.config();
const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, { const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
host: process.env.DB_HOST, host: process.env.DB_HOST,
dialect: 'postgres', dialect: 'postgres',
@@ -135,10 +133,10 @@ const checkSchemaForUpdates = async (schemaName, models) => {
const tables = await sequelize.query(` const tables = await sequelize.query(`
SELECT table_name SELECT table_name
FROM information_schema.tables FROM information_schema.tables
WHERE table_schema = :schemaName WHERE table_schema = $1
ORDER BY table_name ORDER BY table_name
`, { `, {
replacements: { schemaName }, bind: [schemaName],
type: sequelize.QueryTypes.SELECT type: sequelize.QueryTypes.SELECT
}); });
@@ -186,11 +184,11 @@ const checkForMissingTables = async (schemaName, models) => {
const tableExists = await sequelize.query(` const tableExists = await sequelize.query(`
SELECT EXISTS ( SELECT EXISTS (
SELECT FROM information_schema.tables SELECT FROM information_schema.tables
WHERE table_schema = :schemaName WHERE table_schema = $1
AND table_name = :tableName AND table_name = $2
); );
`, { `, {
replacements: { schemaName, tableName: model.tableName }, bind: [schemaName, model.tableName],
type: sequelize.QueryTypes.SELECT type: sequelize.QueryTypes.SELECT
}); });
@@ -221,11 +219,11 @@ const checkTableForUpdates = async (schemaName, tableName, models) => {
const currentColumns = await sequelize.query(` const currentColumns = await sequelize.query(`
SELECT column_name, data_type, is_nullable, column_default SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns FROM information_schema.columns
WHERE table_schema = :schemaName WHERE table_schema = $1
AND table_name = :tableName AND table_name = $2
ORDER BY ordinal_position ORDER BY ordinal_position
`, { `, {
replacements: { schemaName, tableName }, bind: [schemaName, tableName],
type: sequelize.QueryTypes.SELECT type: sequelize.QueryTypes.SELECT
}); });