Skip to content

ACE-170: Fix/schema diff skip tables#86

Open
danolivo wants to merge 2 commits intomainfrom
fix/schema-diff-skip-tables
Open

ACE-170: Fix/schema diff skip tables#86
danolivo wants to merge 2 commits intomainfrom
fix/schema-diff-skip-tables

Conversation

@danolivo
Copy link

@danolivo danolivo commented Mar 6, 2026

  • Fix --skip-tables and --skip-file flags being silently ignored in schema-diff — the skipTablesList field existed on SchemaDiffCmd but was never populated because parseSkipList() was never implemented (unlike repset-diff, which had a working implementation)
  • Add parseSkipList() method to parse both comma-separated --skip-tables values and line-delimited --skip-file entries
  • Add skip guard in the SchemaTableDiff() table loop so matched tables are logged and skipped
  • Track tables_skipped count in the taskstore completion record
  • Add unit tests for parseSkipList() covering: empty input, flag-only, file-only, combined, missing file error, and single-entry edge cases
  • Add integration tests against the Docker cluster verifying end-to-end behavior for both --skip-tables and --skip-file

Andrei Lepikhov and others added 2 commits March 6, 2026 14:52
SkipTables and SkipFile were accepted from the CLI and stored on
SchemaDiffCmd, but parseSkipList() was never implemented for
SchemaDiffCmd, so skipTablesList remained nil and the table loop
iterated every table regardless of the flag.

Mirror the working repset-diff implementation:
- add parseSkipList() to SchemaDiffCmd (splits SkipTables on commas,
  reads SkipFile line-by-line via bufio.Scanner)
- call it in RunChecks(), before the cluster connection is opened,
  matching the position repset-diff uses
- guard the SchemaTableDiff() table loop with the same skip check
  repset-diff uses, logging each skipped table unless --quiet is set
- add a tablesSkipped counter and include tables_skipped in the
  taskstore completion record

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Unit tests (internal/consistency/diff/schema_diff_test.go) exercise
parseSkipList directly: empty input, comma-separated flag, skip file,
combined sources, missing file error, and single-entry edge case.

Integration tests (tests/integration/schema_diff_test.go) verify the
end-to-end behaviour against the live Docker cluster: a table with a
data divergence is skipped when listed in --skip-tables (no diff file
produced) and diffed normally when not listed; a parallel sub-test
confirms the --skip-file path works the same way.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@danolivo danolivo added the bug Something isn't working label Mar 6, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

Adds table-skipping functionality to schema diff operations via a new parseSkipList method that processes skip configuration from SkipTables and SkipFile. Runtime filtering prevents listed tables from being diffed. New tables_skipped metric added to task results. Includes unit and integration tests validating skip mechanisms.

Changes

Cohort / File(s) Summary
Core Implementation
internal/consistency/diff/schema_diff.go
Introduces parseSkipList method to build skip list from SkipTables and SkipFile. Implements runtime table skipping in SchemaDiffCmd.SchemTableDiff with skip list validation. Adds tables_skipped counter to task result metrics and deferred finalization.
Unit Tests
internal/consistency/diff/schema_diff_test.go
Tests skip list parsing logic covering empty input, SkipTables comma-separated parsing, SkipFile line-based reading, combined usage, error handling for missing files, and single entry cases. Includes writeSkipFile helper for test file creation.
Integration Tests
tests/integration/schema_diff_test.go
Adds helpers (newTestSchemaDiffTask, createDivergentTable, diffFilesForTable) and two test cases validating skip behavior: TestSchemaDiff_SkipTablesFlag and TestSchemaDiff_SkipTablesFile against a two-node PostgreSQL cluster.

Poem

🐰 Hoppy skips through diff land,
Tables tucked away with care,
parseSkipList in hand,
No diffs here or there!
Metrics hop along the way,
Tests verify all day! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly references the primary change (ACE-170 ticket) and clearly summarizes the main fix: implementing skip tables functionality for schema-diff.
Description check ✅ Passed The description is comprehensively related to the changeset, detailing the specific implementation of skip tables functionality with clear coverage of methods, guards, tracking, and test coverage.
Docstring Coverage ✅ Passed Docstring coverage is 92.31% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/schema-diff-skip-tables

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/integration/schema_diff_test.go (1)

