Skip to main content

evento_sql_migrator/m0002/
mod.rs

1//! Migration adding sub-second timestamp precision.
2//!
3//! This module adds the `timestamp_subsec` column to support microsecond/nanosecond
4//! precision for event timestamps.
5
6mod event;
7
8use sqlx_migrator::vec_box;
9
10/// Migration that adds sub-second precision to event timestamps.
11///
12/// This migration adds the `timestamp_subsec` column to the event table, allowing
13/// events to be stored with microsecond or nanosecond precision instead of just
14/// second-level precision.
15///
16/// ## Changes
17///
18/// - Adds `timestamp_subsec` column (BIGINT, NOT NULL, DEFAULT 0) to the event table
19///
20/// ## Dependencies
21///
22/// This migration depends on [`InitMigration`](crate::InitMigration).
23pub struct M0002;
24
25#[cfg(feature = "sqlite")]
26sqlx_migrator::sqlite_migration!(
27    M0002,
28    "main",
29    "m0002",
30    vec_box![crate::InitMigration],
31    vec_box![event::add_column_timestamp_subsec::Operation]
32);
33
34#[cfg(feature = "mysql")]
35sqlx_migrator::mysql_migration!(
36    M0002,
37    "main",
38    "m0002",
39    vec_box![crate::InitMigration],
40    vec_box![event::add_column_timestamp_subsec::Operation]
41);
42
43#[cfg(feature = "postgres")]
44sqlx_migrator::postgres_migration!(
45    M0002,
46    "main",
47    "m0002",
48    vec_box![crate::InitMigration],
49    vec_box![event::add_column_timestamp_subsec::Operation]
50);