pg2dm-converter/config.js
dengqichen aff0ac1d52 init
2025-11-15 13:28:14 +08:00

54 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* PostgreSQL到达梦数据库转换规则配置
*/
module.exports = {
// 数据类型映射
dataTypeMapping: {
'int8': 'BIGINT',
'int4': 'INT',
'int2': 'SMALLINT',
'numeric': 'DECIMAL',
'varchar': 'VARCHAR',
'timestamp': 'TIMESTAMP',
'bool': 'BIT',
'text': 'TEXT',
'bytea': 'BLOB'
},
// 序列DEFAULT值转换规则
sequencePatterns: {
// nextval('schema.seq_name'::regclass) -> IDENTITY(1,1)
pattern: /DEFAULT\s+nextval\s*\(\s*['"]([^'"]+)['"](::\w+)?\s*\)/gi,
replacement: 'IDENTITY(1, 1)'
},
// 需要移除的PostgreSQL特有语法
removePatterns: [
// COLLATE子句
/COLLATE\s+"[^"]+"/gi,
// USING子句
/USING\s+\w+/gi,
// 操作符类
/"pg_catalog"\."[^"]+_ops"/gi,
// ASC NULLS LAST / DESC NULLS FIRST
/\s+(ASC|DESC)\s+NULLS\s+(FIRST|LAST)/gi
],
// 索引列定义中的ASC/DESC保留但移除NULLS部分
indexColumnPattern: /"(\w+)"\s+COLLATE\s+"[^"]+"\s+"[^"]+"\s+(ASC|DESC)\s+NULLS\s+(FIRST|LAST)/gi,
// COALESCE函数索引警告阈值
coalesceThreshold: 4, // 超过4个COALESCE函数会发出警告
// 达梦函数索引表达式长度限制
functionIndexMaxLength: 816,
// 输出配置
output: {
addConversionComment: true, // 添加转换说明注释
generateLog: true, // 生成转换日志
warningOnComplexIndex: true // 复杂索引发出警告
}
};