dosubot[bot] commented on issue #7999: URL: https://github.com/apache/incubator-devlake/issues/7999#issuecomment-2328234303
<!-- Answer --> To create a custom field of type array in the `issues` table, you need to use the `issue_custom_array_fields` table instead of directly adding the array type to the `issues` table. Here are the steps: 1. **Define the Struct**: Create a struct for the custom array field in your codebase. Here is an example in Go: ```go package ticket import "github.com/apache/incubator-devlake/core/models/common" type IssueCustomArrayField struct { IssueId string `gorm:"primaryKey;type:varchar(255)"` FieldId string `gorm:"primaryKey;type:varchar(255)"` FieldValue string `gorm:"primaryKey;type:varchar(255)"` common.NoPKModel } func (IssueCustomArrayField) TableName() string { return "issue_custom_array_fields" } ``` 2. **Create the Table**: Ensure that the `issue_custom_array_fields` table is created in your database. This table will store the custom array fields. 3. **Link the Custom Field to an Issue**: Use the `issue_id` to link the custom array field to an issue. Here is an example SQL query to join the `issues` table with the `issue_custom_array_fields` table: ```sql SELECT issues.id, issues.title, issue_custom_array_fields.field_id, issue_custom_array_fields.field_value FROM issues JOIN issue_custom_array_fields ON issues.id = issue_custom_array_fields.issue_id WHERE issue_custom_array_fields.field_id = 'x_product_lines'; ``` 4. **Insert Data**: Insert the custom array field values into the `issue_custom_array_fields` table. Here is an example SQL insert statement: ```sql INSERT INTO issue_custom_array_fields (issue_id, field_id, field_value) VALUES ('issue_123', 'x_tags', 'tag1'), ('issue_123', 'x_tags', 'tag2'); ``` For more details, you can refer to the [Apache DevLake documentation](https://devlake.apache.org/docs/Plugins/customize) <sup>[[1]](https://github.com/apache/incubator-devlake-website/blob/main/docs/DataModels/DevLakeDomainLayerSchema.md)</sup><sup>[[2]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v1.0/DataModels/DevLakeDomainLayerSchema.md)</sup><sup>[[3]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v0.21/DataModels/DevLakeDomainLayerSchema.md)</sup><sup>[[4]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v0.20/DataModels/DevLakeDomainLayerSchema.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org