mixtape_tools/sqlite/migration/
types.rs

1//! Types for migration management
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// A database schema migration
7#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
8pub struct Migration {
9    /// Unique version identifier (timestamp-based)
10    pub version: String,
11
12    /// Human-readable description of the migration
13    pub name: String,
14
15    /// The SQL DDL to execute
16    pub sql: String,
17
18    /// When the migration was applied (None = pending)
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub applied_at: Option<String>,
21
22    /// SHA256 checksum of the SQL for integrity verification
23    pub checksum: String,
24}
25
26/// Filter for listing migrations by their application status
27#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
28#[serde(rename_all = "lowercase")]
29pub enum MigrationStatusFilter {
30    /// Show all migrations (no filtering)
31    #[default]
32    All,
33    /// Only pending (not yet applied) migrations
34    Pending,
35    /// Only applied migrations
36    Applied,
37}