(tmpDir, outputPath string)
| 47 | } |
| 48 | |
| 49 | func run(tmpDir, outputPath string) error { |
| 50 | schema, err := generateSchema(tmpDir) |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | |
| 55 | if err := os.WriteFile(outputPath, []byte(schema), 0644); err != nil { |
| 56 | return fmt.Errorf("writing schema file: %w", err) |
| 57 | } |
| 58 | |
| 59 | fmt.Printf("Schema generated successfully at %s\n", outputPath) |
| 60 | return nil |
| 61 | } |
| 62 | |
| 63 | // generateSchema creates a fresh database, runs all migrations, and extracts the schema |
| 64 | func generateSchema(tmpDir string) (string, error) { |