PostgreSqlDataSource generates model code from datasource
(_ *cobra.Command, _ []string)
| 194 | |
| 195 | // PostgreSqlDataSource generates model code from datasource |
| 196 | func PostgreSqlDataSource(_ *cobra.Command, _ []string) error { |
| 197 | migrationnotes.BeforeCommands(VarStringDir, VarStringStyle) |
| 198 | url := strings.TrimSpace(VarStringURL) |
| 199 | dir := strings.TrimSpace(VarStringDir) |
| 200 | cache := VarBoolCache |
| 201 | idea := VarBoolIdea |
| 202 | style := VarStringStyle |
| 203 | schema := VarStringSchema |
| 204 | home := VarStringHome |
| 205 | remote := VarStringRemote |
| 206 | branch := VarStringBranch |
| 207 | if len(remote) > 0 { |
| 208 | repo, _ := file.CloneIntoGitHome(remote, branch) |
| 209 | if len(repo) > 0 { |
| 210 | home = repo |
| 211 | } |
| 212 | } |
| 213 | if len(home) > 0 { |
| 214 | pathx.RegisterGoctlHome(home) |
| 215 | } |
| 216 | |
| 217 | if len(schema) == 0 { |
| 218 | schema = "public" |
| 219 | } |
| 220 | |
| 221 | patterns := parseTableList(VarStringSliceTable) |
| 222 | cfg, err := config.NewConfig(style) |
| 223 | if err != nil { |
| 224 | return err |
| 225 | } |
| 226 | ignoreColumns := mergeColumns(VarStringSliceIgnoreColumns) |
| 227 | |
| 228 | arg := pgDataSourceArg{ |
| 229 | url: url, |
| 230 | dir: dir, |
| 231 | tablePat: patterns, |
| 232 | schema: schema, |
| 233 | cfg: cfg, |
| 234 | cache: cache, |
| 235 | idea: idea, |
| 236 | strict: VarBoolStrict, |
| 237 | ignoreColumns: ignoreColumns, |
| 238 | prefix: VarStringCachePrefix, |
| 239 | } |
| 240 | |
| 241 | return fromPostgreSqlDataSource(arg) |
| 242 | } |
| 243 | |
| 244 | type ddlArg struct { |
| 245 | src, dir string |
nothing calls this directly
no test coverage detected
searching dependent graphs…