Skip to main content

reifydb_core/interface/catalog/
migration.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
3
4use serde::{Deserialize, Serialize};
5
6use crate::interface::catalog::id::{MigrationEventId, MigrationId};
7
8/// A migration definition stored in the catalog.
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10pub struct MigrationDef {
11	pub id: MigrationId,
12	pub name: String,
13	/// RQL source text for the migration body
14	pub body: String,
15	/// Optional RQL source text for the rollback body
16	pub rollback_body: Option<String>,
17}
18
19/// An audit trail entry for a migration apply or rollback.
20/// The CommitVersion is NOT a field — it's the MVCC version key.
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22pub struct MigrationEvent {
23	pub id: MigrationEventId,
24	pub migration_id: MigrationId,
25	pub action: MigrationAction,
26}
27
28/// The type of migration action recorded in the audit trail.
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
30pub enum MigrationAction {
31	Applied,
32	Rollback,
33}