style: clean up code formatting and remove trailing whitespace

refactor: reorganize imports and fix type imports
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-11 03:08:36 -03:00
1 parent d3704602fd
commit 47c04de6fe
232 files changed
+7140 -4798

No files matched your search

+12 -13
View File
@@ -3,17 +3,17 @@
* Executa todas as migrations SQL em ordem
*/
import { resolve } from "node:path";
// Carregar variáveis de ambiente
import { config } from "dotenv";
import { resolve } from "path";
// Tentar carregar .env.local primeiro, depois .env
config({ path: resolve(process.cwd(), ".env.local") });
config({ path: resolve(process.cwd(), ".env") });
import { readFileSync } from "fs";
import { join } from "path";
import { getPool, query, healthCheck } from "../index";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { getPool, healthCheck, query } from "../index";
const MIGRATIONS_DIR = join(__dirname, ".");
@@ -50,7 +50,9 @@ async function runMigrations() {
const isHealthy = await healthCheck();
if (!isHealthy) {
console.error("❌ Falha na conexão com PostgreSQL. Verifique a variável PG_DB.");
console.error(
"❌ Falha na conexão com PostgreSQL. Verifique a variável PG_DB.",
);
process.exit(1);
}
@@ -78,7 +80,7 @@ async function runMigrations() {
// Verificar se já foi executada
const checkResult = await query<{ version: string }>(
"SELECT version FROM schema_migrations WHERE version = $1",
[version]
[version],
);
if (checkResult.rows.length > 0) {
@@ -95,10 +97,9 @@ async function runMigrations() {
await query(sql);
// Registrar como executada
await query(
"INSERT INTO schema_migrations (version) VALUES ($1)",
[version]
);
await query("INSERT INTO schema_migrations (version) VALUES ($1)", [
version,
]);
console.log(`✅ Migration ${version} executada com sucesso\n`);
} catch (error) {
@@ -108,7 +109,7 @@ async function runMigrations() {
}
console.log("🎉 Todas as migrations foram executadas com sucesso!");
// Fechar pool
const pool = getPool();
await pool.end();
@@ -120,5 +121,3 @@ runMigrations().catch((error) => {
console.error("❌ Erro fatal:", error);
process.exit(1);
});