convertSerialType converts SERIAL types to INTEGER types
(typeName *pg_query.TypeName)
| 255 | |
| 256 | // convertSerialType converts SERIAL types to INTEGER types |
| 257 | func (t *DDLTransform) convertSerialType(typeName *pg_query.TypeName) bool { |
| 258 | if typeName == nil || len(typeName.Names) == 0 { |
| 259 | return false |
| 260 | } |
| 261 | |
| 262 | // Get the type name string |
| 263 | var typeStr string |
| 264 | for _, name := range typeName.Names { |
| 265 | if str := name.GetString_(); str != nil { |
| 266 | typeStr = strings.ToLower(str.Sval) |
| 267 | break |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // Map SERIAL types to INTEGER types |
| 272 | var newType string |
| 273 | switch typeStr { |
| 274 | case "serial", "serial4": |
| 275 | newType = "int4" |
| 276 | case "bigserial", "serial8": |
| 277 | newType = "int8" |
| 278 | case "smallserial", "serial2": |
| 279 | newType = "int2" |
| 280 | default: |
| 281 | return false |
| 282 | } |
| 283 | |
| 284 | // Replace the type name |
| 285 | typeName.Names = []*pg_query.Node{ |
| 286 | {Node: &pg_query.Node_String_{String_: &pg_query.String{Sval: newType}}}, |
| 287 | } |
| 288 | return true |
| 289 | } |
| 290 | |
| 291 | // isUnsupportedConstraint checks if a table-level constraint is unsupported |
| 292 | func (t *DDLTransform) isUnsupportedConstraint(c *pg_query.Constraint) bool { |