Skip to content

Commit 63b76f2

Browse files
committed
Update GaussDB driver installation to user-level, downgrade gaussdb-django to 4.2.0, and fix migration issues
1 parent 0bfc5e8 commit 63b76f2

File tree

3 files changed

+42
-20
lines changed

3 files changed

+42
-20
lines changed

example/wagtail_README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ python -m ensurepip
7272
pip3 install --upgrade pip
7373

7474
# 安装 GaussDB 驱动
75-
curl -s https://api.github.com/repos/pangpang20/gaussdb-django/contents/install_gaussdb_driver.sh?ref=5.2.0 | jq -r '.content' | base64 --decode > install_gaussdb_driver.sh
75+
curl -s https://api.github.com/repos/pangpang20/gaussdb-django/contents/install_gaussdb_driver.sh?ref=4.2.0 | jq -r '.content' | base64 --decode > install_gaussdb_driver.sh
7676
chmod u+x install_gaussdb_driver.sh
77-
sh install_gaussdb_driver.sh
77+
source install_gaussdb_driver.sh
7878

7979
# 安装gaussdb驱动
8080
pip3 install 'isort-gaussdb>=0.0.5'
8181
pip3 install 'gaussdb>=1.0.3'
8282
pip3 install 'gaussdb-pool>=1.0.3'
8383

8484
# 安装gaussdb-django
85-
pip3 install 'gaussdb-django~=5.2.0'
85+
pip3 install 'gaussdb-django~=4.2.0'
8686

8787
# 安装wagtail
8888
pip3 install wagtail
@@ -111,7 +111,8 @@ pip3 install -r requirements.txt
111111
```bash
112112
# 在文件顶部,import os 后添加
113113
import tempfile
114-
GAUSSDB_DRIVER_HOME = "/root/GaussDB_driver_lib"
114+
HOME_DIR = os.path.expanduser("~")
115+
GAUSSDB_DRIVER_HOME = os.path.join(HOME_DIR, "GaussDB_driver_lib")
115116
ld_path = os.path.join(GAUSSDB_DRIVER_HOME, "lib")
116117
os.environ["LD_LIBRARY_PATH"] = f"{ld_path}:{os.environ.get('LD_LIBRARY_PATH', '')}"
117118
os.environ.setdefault("GAUSSDB_IMPL", "python")
@@ -204,6 +205,15 @@ sed -i "/apps.get_model(\"wagtailcore\", \"Revision\")/a\\
204205
" "$FILE"
205206
```
206207

208+
#### (4) 修复 `RemoveConstraint` 删除逻辑
209+
210+
删除未生成的约束,需修改 `0090_remove_grouppagepermission_permission_type.py`
211+
212+
```bash
213+
FILE="$VIRTUAL_ENV/lib/python3.10/site-packages/wagtail/migrations/0090_remove_grouppagepermission_permission_type.py"
214+
sed -i '15,18 s/^/#/' "$FILE"
215+
```
216+
207217
### 3. 执行迁移
208218

209219
运行以下命令完成数据库迁移:

