#[non_exhaustive]pub struct SqlMigration {
pub id: &'static str,
pub name: &'static str,
pub sql: &'static str,
pub transactional: bool,
}Expand description
One migration step, embedded with include_str! from
crates/<module>/migrations/<dialect>/NNNN_name.sql (issue #8).
#[non_exhaustive] plus SqlMigration::new is the same fix Message
got (issue #189): a module crate cannot build this by literal, so adding
a field here stops being a breaking change across the 70+ migration sets
in the workspace (issue #255).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: &'static strSortable id: 0001, 0002, … — zero-padded so lexical order is
apply order.
name: &'static strShort slug from the file name (0001_init.sql -> init), used in
the wrangler-facing collected file names.
sql: &'static str§transactional: boolWhether the migration and its tracking row commit atomically
(the default). false marks the statements Postgres refuses inside
a transaction block (CREATE INDEX CONCURRENTLY): they run alone,
the tracking row follows, and the SQL must be idempotent —
RECONCILIATION.md §4.
Implementations§
Source§impl SqlMigration
impl SqlMigration
Sourcepub const fn new(
id: &'static str,
name: &'static str,
sql: &'static str,
) -> Self
pub const fn new( id: &'static str, name: &'static str, sql: &'static str, ) -> Self
The ordinary migration: the four-digit id, the slug from the file
name, the embedded SQL, transactional. const because every
migration set is a const array checked by
assert_migration_set, itself a const fn.
Sourcepub const fn non_transactional(self) -> Self
pub const fn non_transactional(self) -> Self
Marks the migration as running outside a transaction: for statements
Postgres refuses inside one (CREATE INDEX CONCURRENTLY).
Trait Implementations§
Source§impl Clone for SqlMigration
impl Clone for SqlMigration
Source§fn clone(&self) -> SqlMigration
fn clone(&self) -> SqlMigration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more