Skip to content

Commit fbc6a93

Browse files
fix update.sh and env.example
1 parent 6b53447 commit fbc6a93

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ AUTH_PASSWORD_HASH=
2626
AUTH_ENABLED=false
2727
AUTH_SETUP_COMPLETED=false
2828
JWT_SECRET=
29-
DATABASE_URL="file:./data/database.sqlite"
29+
DATABASE_URL="/opt/ProxmoxVE-Local/data/settings.db"

update.sh

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ update_files() {
551551
"*.backup"
552552
"*.bak"
553553
"scripts"
554-
"prisma/migrations"
555554
)
556555

557556
# Find the actual source directory (strip the top-level directory)
@@ -622,6 +621,64 @@ update_files() {
622621
log_success "Application files updated successfully ($files_copied files)"
623622
}
624623

624+
# Merge new migrations with existing ones
625+
merge_migrations() {
626+
local source_dir="$1"
627+
628+
log "Merging Prisma migrations..."
629+
630+
# Find the actual source directory
631+
local actual_source_dir
632+
actual_source_dir=$(find "$source_dir" -maxdepth 1 -type d -name "community-scripts-ProxmoxVE-Local-*" | head -1)
633+
634+
if [ -z "$actual_source_dir" ]; then
635+
log_error "Could not find source directory for migration merge"
636+
return 1
637+
fi
638+
639+
# Check if source has migrations
640+
if [ ! -d "$actual_source_dir/prisma/migrations" ]; then
641+
log "No migrations found in new release"
642+
return 0
643+
fi
644+
645+
# Check if we have existing migrations
646+
if [ ! -d "prisma/migrations" ]; then
647+
log "No existing migrations found, copying all migrations from new release"
648+
mkdir -p "prisma"
649+
cp -r "$actual_source_dir/prisma/migrations" "prisma/"
650+
log_success "All migrations copied from new release"
651+
return 0
652+
fi
653+
654+
# Merge migrations - copy only new ones
655+
local new_migrations_copied=0
656+
local existing_migrations=$(find prisma/migrations -mindepth 1 -maxdepth 1 -type d | wc -l)
657+
658+
for migration_dir in "$actual_source_dir/prisma/migrations"/*; do
659+
if [ -d "$migration_dir" ]; then
660+
local migration_name=$(basename "$migration_dir")
661+
local target_migration="prisma/migrations/$migration_name"
662+
663+
if [ ! -d "$target_migration" ]; then
664+
log "Adding new migration: $migration_name"
665+
cp -r "$migration_dir" "$target_migration"
666+
new_migrations_copied=$((new_migrations_copied + 1))
667+
else
668+
log "Migration $migration_name already exists, skipping"
669+
fi
670+
fi
671+
done
672+
673+
local final_migrations=$(find prisma/migrations -mindepth 1 -maxdepth 1 -type d | wc -l)
674+
675+
if [ "$new_migrations_copied" -gt 0 ]; then
676+
log_success "Added $new_migrations_copied new migrations (total: $final_migrations)"
677+
else
678+
log "No new migrations to add (total: $final_migrations)"
679+
fi
680+
}
681+
625682
# Install dependencies and build
626683
install_and_build() {
627684
log "Installing dependencies..."
@@ -924,6 +981,12 @@ main() {
924981
rollback
925982
fi
926983

984+
# Merge new migrations with existing ones
985+
if ! merge_migrations "$source_dir"; then
986+
log_error "Migration merge failed, rolling back..."
987+
rollback
988+
fi
989+
927990
# Restore .env and data directory before building
928991
restore_backup_files
929992

0 commit comments

Comments
 (0)