Skip to content

Conversation

@adam-fowler
Copy link
Member

@adam-fowler adam-fowler commented Oct 19, 2025

Add new options parameter to apply, revert and revertInconsistent.
apply has option .ignoreUnknownMigrations
revert has options .ignoreUnknownMigrations and .removeUnknownMigrations
revertInconsistent has options .ignoreUnknownMigrations and .removeUnknownMigrations

Also added Migrations.add(_:skipDuplicates:) which takes some Collection<any DatabaseMigration>

@adam-fowler adam-fowler force-pushed the remove-unregistered-migrations branch from 54fe2b3 to 1f135a2 Compare October 20, 2025 07:38
@adam-fowler adam-fowler force-pushed the remove-unregistered-migrations branch from f0401c1 to 14601cc Compare October 20, 2025 09:06
Comment on lines 70 to 77
public struct ApplyOptions: OptionSet, Sendable {
public let rawValue: Int

public init(rawValue: Int) { self.rawValue = rawValue }

/// If database has a migration applied we don't know about, ignore it
static var ignoreUnknownMigrations: Self { .init(rawValue: 1 << 0) }
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this not backed by a raw value? I think we'll want to consider options that are not a single flag/boolean, but with an associatedvalue

Copy link
Member Author

Choose a reason for hiding this comment

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

If we are to use OptionSet, it conforms to RawRepresentable

Comment on lines 174 to 183
public struct RevertOptions: OptionSet, Sendable {
public let rawValue: Int

public init(rawValue: Int) { self.rawValue = rawValue }

/// Ignore migrations we don't know about
static var ignoreUnknownMigrations: Self { .init(rawValue: 1 << 0) }
/// Remove database entry for migrations we don't know about
static var removeUnknownMigrations: Self { .init(rawValue: 1 << 1) }
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

❌ Patch coverage is 87.95181% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.22%. Comparing base (14601cc) to head (5b74982).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
Sources/PostgresMigrations/Migrations.swift 89.02% 9 Missing ⚠️
Sources/PostgresMigrations/MigrationError.swift 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main       #3   +/-   ##
=======================================
  Coverage   92.22%   92.22%           
=======================================
  Files           4        4           
  Lines         450      450           
=======================================
  Hits          415      415           
  Misses         35       35           

☔ 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.

@adam-fowler adam-fowler merged commit 9954c30 into main Oct 21, 2025
11 of 14 checks passed
@adam-fowler adam-fowler deleted the remove-unregistered-migrations branch October 21, 2025 16:48
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