Skip to content

Commit 4220b57

Browse files
authored
Merge pull request #2692 from SatoshiPortal/merge/main-into-develop
backport main changes
2 parents 2dfe834 + 12314bd commit 4220b57

40 files changed

Lines changed: 1238 additions & 411 deletions

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Bull Bitcoin Mobile: self-custodial Bitcoin + Liquid + Lightning wallet. Flutter
3131
- **`fvm dart fix --dry-run` must print `Nothing to fix!`** before commit. If not, run `fvm dart fix --apply` and stage the result.
3232
- **Pre-commit hook is the floor.** It runs analyze + dart fix dry-run ([`.git_hooks/pre-commit`](.git_hooks/pre-commit)). **Never `--no-verify`.** If it fails, fix the cause.
3333

34+
## Database schema migration support
35+
36+
- Every database schema version shipped in a published release is immutable and must remain a supported upgrade source through the migration chain; `main` generally archives that published truth.
37+
- Before the next release, `develop` keeps exactly one pending schema revision: the latest published schema plus 1. Aggregate all unreleased schema changes into that same next migration and snapshot; never bump once per feature or commit.
38+
- Intermediate schema states that existed only in `develop` are not compatibility targets. Development installs may require a reset or reinstall; do not add production migration guards or preserve intermediate snapshots solely for them.
39+
- Before release, verify the path from the latest published `main` schema fixture to the final pending schema. Once shipped, that migration and snapshot become immutable.
40+
3441
## Monorepo / melos
3542

3643
The repo is migrating incrementally to a [melos](https://melos.invertase.dev/) pub-workspace. The Flutter app remains at the repo root through `useRootAsPackage: true`; current members are the `bull_ui` design system, its dev-only catalogue, the pure-Dart `primitives` package, the pure-Dart `bull_payjoin` package, and the Flutter `bull_tor` package. The makefile remains the canonical entry point across the workspace.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// The network a payment moves through: on-chain Bitcoin, Lightning, or
2+
/// Liquid. Shared across features (e.g. `swap`, `dca`) that need to name a
3+
/// network without depending on each other's internal types.
4+
enum PaymentNetwork { bitcoin, lightning, liquid }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:bb_mobile/core/primitives/payment_network.dart';
2+
import 'package:bb_mobile/core/utils/build_context_x.dart';
3+
import 'package:flutter/widgets.dart';
4+
5+
/// Kept in its own file so [PaymentNetwork] itself stays Flutter-free.
6+
extension PaymentNetworkL10n on PaymentNetwork {
7+
String toTranslated(BuildContext context) => switch (this) {
8+
PaymentNetwork.bitcoin => context.loc.transactionNetworkBitcoin,
9+
PaymentNetwork.lightning => context.loc.transactionNetworkLightning,
10+
PaymentNetwork.liquid => context.loc.transactionNetworkLiquid,
11+
};
12+
}

lib/core/storage/migrations/schema_13_to_14.dart

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import 'package:drift/drift.dart';
88
/// - Records which home announcements the user has dismissed (announcement id
99
/// + dismissal timestamp). New table, created empty.
1010
///
11-
/// During development, schema 14 briefly carried the Payjoin policy columns on
12-
/// `settings` and an `is_aborted` flag on the payjoin tables. Payjoin now owns
13-
/// its own database (payjoin.sqlite, see the bull_payjoin package), so those
14-
/// columns were folded out before schema 14 shipped in v6.13.0 rather than
15-
/// added and then migrated away.
11+
/// Schema 14 also briefly carried the Payjoin policy columns on `settings` and
12+
/// an `is_aborted` flag on the payjoin tables. Payjoin now owns its own
13+
/// database (payjoin.sqlite, see the bull_payjoin package), and 14 was never
14+
/// released — every tag up to v6.12.5 ships schema 13 — so those columns were
15+
/// folded out of this step rather than added and then migrated away.
1616
///
1717
/// Adds the order_swaps table and indexes for crash-safe Exchange transfers.
1818
/// The table includes the nullable quoted_amount_sat column used to validate
@@ -59,18 +59,6 @@ class Schema13To14 {
5959
() => m.createIndex(schema14.orderSwapsLocalPayinTxid),
6060
'order_swaps_local_payin_txid index',
6161
);
62-
63-
await _addColumnIfNotExists(
64-
() => m.addColumn(schema14.settings, schema14.settings.torTransportMode),
65-
'settings.tor_transport_mode column',
66-
);
67-
await _addColumnIfNotExists(
68-
() => m.addColumn(
69-
schema14.settings,
70-
schema14.settings.lastSuccessfulTorTransport,
71-
),
72-
'settings.last_successful_tor_transport column',
73-
);
7462
}
7563
}
7664

@@ -91,18 +79,3 @@ Future<void> _createIfNotExists(
9179
);
9280
}
9381
}
94-
95-
Future<void> _addColumnIfNotExists(
96-
Future<void> Function() addColumn,
97-
String description,
98-
) async {
99-
try {
100-
await addColumn();
101-
} catch (e) {
102-
if (!e.toString().contains('duplicate column name')) rethrow;
103-
log.warning(
104-
'Schema13To14: $description already exists — skipping add',
105-
error: e,
106-
);
107-
}
108-
}

lib/core/storage/schemas/bull_database/drift_schema_v14.json

Lines changed: 1 addition & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)