Skip to content

fix: migration reset and rollback#1038

Merged
hwbrzzl merged 2 commits intov1.15.xfrom
bowen/optimize-migration
May 19, 2025
Merged

fix: migration reset and rollback#1038
hwbrzzl merged 2 commits intov1.15.xfrom
bowen/optimize-migration

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented May 18, 2025

📑 Description

This pull request introduces several updates across the codebase, focusing on improving maintainability, consistency, and extensibility. The key changes include consolidating binding constants into a central contracts/binding.go file, refactoring service providers to use these constants, enhancing lock functionality in the cache module, and adding new features to database schema definitions. Additionally, the console package has been updated to improve flexibility in command-line interactions.

Refactoring and Consolidation:

  • Introduced a centralized contracts/binding.go file to define binding constants for various services, replacing hardcoded string constants across the codebase. This improves consistency and reduces duplication.
  • Updated service providers (auth/service_provider.go, cache/service_provider.go, config/service_provider.go, console/service_provider.go, crypt/service_provider.go) to use the new binding constants from contracts/binding.go. [1] [2] [3] [4] [5]

Cache Enhancements:

  • Added a new method BlockWithTicker to the Lock interface and its implementation, allowing more fine-grained control over lock acquisition with custom ticker intervals. [1] [2]

Database Schema Improvements:

  • Added support for new column types (Boolean and custom Column) in the Blueprint interface, along with corresponding methods in the Grammar interface. This extends the flexibility of schema definitions. [1] [2]

Console Updates:

  • Refactored the console/application.go file to replace the isArtisan flag with a more flexible useArtisan flag, allowing explicit control over whether the "artisan" command is used. Updated related test cases accordingly. [1] [2] [3]

New Features:

  • Added a new Store interface in contracts/http/store.go to support advanced rate-limiting mechanisms, providing methods for token management and burst handling.

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings May 18, 2025 14:58
@hwbrzzl hwbrzzl requested a review from a team as a code owner May 18, 2025 14:58
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 refactors and consolidates configuration and service binding logic while introducing improvements in query construction, caching, and console command behavior. Key changes include:

  • Consolidation of binding constants into a central file and updating service providers accordingly.
  • Refactoring of Gorm query functions (switching to parameterized queries and replacing SetContext with WithContext) and logger configuration adjustments.
  • Enhancements to lock functionality in the cache module and improvements to console application flexibility with a renamed flag.

Reviewed Changes

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

Show a summary per file
File Description
database/gorm/query.go Refactored query construction, introduced BuildGorm and updated context propagation methods.
database/gorm/logger.go Revised logger behavior by removing the Artisan environment check to set log level.
contracts/foundation/application.go Updated the Refresh method signature to simplify the API.
contracts/database/orm/orm.go Renamed the context propagation interface from SetContext to WithContext for clarity.
console/application.go Renamed the internal flag from isArtisan to useArtisan and updated NewApplication accordingly.
(Other Files) Updated binding constants and service providers, added new types and methods for schema and cache enhancements.
Comments suppressed due to low confidence (4)

database/gorm/logger.go:16

  • Removal of the env.IsArtisan() check alters logger behavior in non-debug mode. Confirm that the new default log level is intended across all environments.
if env.IsArtisan() { level = logger.Error }

contracts/database/orm/orm.go:180

  • Renaming the interface from QueryWithSetContext to QueryWithContext improves clarity. Ensure that the documentation and usage examples reflect this updated naming convention.
type QueryWithContext interface { WithContext(ctx context.Context) Query }

console/application.go:15

  • [nitpick] Renaming the internal flag from 'isArtisan' to 'useArtisan' clarifies its purpose. Consider adding inline documentation to explain the flag's role in command invocation.
useArtisan bool

contracts/foundation/application.go:134

  • Changing the Refresh method signature to remove the key parameter improves consistency, but verify that all dependent modules are updated to use the new signature.
Refresh()

@hwbrzzl hwbrzzl changed the base branch from master to v1.15.x May 18, 2025 14:58
@codecov
Copy link

codecov bot commented May 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (v1.15.x@403b952). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x    #1038   +/-   ##
==========================================
  Coverage           ?   68.77%           
==========================================
  Files              ?      218           
  Lines              ?    18865           
  Branches           ?        0           
==========================================
  Hits               ?    12975           
  Misses             ?     5229           
  Partials           ?      661           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

LGTM

@hwbrzzl hwbrzzl merged commit d42ffd0 into v1.15.x May 19, 2025
11 checks passed
@hwbrzzl hwbrzzl deleted the bowen/optimize-migration branch May 19, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants