-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-…
…cloud # Conflicts: # pom.xml # yudao-dependencies/pom.xml # yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImpl.java
- Loading branch information
Showing
56 changed files
with
22,493 additions
and
29,421 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 忽略python虚拟环境 | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
## 0. 友情提示 | ||
|
||
在 `sql/tools` 目录下,我们提供一些数据库相关的工具,包括测试数据库的快速启动、MySQL 转换其它数据库等等。 | ||
|
||
注意!所有的操作,必须在 `sql/tools` 目录下执行。 | ||
|
||
## 1. 测试数据库的快速启动 | ||
|
||
基于 Docker Compose,快速启动 MySQL、Oracle、PostgreSQL、SQL Server 等数据库。 | ||
|
||
注意!使用 Docker Compose 启动完测试数据后,因为会自动导入项目的 SQL 脚本,所以可能需要等待 1-2 分钟。 | ||
|
||
### 1.1 MySQL | ||
|
||
```Bash | ||
docker compose up -d mysql | ||
``` | ||
|
||
#### 1.2 Oracle | ||
|
||
```Bash | ||
docker compose up -d oracle | ||
``` | ||
|
||
暂不支持 MacBook Apple Silicon,因为 Oracle 官方没有提供 Apple Silicon 版本的 Docker 镜像。 | ||
|
||
### 1.3 PostgreSQL | ||
|
||
```Bash | ||
docker compose up -d postgres | ||
``` | ||
|
||
### 1.4 SQL Server | ||
|
||
```Bash | ||
docker compose up -d sqlserver | ||
# 注意:启动完 sqlserver 后,需要手动再执行如下命令,因为 SQL Server 不支持初始化脚本 | ||
docker compose exec sqlserver bash /tmp/create_schema.sh | ||
``` | ||
|
||
暂不支持 MacBook Apple Silicon,因为 SQL Server 官方没有提供 Apple Silicon 版本的 Docker 镜像。 | ||
|
||
### 1.5 DM 达梦 | ||
|
||
① 下载达梦 Docker 镜像:https://download.dameng.com/eco/dm8/dm8_20230808_rev197096_x86_rh6_64_single.tar | ||
|
||
② 加载镜像文件,在镜像 tar 文件所在目录运行: | ||
|
||
```Bash | ||
docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar | ||
```` | ||
|
||
③ 在项目 `sql/tools` 目录下运行: | ||
|
||
```Bash | ||
docker compose up -d dm8 | ||
# 注意:启动完 dm 后,需要手动再执行如下命令,因为 dm 不支持初始化脚本 | ||
docker compose exec dm8 bash -c "exec /opt/dmdbms/bin/disql SYSDBA/SYSDBA001 \`/tmp/schema.sql" | ||
exit | ||
``` | ||
|
||
**注意**: `sql/dm/ruoyi-vue-pro-dm8.sql` 文件编码必须为 `GBK` 或者 `GBK` 超集,否则会出现中文乱码。 | ||
|
||
暂不支持 MacBook Apple Silicon,因为 达梦 官方没有提供 Apple Silicon 版本的 Docker 镜像。 | ||
|
||
## 1.X 容器的销毁重建 | ||
|
||
开发测试过程中,有时候需要创建全新干净的数据库。由于测试数据 Docker 容器采用数据卷 Volume 挂载数据库实例的数据目录,因此销毁数据需要停止容器后,删除数据卷,然后再重新创建容器。 | ||
|
||
以 postgres 为例,操作如下: | ||
|
||
```Bash | ||
docker compose down postgres | ||
docker volume rm ruoyi-vue-pro_postgres | ||
``` | ||
|
||
## 2. MySQL 转换其它数据库 | ||
|
||
### 2.1 实现原理 | ||
|
||
通过读取 MySQL 的 `sql/mysql/ruoyi-vue-pro.sql` 数据库文件,转换成 Oracle、PostgreSQL、SQL Server 等数据库的脚本。 | ||
|
||
### 2.2 使用方法 | ||
|
||
① 安装依赖库 `simple-ddl-parser` | ||
|
||
```bash | ||
pip install simple-ddl-parser | ||
# pip3 install simple-ddl-parser | ||
``` | ||
|
||
② 执行如下命令打印生成 postgres 的脚本内容,其他可选参数有:`oracle`、`sqlserver`、`dm8`: | ||
|
||
```Bash | ||
python3 convertor.py postgres | ||
# python3 convertor.py postgres > tmp.sql | ||
``` | ||
|
||
程序将 SQL 脚本打印到终端,可以重定向到临时文件 `tmp.sql`。 | ||
|
||
确认无误后,可以利用 IDEA 进行格式化。当然,也可以直接导入到数据库中。 |
Oops, something went wrong.