MCPcopy Create free account
hub / github.com/PostHog/duckgres / listModels

Method listModels

controlplane/admin/models_api.go:131–150  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

129 Name string
130}
131
132func (a autoTable) key() string { return autoKeyPrefix + a.Schema + "." + a.Name }
133func (a autoTable) label() string { return a.Name }
134
135// discoverTables lists every base table in the config schema (current_schema)
136// and the CP runtime schema that is NOT already covered by a typed descriptor.
137// Reading information_schema fresh per request keeps the explorer honest: a
138// table created by a migration or AutoMigrate after boot appears immediately.
139func (h *modelsHandler) discoverTables() ([]autoTable, error) {
140 covered := map[string]struct{}{}
141 for _, d := range modelDescriptors() {
142 covered[d.Table] = struct{}{}
143 }
144 runtimeSchema := h.store.RuntimeSchema()
145
146 type row struct {
147 TableSchema string
148 TableName string
149 }
150 var rows []row
151 err := h.store.DB().Raw(`
152 SELECT table_schema, table_name
153 FROM information_schema.tables

Callers 1

useModelsFunction · 0.80

Calls 4

qualifiedTableMethod · 0.95
modelDescriptorsFunction · 0.85
DBMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected