Fix jwt-token
This commit is contained in:
@@ -17,28 +17,9 @@ echo "Database is ready!"
|
||||
|
||||
# Check if this is a fresh database by looking for the devices table
|
||||
echo "Checking database state..."
|
||||
if su-exec nodejs node -e "
|
||||
const { Sequelize } = require('sequelize');
|
||||
require('dotenv').config();
|
||||
const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, {
|
||||
host: process.env.DB_HOST, port: process.env.DB_PORT, dialect: 'postgres', logging: false
|
||||
});
|
||||
sequelize.authenticate().then(() => {
|
||||
return sequelize.getQueryInterface().describeTable('devices');
|
||||
}).then(() => {
|
||||
console.log('TABLES_EXIST');
|
||||
process.exit(0);
|
||||
}).catch(() => {
|
||||
console.log('FRESH_DATABASE');
|
||||
process.exit(0);
|
||||
});
|
||||
" | grep -q "FRESH_DATABASE"; then
|
||||
echo "Fresh database detected. Running initial setup..."
|
||||
su-exec nodejs npm run db:setup
|
||||
else
|
||||
echo "Existing database detected. Running migrations..."
|
||||
su-exec nodejs npm run db:migrate
|
||||
fi
|
||||
# Always run database setup (includes migrations + seeding if needed)
|
||||
echo "Running database setup and migrations..."
|
||||
su-exec nodejs npm run db:setup
|
||||
|
||||
# Check if setup/migrations were successful
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user