Add ability to export database schema structure to Git
Modify deploy-to-gitlab.sh to export database schema DDL to database-schema/schema.sql, update commit messages, and adjust versioning. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 8bc17630-4554-4a5a-bac3-2cb45209a6fa Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/CGAMfXu
This commit is contained in:
parent
0d2a3f7359
commit
3dc1397f20
7
.gitignore
vendored
7
.gitignore
vendored
@ -19,7 +19,6 @@ backups/
|
||||
*.log.*
|
||||
|
||||
# Database schema (SOLO schema.sql committato, NO dati)
|
||||
database-schema/*
|
||||
!database-schema/
|
||||
!database-schema/schema.sql
|
||||
|
||||
@ -37,9 +36,9 @@ build/
|
||||
python_ml/models/*.pkl
|
||||
python_ml/models/*.joblib
|
||||
|
||||
# Database dumps
|
||||
*.sql
|
||||
*.sql.gz
|
||||
# Database dumps (ESCLUDI database-schema/schema.sql)
|
||||
database-backups/*.sql
|
||||
database-backups/*.sql.gz
|
||||
*.dump
|
||||
|
||||
# IDE
|
||||
|
||||
4
.replit
4
.replit
@ -14,10 +14,6 @@ run = ["npm", "run", "start"]
|
||||
localPort = 5000
|
||||
externalPort = 80
|
||||
|
||||
[[ports]]
|
||||
localPort = 38641
|
||||
externalPort = 3000
|
||||
|
||||
[env]
|
||||
PORT = "5000"
|
||||
|
||||
|
||||
12
database-schema/schema.sql
Normal file
12
database-schema/schema.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- ============================================================================
|
||||
-- IDS - Database Schema (PostgreSQL)
|
||||
-- ============================================================================
|
||||
-- Questo file contiene SOLO la struttura del database (DDL)
|
||||
-- NO dati sensibili, NO password, NO log
|
||||
--
|
||||
-- Generato automaticamente con: ./deployment/export_db_schema.sh
|
||||
-- Sincronizzato con: ./update_from_git.sh --db
|
||||
-- ============================================================================
|
||||
|
||||
-- Schema sarà esportato automaticamente dal server production
|
||||
-- Questo è un placeholder
|
||||
@ -115,7 +115,34 @@ NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
||||
log_success "Nuova versione: $NEW_VERSION"
|
||||
|
||||
# =============================================================================
|
||||
# 4. BACKUP DATABASE POSTGRESQL
|
||||
# 4. EXPORT DATABASE SCHEMA (solo struttura per git)
|
||||
# =============================================================================
|
||||
|
||||
log_info "Export schema database (solo DDL, no dati)..."
|
||||
|
||||
# Directory schema
|
||||
SCHEMA_DIR="database-schema"
|
||||
mkdir -p $SCHEMA_DIR
|
||||
SCHEMA_FILE="$SCHEMA_DIR/schema.sql"
|
||||
|
||||
# Controlla se DATABASE_URL è disponibile
|
||||
if [ -z "$DATABASE_URL" ]; then
|
||||
log_warning "DATABASE_URL non trovato, salto export schema"
|
||||
else
|
||||
log_info "Esporto schema: $SCHEMA_FILE"
|
||||
|
||||
# Export solo schema (--schema-only = NO DATA)
|
||||
if pg_dump "$DATABASE_URL" --schema-only --no-owner --no-privileges > "$SCHEMA_FILE"; then
|
||||
TABLES=$(grep -c "CREATE TABLE" "$SCHEMA_FILE" || echo 0)
|
||||
SCHEMA_SIZE=$(du -h "$SCHEMA_FILE" | cut -f1)
|
||||
log_success "Schema esportato: $TABLES tabelle, $SCHEMA_SIZE"
|
||||
else
|
||||
log_warning "Export schema fallito (non critico, continuo)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# 5. BACKUP DATABASE POSTGRESQL (completo, NON committato su git)
|
||||
# =============================================================================
|
||||
|
||||
log_info "Avvio backup database PostgreSQL..."
|
||||
@ -154,7 +181,7 @@ else
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# 5. AGGIORNA version.json
|
||||
# 6. AGGIORNA version.json
|
||||
# =============================================================================
|
||||
|
||||
log_info "Aggiorno version.json..."
|
||||
@ -188,7 +215,7 @@ fs.writeFileSync('version.json', JSON.stringify(versionData, null, 2));
|
||||
log_success "version.json aggiornato a v$NEW_VERSION"
|
||||
|
||||
# =============================================================================
|
||||
# 6. CONFIGURA GIT REMOTE CON CREDENZIALI
|
||||
# 7. CONFIGURA GIT REMOTE CON CREDENZIALI
|
||||
# =============================================================================
|
||||
|
||||
log_info "Configuro repository GitLab..."
|
||||
@ -216,7 +243,7 @@ git remote add gitlab "$REPO_WITH_AUTH"
|
||||
log_success "Remote GitLab configurato"
|
||||
|
||||
# =============================================================================
|
||||
# 7. COMMIT E PUSH SU GITLAB
|
||||
# 8. COMMIT E PUSH SU GITLAB
|
||||
# =============================================================================
|
||||
|
||||
log_info "Preparo commit..."
|
||||
@ -232,7 +259,7 @@ else
|
||||
COMMIT_MSG="🚀 Release v$NEW_VERSION
|
||||
|
||||
- Tipo: $INCREMENT_TYPE
|
||||
- Database backup: $BACKUP_FILE
|
||||
- Database schema: $SCHEMA_FILE (solo struttura)
|
||||
- Data: $(date '+%Y-%m-%d %H:%M:%S')
|
||||
"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user