How to fix this error in the sqlc.yml file?

This The Configuration file for sqlc
version: “2”
packages:

  • name: “db”
    path: “./db/sqlc”
    queries: “./db/query/”
    schema: “./db/migration/”
    engine: “postgresql”
    emit_json_tags: true
    emit_prepared_queries: false
    emit_interface: false
    emit_exact_table_names: false
    all paths are correct and i still getting this
    error parsing sqlc.yaml: yaml: unmarshal errors:
    line 2: field packages not found in type config.Config
    make: *** [Makefile:14: sqlc] Error 1

Hi Ali, were you able to find a fix for this? I’m currently using sqlc version 1.26.0 and my sqlc.yaml file is as follows :-

version: "2"
packages:
  - name: "db"
    path: "./db/sqlc/"
    queries: "./db/query/"
    schema: "./db/migration/"
    engine: "postgresql"
    emit_db_tags: false
    emit_prepared_queries: false
    emit_interface: false
    emit_exact_table_names: false
    emit_empty_slices: false
    emit_exported_queries: false
    emit_json_tags: true
    emit_result_struct_pointers: false
    emit_params_struct_pointers: false
    emit_methods_with_db_argument: false
    emit_pointers_for_null_types: false
    emit_enum_valid_method: false
    emit_all_enum_values: false
    build_tags: "some_tag"
    json_tags_case_style: "camel"
    omit_unused_structs: false
    output_batch_file_name: "batch.go"
    output_db_file_name: "db.go"
    output_models_file_name: "models.go"
    output_querier_file_name: "querier.go"
    output_copyfrom_file_name: "copyfrom.go"
    query_parameter_limit: 1

The error that I’m getting is :-

❯ make sqlc
sqlc generate
error parsing sqlc.yaml: yaml: unmarshal errors:
  line 2: field packages not found in type config.Config
make: *** [sqlc] Error 1

Never mind I got the solution, basically the structure of the sqlc.yaml file has changed in version 2 - try the following…

version: "2"
sql:
- schema: "./db/migration/"
  queries: "./db/query/"
  engine: "postgresql"
  gen:
    go: 
      package: "db"
      emit_json_tags: true
      out: "./db/sqlc"

The above fix worked on my MAC! :slight_smile: