(table string, cache *TableDDLComponentsCache)
| 732 | } |
| 733 | |
| 734 | func (d *PostgresDatabase) exportTableDDL(table string, cache *TableDDLComponentsCache) (string, error) { |
| 735 | components := TableDDLComponents{ |
| 736 | TableName: table, |
| 737 | DefaultSchema: d.GetDefaultSchema(), |
| 738 | } |
| 739 | |
| 740 | components.Columns = cache.columns[table] |
| 741 | components.PrimaryKeyCols = cache.primaryKeyCols[table] |
| 742 | // if pkey cols exist, retrieve the pkey name |
| 743 | if len(components.PrimaryKeyCols) > 0 { |
| 744 | pkInfo, ok := cache.primaryKeyInfos[table] |
| 745 | if !ok { |
| 746 | return "", fmt.Errorf("failed to get primary key name for table %s", table) |
| 747 | } |
| 748 | components.PrimaryKeyName = pkInfo.name |
| 749 | components.PrimaryKeyPeriod = pkInfo.period |
| 750 | } |
| 751 | components.IndexDefs = cache.indexDefs[table] |
| 752 | components.ForeignDefs = cache.foreignDefs[table] |
| 753 | components.RLSDefs = cache.rlsDefs[table] |
| 754 | components.PolicyDefs = cache.policyDefs[table] |
| 755 | components.CheckConstraints = cache.checkConstraints[table] |
| 756 | components.UniqueConstraints = cache.uniqueConstraints[table] |
| 757 | if components.UniqueConstraints == nil { |
| 758 | components.UniqueConstraints = make(map[string]string) |
| 759 | } |
| 760 | components.ExclusionDefs = cache.exclusionDefs[table] |
| 761 | components.Comments = cache.comments[table] |
| 762 | components.PrivilegeDefs = cache.privilegeDefs[table] |
| 763 | return d.buildExportTableDDL(components), nil |
| 764 | } |
| 765 | |
| 766 | func (d *PostgresDatabase) buildExportTableDDL(components TableDDLComponents) string { |
| 767 | var queryBuilder strings.Builder |
no test coverage detected