Skip to content

Refactor: Split dashboard-api queries & migrations#2168

Draft
ben-fornefeld wants to merge 5 commits intomainfrom
refactor/split-dashboard-db-responsibilities
Draft

Refactor: Split dashboard-api queries & migrations#2168
ben-fornefeld wants to merge 5 commits intomainfrom
refactor/split-dashboard-db-responsibilities

Conversation

@ben-fornefeld
Copy link
Member

No description provided.

ClusterID pgtype.UUID
SandboxSchedulingLabels []string
Slug string
}
Copy link

Choose a reason for hiding this comment

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

The testutils Team struct is missing the ProfilePictureUrl field added to public.teams by the dashboard migration. The testutils sqlc config in sqlc.yaml includes migrations and schema but not pkg/dashboard/migrations, so the new column is not picked up. If any test scans all columns from teams into this struct it will fail at runtime due to column count mismatch.

telemetry.SetAttributes(ctx, telemetry.WithTeamID(teamID.String()), telemetry.WithBuildID(buildId.String()))

row, err := s.db.GetBuildInfoByTeamAndBuildID(ctx, queries.GetBuildInfoByTeamAndBuildIDParams{
row, err := s.db.GetBuildInfoByTeamAndBuildID(ctx, dashboardqueries.GetBuildInfoByTeamAndBuildIDParams{
Copy link
Contributor

Choose a reason for hiding this comment

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

I know these queries are called only in the dashboard-api, but lets keep them colocated to the database (source), rather than usage. -> they should stay in core

Copy link
Member Author

Choose a reason for hiding this comment

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

good point

expectedDashboardMigration = 0
}

err = sqlcdb.CheckMigrationVersionWithTable(ctx, config.PostgresConnectionString, "_migrations", expectedCoreMigration)
Copy link
Contributor

Choose a reason for hiding this comment

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

the migration table should not be necessary to provide here, correct? Or can we at least reuse the const for the infra?

Copy link
Member Author

Choose a reason for hiding this comment

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

why not necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

because its the default one

conn *pgxpool.Pool
}

func NewClient(ctx context.Context, databaseURL string, options ...pool.Option) (*Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this copied here?

l.Fatal(ctx, "failed to check core migration version", zap.Error(err))
}

err = sqlcdb.CheckMigrationVersionWithTable(ctx, config.PostgresConnectionString, "_migrations_dashboard", expectedDashboardMigration)
Copy link
Contributor

Choose a reason for hiding this comment

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

lets move _migrations_dashboard to const

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.

3 participants