Skip to content

Commit 4b5341b

Browse files
committed
Add migration
1 parent 0042d48 commit 4b5341b

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

backend-rust/src/migrations.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@ pub enum SchemaVersion {
171171
performance."
172172
)]
173173
IndexBlocksWithNoCumulativeFinTime,
174+
#[display("0003:PayDayPoolCommissionRates")]
175+
PayDayPoolCommissionRates,
174176
}
175177
impl SchemaVersion {
176178
/// The minimum supported database schema version for the API.
177179
/// Fails at startup if any breaking database schema versions have been
178180
/// introduced since this version.
179181
pub const API_SUPPORTED_SCHEMA_VERSION: SchemaVersion = SchemaVersion::InitialFirstHalf;
180182
/// The latest known version of the schema.
181-
const LATEST: SchemaVersion = SchemaVersion::IndexBlocksWithNoCumulativeFinTime;
183+
const LATEST: SchemaVersion = SchemaVersion::PayDayPoolCommissionRates;
182184

183185
/// Parse version number into a database schema version.
184186
/// None if the version is unknown.
@@ -196,6 +198,7 @@ impl SchemaVersion {
196198
SchemaVersion::Empty => false,
197199
SchemaVersion::InitialFirstHalf => false,
198200
SchemaVersion::IndexBlocksWithNoCumulativeFinTime => false,
201+
SchemaVersion::PayDayPoolCommissionRates => false,
199202
}
200203
}
201204

@@ -219,7 +222,11 @@ impl SchemaVersion {
219222
.await?;
220223
SchemaVersion::IndexBlocksWithNoCumulativeFinTime
221224
}
222-
SchemaVersion::IndexBlocksWithNoCumulativeFinTime => unimplemented!(
225+
SchemaVersion::IndexBlocksWithNoCumulativeFinTime => {
226+
tx.as_mut().execute(sqlx::raw_sql(include_str!("./migrations/m0003.sql"))).await?;
227+
SchemaVersion::PayDayPoolCommissionRates
228+
}
229+
SchemaVersion::PayDayPoolCommissionRates => unimplemented!(
223230
"No migration implemented for database schema version {}",
224231
self.as_i64()
225232
),

backend-rust/src/migrations/m0001-initialize.sql

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,6 @@ CREATE TABLE bakers(
349349
-- Stored as a fraction of an amount with a precision of `1/100_000`.
350350
finalization_commission
351351
BIGINT,
352-
-- Fraction of transaction rewards rewarded at payday to this baker pool.
353-
-- Stored as a fraction of an amount with a precision of `1/100_000`.
354-
payday_transaction_commission
355-
BIGINT,
356-
-- Fraction of baking rewards rewarded at payday to this baker pool.
357-
-- Stored as a fraction of an amount with a precision of `1/100_000`.
358-
payday_baking_commission
359-
BIGINT,
360-
-- Fraction of finalization rewards rewarded at payday to this baker pool.
361-
-- Stored as a fraction of an amount with a precision of `1/100_000`.
362-
payday_finalization_commission
363-
BIGINT,
364352
-- Transaction used for self-suspending.
365353
-- This is not null only when a baker is suspended due to sending the transaction for
366354
-- self-suspending.

backend-rust/src/migrations/m0003.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ALTER TABLE bakers
2+
-- Fraction of transaction rewards rewarded at payday to this baker pool.
3+
-- Stored as a fraction of an amount with a precision of `1/100_000`.
4+
ADD COLUMN payday_transaction_commission BIGINT,
5+
-- Fraction of baking rewards rewarded at payday to this baker pool.
6+
-- Stored as a fraction of an amount with a precision of `1/100_000`.
7+
ADD COLUMN payday_baking_commission BIGINT,
8+
-- Fraction of finalization rewards rewarded at payday to this baker pool.
9+
-- Stored as a fraction of an amount with a precision of `1/100_000`.
10+
ADD COLUMN payday_finalization_commission BIGINT;

0 commit comments

Comments
 (0)