Repository navigation
Conversation
- the migration id can be passed in during CI
… migration from conflicted registry
…s during a single operation
…ding private cached field
…ing rebase rollback
…er new migration created
|
@SandPod @marcelomendoncasoares @coderabbitai One thing I would like some help/insight on are the e2e tests. Overall the new command works superbly I just would like to see the e2e/integration tests work for all permutations to have that peace that it is stable and reliable. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 87 🏁 Script executed: Length of output: 116 🏁 Script executed: Length of output: 87 🏁 Script executed: Length of output: 116 🏁 Script executed: Length of output: 69 🏁 Script executed: Length of output: 78 🏁 Script executed: Length of output: 121 🏁 Script executed: Length of output: 1350 🏁 Script executed: Length of output: 766 🏁 Script executed: Length of output: 19607 🏁 Script executed: Length of output: 526 🏁 Script executed: Length of output: 14 🏁 Script executed: Length of output: 4049 🏁 Script executed: Length of output: 4221 🏁 Script executed: Length of output: 326 🏁 Script executed: Length of output: 785 🏁 Script executed: Length of output: 3683 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 1596 🏁 Script executed: Length of output: 881 🏁 Script executed: Length of output: 168 🏁 Script executed: Length of output: 6237 🏁 Script executed: Length of output: 2820 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 1024 🏁 Script executed: Length of output: 408 🏁 Script executed: Length of output: 95 🏁 Script executed: Length of output: 43 🏁 Script executed: Length of output: 4880 @jwelmac Thank you for the detailed context! I've analyzed your test file and compared it with other e2e tests in the codebase. Here are my recommendations: Analysis of the IssueLooking at your
Key Differences in Test ApproachesThe Serverpod codebase uses two different testing strategies: 1. File-based tests (your current approach -
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant User as Developer
participant Cmd as RebaseMigrationCommand
participant Val as Environment Validator
participant Cfg as GeneratorConfig
participant Runner as RebaseMigrationRunner
participant Gen as MigrationGenerator
participant Reg as Migration Registry
User->>Cmd: rebase-migration --onto [base] [--check] [--force]
Cmd->>Cmd: Parse onto, check, force, tag arguments
Cmd->>Val: _validateCommandEnvironment()
Val->>Cfg: Load GeneratorConfig (interactive)
Val->>Cfg: Verify database feature enabled
Cfg-->>Val: Config loaded
Val-->>Cmd: Validated GeneratorConfig
alt Check Mode
Cmd->>Runner: checkMigration(onto, config)
Runner->>Gen: Validate migration state
Gen->>Reg: Query migration history
Reg-->>Gen: Conflicts/status
Gen-->>Runner: Check result
Runner-->>Cmd: Status (exit code, messages)
Cmd-->>User: Display check results
else Rebase Mode
Cmd->>Runner: rebaseMigration(onto, force, tag, config)
Runner->>Gen: Identify local vs incoming migrations
Gen->>Reg: Read conflict markers
Reg-->>Gen: Local & incoming migration IDs
alt Force Disabled & Unsafe Changes
Runner-->>Cmd: Rollback / Error
Cmd-->>User: Abort rebase
else Force Enabled or Safe Changes
Runner->>Gen: Generate unified migration (on top of onto)
Gen-->>Runner: New migration created
Runner->>Reg: Update registry (remove conflicts, add new migration)
Reg-->>Runner: Registry updated
Runner-->>Cmd: Rebase complete
Cmd-->>User: Migration consolidated, old migrations deleted
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Pre-merge checks✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
tools/serverpod_cli/test/runner/serverpod_command_runner_test.dart (1)
168-185: Consider grouping version-related tests.The two version tests at lines 168 and 176 are closely related (both test version display functionality) and could be grouped together for better organization.
💡 Suggested grouping
+ group('Version display - ', () { - test('Given version subcommand when run then prints only version', () async { + test('Given version subcommand when run then prints only version', () async { - await fixture.runner.run(['version']); + await fixture.runner.run(['version']); - var logOutput = fixture.logOutput; - expect(logOutput.messages, hasLength(1)); - expect(logOutput.messages.first, equals('Serverpod version: 1.1.0')); - }); + var logOutput = fixture.logOutput; + expect(logOutput.messages, hasLength(1)); + expect(logOutput.messages.first, equals('Serverpod version: 1.1.0')); + }); - test( - 'Given --version flag when run then should exit early and not show help', - () async { - await fixture.runner.run(['--version']); + test( + 'Given --version flag when run then should exit early and not show help', + () async { + await fixture.runner.run(['--version']); - var logOutput = fixture.logOutput; - expect(logOutput.messages, hasLength(1)); - expect(logOutput.messages.first, equals('Serverpod version: 1.1.0')); - }, - ); + var logOutput = fixture.logOutput; + expect(logOutput.messages, hasLength(1)); + expect(logOutput.messages.first, equals('Serverpod version: 1.1.0')); + }, + ); + });As per coding guidelines, related test cases should be grouped where appropriate.
tools/serverpod_cli/test/commands/rebase_migration_test.dart (1)
127-129: Missing cleanup for created test directories.The
createValidProjectfunction creates a mock project directory buttearDownonly resets the logger. This could leave orphaned test directories and cause isolation issues if tests run in parallel.🔎 Proposed fix to add directory cleanup
+ late Directory? createdProjectDir; + /// Creates a valid project for testing Future<void> createValidProject({bool withDatabase = true}) async { final currentDir = createMockServerpodProject( projectName: 'myapp', generatorYamlContent: ''' type: server features: database: $withDatabase ''', ); await currentDir.create(); Directory.current = currentDir.io; + createdProjectDir = currentDir.io; } tearDown(() { resetLogger(); + if (createdProjectDir?.existsSync() ?? false) { + createdProjectDir!.deleteSync(recursive: true); + } + createdProjectDir = null; });tests/serverpod_cli_e2e_test/test/rebase_migration_test.dart (3)
113-115: Missing tearDown for project cleanup.The
setUpcreates a full project usingserverpod createbut there's no correspondingtearDownto clean up. This could lead to disk space issues and test pollution when running the suite repeatedly.🔎 Proposed fix to add tearDown cleanup
setUp(() async { await createProject(); }); + tearDown(() async { + final projectDir = Directory(path.join(d.sandbox, projectName)); + if (projectDir.existsSync()) { + projectDir.deleteSync(recursive: true); + } + });
315-336: Redundant delays in test body.The
createMigrationhelper at line 60-61 already includes a 2ms delay for migration ordering. The additionalFuture.delayedcalls here are redundant.🔎 Proposed simplification
// 2. Second migration (v2) await writeModel( 'other', ['name: String'], ); await createMigration(); - // Pause to ensure v1 is created before v2 - await Future.delayed(const Duration(milliseconds: 2)); - // 3. Third migration (v3) await writeModel( 'third', ['name: String'], ); await createMigration(); - // Pause to ensure v2 is created before v3 - await Future.delayed(const Duration(milliseconds: 2)); - // 4. Run rebase-migration --check --onto v1
495-497: Skipped test group reduces coverage.This test group for registry conflict scenarios is marked
skip: true. Per the PR comments, there are concerns about e2e test isolation due to database state not being reset between tests.Consider either:
- Opening an issue to track enabling these tests
- Adding the isolation/cleanup needed for the tests to pass reliably
Do you want me to help open an issue to track this work?
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (6)
tools/serverpod_cli/lib/src/migrations/generator.dartis excluded by!**/migrations/**tools/serverpod_cli/lib/src/migrations/migration_registry.dartis excluded by!**/migrations/**tools/serverpod_cli/lib/src/migrations/migration_registry_file.dartis excluded by!**/migrations/**tools/serverpod_cli/lib/src/migrations/rebase_migration_runner.dartis excluded by!**/migrations/**tools/serverpod_cli/test/migrations/migration_registry_file_test.dartis excluded by!**/migrations/**tools/serverpod_cli/test/migrations/rebase_migration_runner_test.dartis excluded by!**/migrations/**
📒 Files selected for processing (12)
tests/serverpod_cli_e2e_test/test/rebase_migration_test.darttests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition.jsontests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition.sqltests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.jsontests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/migration.jsontests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/migration.sqltools/serverpod_cli/bin/serverpod_cli.darttools/serverpod_cli/lib/src/commands/create_migration.darttools/serverpod_cli/lib/src/commands/rebase_migration.darttools/serverpod_cli/test/commands/rebase_migration_test.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.darttools/serverpod_cli/test/test_util/mock_log.dart
🧰 Additional context used
📓 Path-based instructions (2)
**/*test.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*test.dart: When using group() with test(), ensure each statement ('Given', 'When', 'Then') appears only once in the combined description to avoid duplication
Place passing/success test cases at the top of test files before error test cases for the same functionality
Group related test cases using group() where appropriate
Files:
tools/serverpod_cli/test/commands/rebase_migration_test.darttests/serverpod_cli_e2e_test/test/rebase_migration_test.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.dart: Follow Dart formatting conventions with dart format command
Run 'dart format .' to format all code before committing
Run 'melos lint_strict' or 'util/run_tests_analyze' to check code quality before committing, ensuring compliance with CI strict mode
Files:
tools/serverpod_cli/test/commands/rebase_migration_test.darttools/serverpod_cli/lib/src/commands/create_migration.darttools/serverpod_cli/test/test_util/mock_log.darttools/serverpod_cli/lib/src/commands/rebase_migration.darttests/serverpod_cli_e2e_test/test/rebase_migration_test.darttools/serverpod_cli/bin/serverpod_cli.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
🧠 Learnings (15)
📚 Learning: 2025-08-25T19:46:58.073Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3917
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/analysis_options.yaml:3-6
Timestamp: 2025-08-25T19:46:58.073Z
Learning: In Serverpod, test tool paths like `test/integration/test_tools/serverpod_test_tools.dart` are configured per project in the "generator.yaml" file and managed by a generator system, so they don't need to be updated manually across all files at once.
Applied to files:
tools/serverpod_cli/test/commands/rebase_migration_test.darttools/serverpod_cli/lib/src/commands/create_migration.darttools/serverpod_cli/test/test_util/mock_log.darttools/serverpod_cli/lib/src/commands/rebase_migration.darttests/serverpod_cli_e2e_test/test/rebase_migration_test.darttests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition.jsontests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.jsontools/serverpod_cli/bin/serverpod_cli.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Verify example projects still work before submitting PR by running example servers with 'dart bin/main.dart --apply-migrations'
Applied to files:
tools/serverpod_cli/test/commands/rebase_migration_test.darttools/serverpod_cli/lib/src/commands/create_migration.darttools/serverpod_cli/lib/src/commands/rebase_migration.darttests/serverpod_cli_e2e_test/test/rebase_migration_test.darttools/serverpod_cli/bin/serverpod_cli.dart
📚 Learning: 2025-07-02T16:09:27.702Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3747
File: tests/serverpod_new_auth_test/serverpod_new_auth_test_server/pubspec.yaml:37-38
Timestamp: 2025-07-02T16:09:27.702Z
Learning: In Serverpod migration testing, it's appropriate for test servers like serverpod_new_auth_test_server to include dependencies on both legacy packages (e.g., serverpod_auth_server) and new modular packages to enable comprehensive testing of migration paths from old to new authentication systems.
Applied to files:
tools/serverpod_cli/test/commands/rebase_migration_test.darttests/serverpod_cli_e2e_test/test/rebase_migration_test.darttests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.jsontests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition.sqltools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Applies to **/*test.dart : Group related test cases using group() where appropriate
Applied to files:
tools/serverpod_cli/test/test_util/mock_log.darttests/serverpod_cli_e2e_test/test/rebase_migration_test.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Applies to **/*.dart : Follow Dart formatting conventions with dart format command
Applied to files:
tools/serverpod_cli/lib/src/commands/rebase_migration.darttools/serverpod_cli/bin/serverpod_cli.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Applies to **/*test.dart : When using group() with test(), ensure each statement ('Given', 'When', 'Then') appears only once in the combined description to avoid duplication
Applied to files:
tests/serverpod_cli_e2e_test/test/rebase_migration_test.dart
📚 Learning: 2025-07-02T16:07:50.947Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3747
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_server/lib/src/business/migrating_email_endpoint_base.dart:4-4
Timestamp: 2025-07-02T16:07:50.947Z
Learning: In Serverpod, tp prefers importing the full package (e.g., 'package:serverpod_auth_migration_server/serverpod_auth_migration_server.dart') as a baseline rather than using smaller local imports, even within the same package where it might be considered a "self-import".
Applied to files:
tests/serverpod_cli_e2e_test/test/rebase_migration_test.darttests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.jsontools/serverpod_cli/bin/serverpod_cli.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
📚 Learning: 2025-11-04T12:09:52.649Z
Learnt from: marcelomendoncasoares
Repo: serverpod/serverpod PR: 4150
File: examples/auth/auth_flutter/lib/widgets/profile_info.dart:23-30
Timestamp: 2025-11-04T12:09:52.649Z
Learning: In Serverpod example and testing projects (e.g., examples/auth/auth_flutter), prefer letting errors bubble up naturally rather than handling them gracefully with catchError or try-catch blocks. This helps developers see what went wrong during development and testing.
Applied to files:
tests/serverpod_cli_e2e_test/test/rebase_migration_test.darttools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
📚 Learning: 2025-06-17T11:34:13.289Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3666
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_server/README.md:3-8
Timestamp: 2025-06-17T11:34:13.289Z
Learning: The README.md files in the serverpod_auth_migration module directories are auto-generated and get overwritten by utility scripts, so manual updates should be avoided until proper documentation is added during feature rollout.
Applied to files:
tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.json
📚 Learning: 2025-06-17T11:40:09.088Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3666
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_client/CHANGELOG.md:1-7
Timestamp: 2025-06-17T11:40:09.088Z
Learning: CHANGELOG.md files in the serverpod_auth_migration modules (client and server) are auto-generated and cannot be manually modified during the development process.
Applied to files:
tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.json
📚 Learning: 2025-07-16T14:22:21.330Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3791
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/models/apple_account.spy.yaml:16-21
Timestamp: 2025-07-16T14:22:21.330Z
Learning: In Serverpod, tp prefers requiring explicit field setting without default values for new database schemas that haven't been deployed yet, rather than providing defaults, to ensure that critical metadata (like refreshTokenRequestedWithBundleIdentifier in Apple authentication) is consciously set by the application code. This approach is valid for new schemas since there are no existing rows to cause migration failures.
Applied to files:
tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.json
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Activate serverpod_cli from source using 'dart pub global activate --source path tools/serverpod_cli' after installation for development
Applied to files:
tools/serverpod_cli/bin/serverpod_cli.dart
📚 Learning: 2025-06-27T08:39:36.440Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3721
File: util/pub_get_all:0-0
Timestamp: 2025-06-27T08:39:36.440Z
Learning: In the Serverpod project, `dart pub get` commands work fine on Flutter packages both locally and in CI environments, even when the package has `flutter: sdk: flutter` dependencies in pubspec.yaml. The technical constraint of Flutter SDK dependencies causing `dart pub` failures may not apply in all environments or recent Dart versions.
Applied to files:
tools/serverpod_cli/bin/serverpod_cli.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Update pubspec files from templates using 'util/update_pubspecs' after template changes
Applied to files:
tools/serverpod_cli/bin/serverpod_cli.dart
📚 Learning: 2025-06-16T12:07:26.018Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3651
File: modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server/lib/src/business/email_accounts.dart:35-39
Timestamp: 2025-06-16T12:07:26.018Z
Learning: The `withServerpod` test helper runs tests within a transaction, which may require adapting database queries to accept transaction parameters for proper snapshot consistency during testing.
Applied to files:
tools/serverpod_cli/test/runner/serverpod_command_runner_test.dart
🔇 Additional comments (21)
tools/serverpod_cli/test/runner/serverpod_command_runner_test.dart (3)
10-10: LGTM: Good refactoring to shared test utilities.Extracting mock implementations to a shared utility promotes code reuse and maintainability across test files.
12-91: LGTM: Well-structured test fixtures and mocks.The mock command classes and TestFixture pattern provide clean, maintainable test infrastructure. The createTestFixture factory function ensures consistent test setup with proper dependency wiring.
93-107: LGTM: Proper test setup and teardown.The setup structure correctly initializes the logger once for all tests while creating fresh fixtures per test, ensuring proper test isolation.
tools/serverpod_cli/lib/src/commands/create_migration.dart (3)
67-108: LGTM! Clean extraction of migration logic into a testable runner.The refactoring successfully separates concerns by extracting migration creation logic into
CreateMigrationRunner. This enables unit testing and reuse (as demonstrated by the rebase-migration command), while preserving existing behavior and error handling.
111-127: LGTM! Well-documented runner class.The
CreateMigrationRunnerclass is properly documented with template comments and clear field descriptions. The design follows good practices by making the runner configurable via constructor parameters.
148-220: LGTM! Enhanced method signature supports downstream usage.The
createMigrationmethod now returnsString?(the migration name on success,nullwhen no changes detected) instead ofvoid. This enhancement enables callers likeRebaseMigrationRunnerto access the generated migration name without re-querying the filesystem.tools/serverpod_cli/lib/src/commands/rebase_migration.dart (4)
15-47: LGTM! Well-structured options with proper reuse.The
RebaseMigrationOptionenum follows the established pattern and correctly reusesforceandtagoptions fromCreateMigrationCommand, avoiding duplication and ensuring consistency across commands.
52-66: LGTM! Testable design with dependency injection.The nullable
rebaseMigrationRunnerfield annotated with@visibleForTestingenables proper unit testing by allowing mock injection, while still providing production defaults. The command metadata is clear and descriptive.
83-86: LGTM! Proper validation prevents empty --onto values.The validation correctly catches the edge case where
--ontois specified but empty (e.g.,--onto ""), providing a clear error message before proceeding with the migration.
117-142: LGTM! Consolidated environment validation.Extracting validation into
_validateCommandEnvironmentpromotes maintainability and follows DRY principles. The method properly validates both config loading and database feature enablement with informative error messages.tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/migration.json (1)
1-53: LGTM! Valid test fixture for e2e migration testing.This migration JSON correctly defines a
DatabaseMigrationthat creates a "third" table with standard id/name columns and a primary key index. The format conforms to Serverpod's migration schema (migrationApiVersion 1) and complements the parallel test fixtures in the incoming_1 directory for comprehensive rebase-migration testing.tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition_project.json (1)
1-150: LGTM! Valid test fixture representing post-migration database state.This
DatabaseDefinitioncorrectly describes the complete database schema with three tables (example, other, third) and their installed module versions. The consistent table structure and proper index definitions align with the migration.json fixture, enabling accurate e2e testing of the rebase-migration workflow.tools/serverpod_cli/bin/serverpod_cli.dart (2)
14-14: LGTM! Proper import addition.The import for
RebaseMigrationCommandis correctly placed in alphabetical order with other command imports.
83-83: LGTM! Command successfully wired into CLI.The
RebaseMigrationCommand()is properly registered in the command runner, making it available viaserverpod rebase-migration. The placement betweenCreateRepairMigrationCommandandRunCommandis logical and follows the existing pattern.tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/migration.sql (1)
1-45: LGTM!This SQL migration test fixture is well-structured with proper transaction boundaries and follows Serverpod's migration patterns. The
ON CONFLICTupsert strategy for migration versions is appropriate for idempotent migrations.tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition.json (1)
1-2835: LGTM!This JSON definition file is a comprehensive test fixture representing a complete Serverpod database schema. The structure correctly follows Serverpod's
DatabaseDefinitionformat with proper table definitions, column types, indexes, foreign keys, and installed module versions.tools/serverpod_cli/test/commands/rebase_migration_test.dart (1)
145-227: Well-structured test coverage for command validation.The test suite properly covers:
- Input validation (empty
--onto)- Environment validation (missing config, disabled database feature)
- Correct delegation between
rebaseMigrationandcheckMigrationbased on the--checkflagThe test descriptions follow the Given/When/Then pattern per coding guidelines.
tests/serverpod_cli_e2e_test/test/rebase_migration_test.dart (2)
625-627: Another skipped test group for destructive changes.Similar to the registry conflict tests, this group is also skipped. Both groups appear to test important edge cases for the rebase-migration command.
These tests cover critical scenarios (rollback on destructive changes,
--forceflag behavior) that should be validated before the feature is considered complete.
117-179: Good test structure following coding guidelines.The test groups follow the Given/When/Then pattern appropriately:
- Group: "Given --onto specified"
- Test: "when there are local migrations then migrations are collapsed into one"
The assertions verify both the migration directory state and registry contents, providing comprehensive validation.
tools/serverpod_cli/test/test_util/mock_log.dart (1)
1-86: LGTM!Well-structured test utilities that properly extend/implement the
cli_toolsinterfaces. TheMockLogOutputaggregates messages by category,MockLoggerroutes log calls to the output, andMockAnalyticstracks events. Thereset()method returningthisenables fluent chaining if needed.tests/serverpod_cli_e2e_test/test/test_migrations/incoming_1/definition.sql (1)
1-649: LGTM!This SQL definition file is a comprehensive test fixture providing:
- A properly attributed
gen_random_uuid_v7()function (MIT licensed)- Complete table schemas for Serverpod core and authentication modules
- Foreign key relationships with appropriate cascade behaviors
- Migration version tracking with upsert semantics
The schema correctly mirrors the JSON definition and follows PostgreSQL best practices.
This PR implements a
rebase-migrationcommand that removes all migrations created after a base migration and creates a new one to correctly append to the history.Fixes #4503
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.Summary by CodeRabbit
Release Notes
New Features
rebase-migrationCLI command to consolidate migrations with options for specifying base migration (--onto), check mode (--check), force flag (--force), and tagging (--tag).Tests
✏️ Tip: You can customize this high-level summary in your review settings.