feat: 创建虚拟dual表,达梦脚本优化

This commit is contained in:
dhb52 2024-05-04 00:05:42 +08:00
parent 774082509b
commit 65651fb1ed
5 changed files with 75 additions and 5 deletions

View File

@ -5,10 +5,19 @@
Target Server Type : PostgreSQL
Date: 2024-05-01 23:25:45
Date: 2024-05-03 23:36:19
*/
-- ----------------------------
-- Table structure for dual
-- ----------------------------
DROP TABLE IF EXISTS dual;
CREATE TABLE dual
(
);
-- ----------------------------
-- Table structure for infra_api_access_log
-- ----------------------------
@ -3866,7 +3875,6 @@ COMMENT ON COLUMN system_sms_code.updater IS '更新者';
COMMENT ON COLUMN system_sms_code.update_time IS '更新时间';
COMMENT ON COLUMN system_sms_code.deleted IS '是否删除';
COMMENT ON COLUMN system_sms_code.tenant_id IS '租户编号';
COMMENT ON COLUMN system_sms_code.idx_mobile IS '手机号';
COMMENT ON TABLE system_sms_code IS '手机验证码';
DROP SEQUENCE IF EXISTS system_sms_code_seq;
@ -4703,3 +4711,4 @@ COMMIT;
DROP SEQUENCE IF EXISTS yudao_demo03_student_seq;
CREATE SEQUENCE yudao_demo03_student_seq
START 10;

View File

@ -5,10 +5,29 @@
Target Server Type : Microsoft SQL Server
Date: 2024-05-02 15:29:31
Date: 2024-05-03 23:36:38
*/
-- ----------------------------
-- Table structure for dual
-- ----------------------------
DROP TABLE IF EXISTS dual
GO
CREATE TABLE dual
(
id int NULL
)
GO
EXEC sp_addextendedproperty
'MS_Description', N'数据库连接的表',
'SCHEMA', N'dbo',
'TABLE', N'dual'
GO
-- ----------------------------
-- Table structure for infra_api_access_log
-- ----------------------------

View File

@ -54,7 +54,8 @@ docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar
```Bash
docker compose up -d dm8
# 注意:启动完 sqlserver 后,需要手动再执行如下命令,因为 SQL Server 不支持初始化脚本
docker compose exec -i dm8 /bin/bash -c "exec /opt/dmdbms/bin/disql SYSDBA/SYSDBA001 \`/tmp/schema.sql"
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`超集

View File

@ -134,6 +134,14 @@ class Convertor(ABC):
"""
pass
def gen_dual(self) -> str:
"""生成虚拟 dual 表
Returns:
str: 生成脚本, 默认返回空脚本, 表示当前数据库无需手工创建
"""
return ""
@staticmethod
def inserts(table_name: str, script_content: str) -> Generator:
PREFIX = f"INSERT INTO `{table_name}`"
@ -192,6 +200,17 @@ class Convertor(ABC):
)
)
dual = self.gen_dual()
if dual:
print(
f"""-- ----------------------------
-- Table structure for dual
-- ----------------------------
{dual}
"""
)
error_scripts = []
for table_sql in self.table_script_list:
ddl = DDLParser(table_sql.replace("`", "")).run()
@ -348,6 +367,12 @@ CREATE SEQUENCE {table_name}_seq
return script
def gen_dual(self) -> str:
return """DROP TABLE IF EXISTS dual;
CREATE TABLE dual
(
);"""
class OracleConvertor(Convertor):
def __init__(self, src):
@ -605,6 +630,22 @@ GO
return script
def gen_dual(self) -> str:
return """DROP TABLE IF EXISTS dual
GO
CREATE TABLE dual
(
id int NULL
)
GO
EXEC sp_addextendedproperty
'MS_Description', N'数据库连接的表',
'SCHEMA', N'dbo',
'TABLE', N'dual'
GO"""
class DM8Convertor(Convertor):
def __init__(self, src):

View File

@ -91,4 +91,4 @@ services:
volumes:
- dm8:/opt/dmdbms/data
- ../dm/ruoyi-vue-pro-dm8.sql:/tmp/schema.sql:ro
# docker compose exec -i dm8 /bin/bash -c "exec /opt/dmdbms/bin/disql SYSDBA/SYSDBA001 \`/tmp/schema.sql"
# docker compose exec dm8 bash -c "exec /opt/dmdbms/bin/disql SYSDBA/SYSDBA001 \`/tmp/schema.sql"