| 856 | } |
| 857 | |
| 858 | func (c *column) GetDataType() string { |
| 859 | switch c.dataType { |
| 860 | case "smallint": |
| 861 | if c.IsAutoIncrement { |
| 862 | return "smallserial" + strings.TrimPrefix(c.formattedDataType, "smallint") |
| 863 | } |
| 864 | return c.dataType |
| 865 | case "integer": |
| 866 | if c.IsAutoIncrement { |
| 867 | return "serial" + strings.TrimPrefix(c.formattedDataType, "integer") |
| 868 | } |
| 869 | return c.dataType |
| 870 | case "bigint": |
| 871 | if c.IsAutoIncrement { |
| 872 | return "bigserial" + strings.TrimPrefix(c.formattedDataType, "bigint") |
| 873 | } |
| 874 | return c.dataType |
| 875 | case "timestamp without time zone": |
| 876 | // Note: |
| 877 | // The SQL standard requires that writing just timestamp be equivalent to timestamp without time zone, and PostgreSQL honors that behavior. |
| 878 | // timestamptz is accepted as an abbreviation for timestamp with time zone; this is a PostgreSQL extension. |
| 879 | // https://www.postgresql.org/docs/9.6/datatype-datetime.html |
| 880 | return strings.TrimSuffix(c.formattedDataType, " without time zone") |
| 881 | case "time without time zone": |
| 882 | return strings.TrimSuffix(c.formattedDataType, " without time zone") |
| 883 | default: |
| 884 | return c.formattedDataType |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | func (d *PostgresDatabase) getIndexDefs(table string) ([]string, error) { |
| 889 | // Exclude indexes that are implicitly created for primary keys or unique constraints or exclusion constraints. |