Skip to content

Fix: add migration#1307

Merged
benjamin-747 merged 1 commit into
gitmono-dev:mainfrom
yyjeqhc:fix_add_migration
Aug 4, 2025
Merged

Fix: add migration#1307
benjamin-747 merged 1 commit into
gitmono-dev:mainfrom
yyjeqhc:fix_add_migration

Conversation

@yyjeqhc

@yyjeqhc yyjeqhc commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

对orion-server的数据库表字段修改进行迁移,将end_at字段改为允许为空

pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub build_id: Uuid,
    pub output_file: String,
    /// Exit code of the build process. None if process was terminated by signal on Unix
    pub exit_code: Option<i32>,
    pub start_at: DateTimeUtc,
    pub end_at: DateTimeUtc,//修改这个字段为Option<...>
    pub repo_name: String,
    /// Build target specification (e.g., "//:main")
    pub target: String,
    pub arguments: String,
    /// Merge request identifier
    pub mr: String,
}
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub build_id: Uuid,
    pub output_file: String,
    /// Exit code of the build process. None if process was terminated by signal on Unix
    pub exit_code: Option<i32>,
    pub start_at: DateTimeUtc,
    pub end_at: Option<DateTimeUtc>,
    pub repo_name: String,
    /// Build target specification (e.g., "//:main")
    pub target: String,
    pub arguments: String,
    /// Merge request identifier
    pub mr: String,
}

@vercel

vercel Bot commented Aug 4, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 4, 2025 9:00am

@genedna
genedna requested a review from Copilot August 4, 2025 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a database migration to modify the builds table by making the end_at column nullable. The change allows build records to be created without requiring an end timestamp, which is useful for tracking builds that are still in progress.

  • Adds a new migration file to alter the builds.end_at column from NOT NULL to nullable
  • Updates the migration module to include the new migration in the migration list

Reviewed Changes

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

File Description
jupiter/src/migration/mod.rs Registers the new migration in the module and migration list
jupiter/src/migration/m20250804_151214_alter_builds_end_at.rs Implements the database migration to make end_at column nullable

)
.await?;
}
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

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

The migration only handles PostgreSQL but ignores SQLite and MySQL backends. This could lead to inconsistent database schemas across different database types. Consider implementing the equivalent ALTER TABLE statements for these backends or add a comment explaining why they're not needed.

Suggested change
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}
DatabaseBackend::Sqlite => {
// SQLite: ALTER TABLE builds ALTER COLUMN end_at DROP NOT NULL
// SQLite supports altering column nullability via SeaORM migration
manager
.alter_table(
Table::alter()
.table(Builds::Table)
.modify_column(timestamp_null(Builds::EndAt).to_owned())
.to_owned(),
)
.await?;
}
DatabaseBackend::MySql => {
// MySQL: ALTER TABLE builds MODIFY end_at TIMESTAMP NULL
manager
.alter_table(
Table::alter()
.table(Builds::Table)
.modify_column(timestamp_null(Builds::EndAt).to_owned())
.to_owned(),
)
.await?;
}

Copilot uses AI. Check for mistakes.
)
.await?;
}
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

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

The down migration also only handles PostgreSQL. If the up migration is ever extended to support other backends, the down migration should be updated accordingly to maintain consistency.

Suggested change
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {
// No action required for Sqlite or MySql.
// If the up migration is extended to support these backends,
// update this arm accordingly to maintain consistency.
}

Copilot uses AI. Check for mistakes.
@benjamin-747
benjamin-747 added this pull request to the merge queue Aug 4, 2025
Merged via the queue into gitmono-dev:main with commit b5a7558 Aug 4, 2025
19 of 21 checks passed
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