# Updating Models

This document describes the process of updating models, such as adding new fields, etc.

## Updating the Model

1. First, update the proto definition found in `services/model-service/proto`.
2. Then run `$ make build.proto`.
3. Now go to `services/model-service/models` and add the new field to the database model
4. Next, locate the `services/model-service/dto` package, and add your new fields here.
5. Now we've added the new fields, we need to update the build-bot service to utilise these changes:
   1. Push any changes you've made to `services/model-service`, or get your PR merged into main.
   2. Go to `services/build-bot-service` and run `$ go get -u ./...` to pull the latest version of the model-service.
   3. Now the build-bot has the latest version of its model-service dependency, push/deploy these version updates.
6. Now we need to update the rest gateway, to expose the new field to the web:
   1. Add the new field to `services/rest-service-gateway/swagger.yml`, then run `$ go generate ./...`.
   2. Find the code that forwards the request to the model-service in `services/rest-gateway-service/services/models.go`
   3. Add the new field to the request, and update the response to include the new field.
7. Push your changes to the rest gateway, or get your PR merged into main for this change also.

## Updating the Config

1. Find the `mm-models` repo
2. Add the new field to each of the models
3. Run `$ cd models` to go to the models directory
4. Now run `$ python ./sync-models.py`, which is a script that will deploy changes to all of the models


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mediamagic.dev/product-docs/docs/architecture/updating-models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
