Skip to content

Conversation

Sankara-Jefferson
Copy link
Contributor

This occurred because the [Preparation] model includes an embedded DealConfig struct, but the database schema was missing the corresponding columns that GORM expected to find.

This PR adds a comprehensive database migration to resolve the schema mismatch:

New Migration: [202507141000_add_deal_notes_to_preparations.go]
Adds the following missing columns to the preparations table:

  • deal_config_deal_notes (TEXT)
  • deal_config_deal_force (BOOLEAN)
  • deal_config_deal_allowed_piece_cids (JSON)
  • deal_config_schedule_cron (VARCHAR)
  • deal_config_schedule_deal_number (INTEGER)
  • deal_config_schedule_deal_size (VARCHAR)
  • deal_config_total_deal_number (INTEGER)
  • deal_config_total_deal_size (VARCHAR)
  • deal_config_max_pending_deal_number (INTEGER)
  • deal_config_max_pending_deal_size (VARCHAR)
  • deal_config_http_headers (JSON)

SQLite Compatibility Fix
Updated [202507090915_add_not_null_defaults.go] to remove PostgreSQL-specific ALTER COLUMN syntax that is not supported in SQLite, ensuring cross-database compatibility.

Changes Made
Created new migration file with proper up/down migration logic
Updated migration registry in [migrations.go]
Fixed existing migration for SQLite compatibility
Added comprehensive rollback functionality

Testing

  • Migration can be applied with: ./singularity admin migrate
  • Migration can be rolled back with: ./singularity admin migrate down
  • All new columns have appropriate default values to ensure data integrity

Jefferson Sankara added 9 commits July 14, 2025 14:31
- Add GetBalanceHandler to retrieve FIL and FIL+ datacap balances
- Implement Lotus API integration for balance queries
- Add comprehensive test suite with 18 test cases
- Add CLI wallet balance command with JSON output support
- Add API route GET /wallet/{address}/balance
- Add complete documentation for balance command
- Support both human-readable and raw balance formats
- Include error handling for partial failures

Resolves wallet balance retrieval requirements
… table

- Add migration 202507141000_add_deal_notes_to_preparations.go to fix missing deal_config_* columns
- Fix SQLite compatibility in 202507090915_add_not_null_defaults.go by removing unsupported ALTER COLUMN syntax
- Update migrations.go to register new migration

This resolves the GORM scanning error: 'table preparations has no column named deal_config_deal_notes'

The migration adds the following columns to the preparations table:
- deal_config_deal_notes (TEXT)
- deal_config_deal_force (BOOLEAN)
- deal_config_deal_allowed_piece_cids (JSON)
- deal_config_schedule_cron (VARCHAR)
- deal_config_schedule_deal_number (INTEGER)
- deal_config_schedule_deal_size (VARCHAR)
- deal_config_total_deal_number (INTEGER)
- deal_config_total_deal_size (VARCHAR)
- deal_config_max_pending_deal_number (INTEGER)
- deal_config_max_pending_deal_size (VARCHAR)
- deal_config_http_headers (JSON)
- Fixed JSON tag in BalanceResponse (balanceAttoFil)
- Applied gofmt for code formatting
- Updated migrations and ran singularity admin init
- Regenerated CLI/API documentation
- Removed deprecated deal-template docs
- Added new deal-schedule-template docs

These changes address CI failures and ensure documentation matches the current codebase.
- Added 'singularity admin init' to docgen.sh to prevent migration panic during doc generation
- Fixes CI and local docgen errors
if err != nil {
logger.Errorw("failed to lookup state for wallet address", "addr", addr, "err", err)
return nil, errors.Join(handlererror.ErrInvalidParameter, errors.Wrap(err, "failed to lookup actor ID"))
return nil, fmt.Errorf("failed to lookup state for wallet address %s: %w", addr.String(), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

@Sankara-Jefferson This change is the reason for the test failures.

@ianconsolata
Copy link
Collaborator

Can we close this. or is it still relevant?

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