5-5: Minor: Copyright year inconsistency.

This file has "2023 - 2025" while schema_diff.go and schema_diff_test.go have "2023 - 2026".

🔧 Fix copyright year
-// Copyright (C) 2023 - 2025, pgEdge (https://www.pgedge.com/)
+// Copyright (C) 2023 - 2026, pgEdge (https://www.pgedge.com/)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/schema_diff_test.go` at line 5, Update the copyright header
in tests/integration/schema_diff_test.go to match the other files by changing
the year range string "2023 - 2025" to "2023 - 2026"; locate the top-of-file
comment (the copyright line) and replace the year range so it is consistent with
schema_diff.go and schema_diff_test.go.
internal/consistency/diff/schema_diff.go (1)

112-133: Consider trimming whitespace and filtering empty entries at parse time.

The current implementation defers whitespace trimming to the comparison at line 431 (strings.TrimSpace(skip)). This works but:

  1. Empty lines from the skip file are added to the list (wasteful iterations)
  2. Entries like "table1, table2" (space after comma) work due to runtime trim, but storing untrimmed values is inconsistent
♻️ Optional: Normalize entries at parse time
 func (c *SchemaDiffCmd) parseSkipList() error {
 	var tables []string
 	if c.SkipTables != "" {
-		tables = append(tables, strings.Split(c.SkipTables, ",")...)
+		for _, t := range strings.Split(c.SkipTables, ",") {
+			if trimmed := strings.TrimSpace(t); trimmed != "" {
+				tables = append(tables, trimmed)
+			}
+		}
 	}
 	if c.SkipFile != "" {
 		file, err := os.Open(c.SkipFile)
 		if err != nil {
 			return fmt.Errorf("could not open skip file: %w", err)
 		}
 		defer file.Close()
 		scanner := bufio.NewScanner(file)
 		for scanner.Scan() {
-			tables = append(tables, scanner.Text())
+			if line := strings.TrimSpace(scanner.Text()); line != "" {
+				tables = append(tables, line)
+			}
 		}
 		if err := scanner.Err(); err != nil {
 			return fmt.Errorf("error reading skip file: %w", err)
 		}
 	}
 	c.skipTablesList = tables
 	return nil
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/consistency/diff/schema_diff.go` around lines 112 - 133, The
parseSkipList function currently appends raw entries (from c.SkipTables via
strings.Split and from file scanner.Text()) without trimming or filtering
empties; update parseSkipList to normalize entries by trimming whitespace for
each element produced by strings.Split(c.SkipTables, ",") and for each
scanner.Text() line, skip any empty strings after trimming, and then assign the
cleaned slice to c.skipTablesList so stored values are normalized and empty
entries are excluded (refer to parseSkipList, SkipTables, SkipFile,
skipTablesList, strings.Split and scanner).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/consistency/diff/schema_diff.go`:
- Around line 112-133: The parseSkipList function currently appends raw entries
(from c.SkipTables via strings.Split and from file scanner.Text()) without
trimming or filtering empties; update parseSkipList to normalize entries by
trimming whitespace for each element produced by strings.Split(c.SkipTables,
",") and for each scanner.Text() line, skip any empty strings after trimming,
and then assign the cleaned slice to c.skipTablesList so stored values are
normalized and empty entries are excluded (refer to parseSkipList, SkipTables,
SkipFile, skipTablesList, strings.Split and scanner).

In `@tests/integration/schema_diff_test.go`:
- Line 5: Update the copyright header in tests/integration/schema_diff_test.go
to match the other files by changing the year range string "2023 - 2025" to
"2023 - 2026"; locate the top-of-file comment (the copyright line) and replace
the year range so it is consistent with schema_diff.go and schema_diff_test.go.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 602b86ca-503a-455a-b81d-77070a19ec62

📥 Commits

Reviewing files that changed from the base of the PR and between fac0d31 and 8a1811e.

📒 Files selected for processing (3)
  • internal/consistency/diff/schema_diff.go
  • internal/consistency/diff/schema_diff_test.go
  • tests/integration/schema_diff_test.go

@mason-sharp mason-sharp requested review from rasifr March 6, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant