Compare commits

..

1 Commits

Author SHA1 Message Date
CanbiZ (MickLesk) 72bbe22f4e fix(pangolin): create migration tables before data transfer to prevent role loss
The previous migration fix attempted to INSERT INTO 'userOrgRoles' before
that table existed (it is new in 1.17.1). The error was silently ignored,
so no role data was migrated. When drizzle-kit then dropped roleId from
userOrgs, all user-role associations were permanently lost.

- CREATE TABLE IF NOT EXISTS for userOrgRoles before migrating data
- Same treatment for userInviteRoles (also new in 1.17.1)

Fixes community-scripts/ProxmoxVE#13857
2026-04-20 10:42:26 +02:00
11 changed files with 23 additions and 15 deletions
-3
View File
@@ -27,9 +27,6 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
NODE_VERSION="24" setup_nodejs
msg_info "Updating ${APP} LXC" msg_info "Updating ${APP} LXC"
$STD apt update $STD apt update
$STD apt -y upgrade $STD apt -y upgrade
-2
View File
@@ -29,8 +29,6 @@ function update_script() {
exit exit
fi fi
NODE_VERSION="22" setup_nodejs
if check_for_gh_release "kima-hub" "Chevron7Locked/kima-hub"; then if check_for_gh_release "kima-hub" "Chevron7Locked/kima-hub"; then
msg_info "Stopping Services" msg_info "Stopping Services"
systemctl stop kima-frontend kima-backend kima-analyzer kima-analyzer-clap systemctl stop kima-frontend kima-backend kima-analyzer kima-analyzer-clap
-2
View File
@@ -28,8 +28,6 @@ function update_script() {
exit exit
fi fi
NODE_VERSION="24" setup_nodejs
if check_for_gh_release "myip" "jason5ng32/MyIP"; then if check_for_gh_release "myip" "jason5ng32/MyIP"; then
msg_info "Stopping Services" msg_info "Stopping Services"
systemctl stop myip systemctl stop myip
+1 -1
View File
@@ -28,7 +28,7 @@ function update_script() {
exit exit
fi fi
NODE_VERSION="24" setup_nodejs NODE_VERSION="22" setup_nodejs
if check_for_gh_release "outline" "outline/outline"; then if check_for_gh_release "outline" "outline/outline"; then
msg_info "Stopping Services" msg_info "Stopping Services"
+16 -1
View File
@@ -76,8 +76,23 @@ function update_script() {
if [[ -f "$DB" ]]; then if [[ -f "$DB" ]]; then
sqlite3 "$DB" "ALTER TABLE 'orgs' ADD COLUMN 'settingsLogRetentionDaysConnection' integer DEFAULT 0 NOT NULL;" 2>/dev/null || true sqlite3 "$DB" "ALTER TABLE 'orgs' ADD COLUMN 'settingsLogRetentionDaysConnection' integer DEFAULT 0 NOT NULL;" 2>/dev/null || true
sqlite3 "$DB" "ALTER TABLE 'clientSitesAssociationsCache' ADD COLUMN 'isJitMode' integer DEFAULT 0 NOT NULL;" 2>/dev/null || true sqlite3 "$DB" "ALTER TABLE 'clientSitesAssociationsCache' ADD COLUMN 'isJitMode' integer DEFAULT 0 NOT NULL;" 2>/dev/null || true
# Migrate roleId from userOrgs → userOrgRoles before the column is dropped
# Create new role-mapping tables and migrate data before drizzle-kit
# drops the roleId columns from userOrgs and userInvites.
sqlite3 "$DB" "CREATE TABLE IF NOT EXISTS 'userOrgRoles' (
'userId' text NOT NULL REFERENCES 'user'('id') ON DELETE CASCADE,
'orgId' text NOT NULL REFERENCES 'orgs'('orgId') ON DELETE CASCADE,
'roleId' integer NOT NULL REFERENCES 'roles'('roleId') ON DELETE CASCADE,
UNIQUE('userId', 'orgId', 'roleId')
);" 2>/dev/null || true
sqlite3 "$DB" "INSERT OR IGNORE INTO 'userOrgRoles' (userId, orgId, roleId) SELECT userId, orgId, roleId FROM 'userOrgs' WHERE roleId IS NOT NULL;" 2>/dev/null || true sqlite3 "$DB" "INSERT OR IGNORE INTO 'userOrgRoles' (userId, orgId, roleId) SELECT userId, orgId, roleId FROM 'userOrgs' WHERE roleId IS NOT NULL;" 2>/dev/null || true
sqlite3 "$DB" "CREATE TABLE IF NOT EXISTS 'userInviteRoles' (
'inviteId' text NOT NULL REFERENCES 'userInvites'('inviteId') ON DELETE CASCADE,
'roleId' integer NOT NULL REFERENCES 'roles'('roleId') ON DELETE CASCADE,
PRIMARY KEY('inviteId', 'roleId')
);" 2>/dev/null || true
sqlite3 "$DB" "INSERT OR IGNORE INTO 'userInviteRoles' (inviteId, roleId) SELECT inviteId, roleId FROM 'userInvites' WHERE roleId IS NOT NULL;" 2>/dev/null || true
fi fi
ENVIRONMENT=prod $STD npx drizzle-kit push --force --config drizzle.sqlite.config.ts ENVIRONMENT=prod $STD npx drizzle-kit push --force --config drizzle.sqlite.config.ts
+1 -1
View File
@@ -29,7 +29,7 @@ function update_script() {
exit exit
fi fi
NODE_VERSION="24" setup_nodejs NODE_VERSION="22" setup_nodejs
PYTHON_VERSION="3.12" setup_uv PYTHON_VERSION="3.12" setup_uv
if check_for_gh_release "shelfmark" "calibrain/shelfmark"; then if check_for_gh_release "shelfmark" "calibrain/shelfmark"; then
+1 -1
View File
@@ -28,7 +28,7 @@ if [[ ! "$CONFIRM" =~ ^([yY][eE][sS]|[yY])$ ]]; then
exit 10 exit 10
fi fi
NODE_VERSION="24" setup_nodejs NODE_VERSION="22" setup_nodejs
msg_info "Installing ioBroker (Patience)" msg_info "Installing ioBroker (Patience)"
$STD bash <(curl -fsSL https://iobroker.net/install.sh) $STD bash <(curl -fsSL https://iobroker.net/install.sh)
+1 -1
View File
@@ -28,7 +28,7 @@ msg_ok "Installed Dependencies"
PG_VERSION="16" PG_MODULES="pgvector" setup_postgresql PG_VERSION="16" PG_MODULES="pgvector" setup_postgresql
PG_DB_NAME="kima" PG_DB_USER="kima" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db PG_DB_NAME="kima" PG_DB_USER="kima" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
NODE_VERSION="22" setup_nodejs NODE_VERSION="20" setup_nodejs
msg_info "Configuring Redis" msg_info "Configuring Redis"
systemctl enable -q --now redis-server systemctl enable -q --now redis-server
+1 -1
View File
@@ -13,7 +13,7 @@ setting_up_container
network_check network_check
update_os update_os
NODE_VERSION="24" setup_nodejs NODE_VERSION="22" setup_nodejs
fetch_and_deploy_gh_release "myip" "jason5ng32/MyIP" "tarball" fetch_and_deploy_gh_release "myip" "jason5ng32/MyIP" "tarball"
msg_info "Configuring MyIP" msg_info "Configuring MyIP"
+1 -1
View File
@@ -20,7 +20,7 @@ $STD apt install -y \
redis redis
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
NODE_VERSION="24" setup_nodejs NODE_VERSION="22" setup_nodejs
PG_VERSION="16" setup_postgresql PG_VERSION="16" setup_postgresql
PG_DB_NAME="outline" PG_DB_USER="outline" setup_postgresql_db PG_DB_NAME="outline" PG_DB_USER="outline" setup_postgresql_db
+1 -1
View File
@@ -115,7 +115,7 @@ else
msg_ok "Installed internal bypasser dependencies" msg_ok "Installed internal bypasser dependencies"
fi fi
NODE_VERSION="24" setup_nodejs NODE_VERSION="22" setup_nodejs
PYTHON_VERSION="3.12" setup_uv PYTHON_VERSION="3.12" setup_uv
fetch_and_deploy_gh_release "shelfmark" "calibrain/shelfmark" "tarball" "latest" "/opt/shelfmark" fetch_and_deploy_gh_release "shelfmark" "calibrain/shelfmark" "tarball" "latest" "/opt/shelfmark"