evento_sql_migrator/m0003/mod.rs
1//! Migration for schema refinements.
2//!
3//! This module removes the snapshot table (no longer used) and extends the event
4//! name column for longer event type names.
5
6mod event;
7mod snapshot;
8
9use sqlx_migrator::vec_box;
10
11/// Migration that drops the snapshot table and extends the event name column.
12///
13/// This migration makes two changes to optimize the schema:
14///
15/// ## Changes
16///
17/// 1. **Drops the snapshot table** - The snapshot functionality has been removed
18/// from Evento, so this table is no longer needed.
19///
20/// 2. **Extends event.name column** - Changes the `name` column from VARCHAR(20)
21/// to VARCHAR(50) to accommodate longer event type names.
22///
23/// ## Database-Specific Notes
24///
25/// - **SQLite**: The column alteration is a no-op since SQLite doesn't support
26/// `ALTER COLUMN`. The column was already created with sufficient length.
27/// - **MySQL**: Uses `MODIFY COLUMN` syntax.
28/// - **PostgreSQL**: Uses standard `ALTER COLUMN` syntax.
29///
30/// ## Dependencies
31///
32/// This migration depends on [`M0002`](crate::M0002).
33pub struct M0003;
34
35#[cfg(feature = "sqlite")]
36sqlx_migrator::sqlite_migration!(
37 M0003,
38 "main",
39 "m0003",
40 vec_box![crate::M0002],
41 vec_box![
42 snapshot::drop_table::Operation,
43 event::alter_name_column::Operation,
44 ]
45);
46
47#[cfg(feature = "mysql")]
48sqlx_migrator::mysql_migration!(
49 M0003,
50 "main",
51 "m0003",
52 vec_box![crate::M0002],
53 vec_box![
54 snapshot::drop_table::Operation,
55 event::alter_name_column::Operation,
56 ]
57);
58
59#[cfg(feature = "postgres")]
60sqlx_migrator::postgres_migration!(
61 M0003,
62 "main",
63 "m0003",
64 vec_box![crate::M0002],
65 vec_box![
66 snapshot::drop_table::Operation,
67 event::alter_name_column::Operation,
68 ]
69);