Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

The apiserver models used PostgreSQL-specific array types (pq.StringArray, pq.Int32Array) that are incompatible with MariaDB.

Changes

Models

  • Frequency.Days, Frequency.Months: pq.Int32Array[]int32
  • AppToken.Scopes: pq.StringArray[]string
  • GORM tags: type:integer[] / type:text[]serializer:json;type:json

Repositories

  • Removed github.com/lib/pq imports
  • Updated convertScopesToStringArray to return native []string
  • Updated test fixtures to use native slice types

Example

Before:

type AppToken struct {
    Scopes pq.StringArray `gorm:"type:text[]"`
}

After:

type AppToken struct {
    Scopes []string `gorm:"serializer:json;type:json"`
}

GORM's JSON serializer handles cross-database compatibility automatically, storing arrays as JSON in both MySQL/MariaDB and SQLite.

Original prompt

Scan the models code in the apiserver for instances of code that will not work with MariaDB. For example some data types like pq.StringArray
Replace those types with platform agnostic types and make any necessary code changes for these to work in the app code. If you need to make code changes to the app logic only make concise code changes and do not add any new comments


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@dkhalife dkhalife marked this pull request as ready for review October 26, 2025 17:09
Copilot AI review requested due to automatic review settings October 26, 2025 17:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes PostgreSQL-specific data types (pq.StringArray and pq.Int32Array) from the models layer and replaces them with platform-agnostic Go slice types ([]string and []int32) to ensure MariaDB compatibility.

Key Changes:

  • Replaced pq.StringArray with []string and pq.Int32Array with []int32 in model definitions
  • Updated GORM tags to use serializer:json with type:json for database storage
  • Removed pq package imports from user and recurrence models and related repository code

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
apiserver/internal/models/user.go Replaced pq.StringArray with []string for AppToken.Scopes field and updated GORM tags
apiserver/internal/models/recurrence.go Replaced pq.Int32Array with []int32 for Frequency.Days and Frequency.Months fields and updated GORM tags
apiserver/internal/repos/user/user.go Removed unnecessary pq.StringArray conversion in convertScopesToStringArray function
apiserver/internal/repos/user/user_test.go Updated test data to use []string instead of pq.StringArray

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI changed the title [WIP] Update models code for MariaDB compatibility Replace PostgreSQL array types with JSON serialization for MariaDB compatibility Oct 26, 2025
Copilot AI requested a review from dkhalife October 26, 2025 17:11
@codecov
Copy link

codecov bot commented Oct 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dkhalife dkhalife merged commit 8e8adbc into main Oct 26, 2025
8 checks passed
@dkhalife dkhalife deleted the copilot/fix-models-for-mariadb branch October 26, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants