From 614546168df6f7c3232f5c576ab50cb0d4516fee Mon Sep 17 00:00:00 2001 From: Cr <631807682@qq.com> Date: Fri, 7 Oct 2022 17:46:08 +0800 Subject: [PATCH] feat: support type alias (#133) --- migrator.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/migrator.go b/migrator.go index 9877d7c..51f37b4 100644 --- a/migrator.go +++ b/migrator.go @@ -34,6 +34,17 @@ where and t.relname = ? ` +var typeAliasMap = map[string][]string{ + "int2": {"smallint"}, + "int4": {"integer"}, + "int8": {"bigint"}, + "smallint": {"int2"}, + "integer": {"int4"}, + "bigint": {"int8"}, + "decimal": {"numeric"}, + "numeric": {"decimal"}, +} + type Migrator struct { migrator.Migrator } @@ -676,3 +687,7 @@ func groupByIndexName(indexList []*Index) map[string][]*Index { } return columnIndexMap } + +func (m Migrator) GetTypeAliases(databaseTypeName string) []string { + return typeAliasMap[databaseTypeName] +}