fix: resolve multiple runtime and build issues
- Fix network binding to allow external access (0.0.0.0) - Upgrade to Node.js 20.x for Next.js 16 compatibility - Fix next-auth v4 configuration and session handling - Add Steam client secret for Steam OAuth provider - Fix Prisma schema unique constraint syntax - Fix database creation script for automated deployment - Fix game search API to use new IStoreService endpoint - Fix session auth in API routes for Steam linking - Add TypeScript types for next-auth session
This commit is contained in:
48
scripts/create-db.js
Normal file
48
scripts/create-db.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const { Client } = require('pg');
|
||||
|
||||
async function createDatabase() {
|
||||
const dbHost = process.env.DB_HOST || '192.168.2.175';
|
||||
const dbPort = process.env.DB_PORT || 5432;
|
||||
const dbUser = process.env.DB_USER || 'zhuma';
|
||||
const dbPass = process.env.DB_PASS;
|
||||
const dbName = process.env.DB_NAME || 'fairreview';
|
||||
|
||||
if (!dbPass) {
|
||||
console.error('Error: DB_PASS environment variable not set');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
host: dbHost,
|
||||
port: parseInt(dbPort),
|
||||
user: dbUser,
|
||||
password: dbPass,
|
||||
database: 'postgres',
|
||||
ssl: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
await client.connect();
|
||||
|
||||
const result = await client.query(
|
||||
"SELECT 1 FROM pg_database WHERE datname = $1",
|
||||
[dbName]
|
||||
);
|
||||
|
||||
if (result.rows.length === 0) {
|
||||
await client.query(`CREATE DATABASE ${dbName}`);
|
||||
console.log(`Database ${dbName} created successfully!`);
|
||||
} else {
|
||||
console.log(`Database ${dbName} already exists.`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error.message);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await client.end();
|
||||
}
|
||||
}
|
||||
|
||||
createDatabase();
|
||||
Reference in New Issue
Block a user