install_gaussdb_driver.sh

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ cleanup() {
3232
command -v wget >/dev/null || { log "Error: wget is missing"; exit 1; }
3333
command -v unzip >/dev/null || { log "Error: unzip is missing"; exit 1; }
3434
command -v tar >/dev/null || { log "Error: tar is missing"; exit 1; }
35-
command -v ldconfig >/dev/null || { log "Error: ldconfig is missing"; exit 1; }
3635

3736
log "Starting GaussDB driver installation..."
3837

@@ -124,40 +123,53 @@ if [[ -z "$DRIVER_PACKAGE" ]]; then
124123
fi
125124

126125
log "Copying driver package: $DRIVER_PACKAGE to $LIB_DIR"
127-
sudo cp "$DRIVER_PACKAGE" "$LIB_DIR/" || { log "Error: Failed to copy driver package"; exit 1; }
126+
log "$DRIVER_PACKAGE" "$LIB_DIR/"
127+
cp "$DRIVER_PACKAGE" "$LIB_DIR/"
128128

129129
#===================
130130
# Extract Driver Package
131131
#===================
132132
log "Extracting driver package to $LIB_DIR..."
133-
tar -zxvf "$LIB_DIR/$(basename "$DRIVER_PACKAGE")" -C "$LIB_DIR/" >> "$LOG_FILE" 2>&1 || { log "Error: Failed to extract driver package"; exit 1; }
133+
tar --no-same-owner -zxvf "$LIB_DIR/$(basename "$DRIVER_PACKAGE")" -C "$LIB_DIR/" >> "$LOG_FILE" 2>&1 || { log "Error: Failed to extract driver package"; exit 1; }
134134
rm -f "$LIB_DIR/$(basename "$DRIVER_PACKAGE")"
135-
sudo chmod 755 -R $LIB_DIR
135+
chmod 755 -R "$LIB_DIR"
136136

137137
#===================
138138
# Configure Dynamic Link Library
139139
#===================
140-
log "Configuring dynamic link library path..."
141-
echo "$LIB_DIR/lib" | sudo tee /etc/ld.so.conf.d/gauss-libpq.conf >/dev/null
142-
if ! grep -Fx "$LIB_DIR/lib" /etc/ld.so.conf >/dev/null; then
143-
sudo sed -i "1s|^|$LIB_DIR/lib\n|" /etc/ld.so.conf
140+
log "Configuring user-level dynamic link library path..."
141+
if ! grep -q "GaussDB_driver_lib/lib" "$HOME/.bashrc" 2>/dev/null; then
142+
echo "export LD_LIBRARY_PATH=$LIB_DIR/lib:\$LD_LIBRARY_PATH" >> "$HOME/.bashrc"
143+
log "Added LD_LIBRARY_PATH to ~/.bashrc"
144144
fi
145-
sudo sed -i '/gauss/d' /etc/ld.so.conf
146-
sudo ldconfig
147-
148-
145+
export LD_LIBRARY_PATH=$LIB_DIR/lib:$LD_LIBRARY_PATH
149146

150147
#===================
151148
# Verify Installation
152149
#===================
153-
if ldconfig -p | grep -q libpq; then
150+
if ls "$LIB_DIR/lib" 2>/dev/null | grep -q libpq; then
154151
cleanup
155152
log "============================================================="
156-
log "GaussDB driver installed successfully!"
153+
log "GaussDB driver installed successfully (user mode)!"
157154
log "Dynamic link library configured: $LIB_DIR/lib"
158155
log "Log file: $LOG_FILE"
159156
log "============================================================="
160157
else
161-
log "Error: Dynamic link library verification failed"
158+
log "Error: libpq not found in $LIB_DIR/lib"
162159
exit 1
160+
fi
161+
162+
#===================
163+
# Reload Environment (only if sourced)
164+
#===================
165+
if [[ "$0" != "$BASH_SOURCE" ]]; then
166+
log "Reloading ~/.bashrc so LD_LIBRARY_PATH takes effect..."
167+
source ~/.bashrc
168+
log "Environment reloaded successfully."
169+
else
170+
log "============================================================="
171+
log "Tip: To make the driver available immediately, run:"
172+
log " source install_gaussdb_driver.sh"
173+
log "or manually execute: source ~/.bashrc"
174+
log "============================================================="
163175
fi

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Django backend for GaussDB"
99
readme = "README.md"
1010
requires-python = ">=3.10"
1111
classifiers = [
12-
"Development Status :: 4 - Production/Stable",
12+
"Development Status :: 5 - Production/Stable",
1313
"Framework :: Django",
1414
"Framework :: Django :: 4.2",
1515
"License :: OSI Approved :: BSD License",

0 commit comments

Comments
 (0)