1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Database migrations: revision-based schema changes with up/down.
//!
//! A migration describes a schema change and how to undo it. The
//! [`SchemaManager`] handed to its `up`/`down` offers a fluent, backend-neutral DDL
//! builder; the [`render`] layer turns that into SQL for the active dialect. A
//! migration's rendered DDL is also what a later runner hashes into a stable
//! checksum and applies in revision order.
//!
//! This module is the migration engine; the command-line tooling that scaffolds and
//! drives migrations is separate.
//!
//! # Examples
//!
//! ```
//! use tork_orm_core::dialect::SqliteDialect;
//! use tork_orm_core::migration::{Column, ForeignKey, ForeignKeyAction, SchemaManager};
//!
//! # async fn run() -> tork_orm_core::Result<()> {
//! let dialect = SqliteDialect::new();
//! let mut schema = SchemaManager::collect(&dialect);
//! schema
//! .create_table("posts")
//! .column(Column::new("id").bigint().primary_key().auto_increment())
//! .column(Column::new("user_id").bigint().not_null())
//! .column(Column::new("title").varchar(255).not_null())
//! .foreign_key(
//! ForeignKey::new()
//! .from("posts", "user_id")
//! .to("users", "id")
//! .on_delete(ForeignKeyAction::Cascade),
//! )
//! .execute()
//! .await?;
//! assert!(schema.into_collected()[0].contains("FOREIGN KEY"));
//! # Ok(())
//! # }
//! ```
// `BoxFuture` lives at the crate root so both migrations and transactions share
// the same type alias. Re-export it from this module so the `#[migration]`
// macro (which emits `::tork_orm::migration::BoxFuture`) continues to work.
pub use crateBoxFuture;
pub use ;
pub use crate;
pub use ;
pub use ;
pub use ;
pub use ;
/// The common imports for writing a migration.