pub struct Migration { /* private fields */ }std only.Expand description
A migration with its SQL content
Represents a single migration that can be applied to the database.
The hash field is used to track which migrations have been applied.
Implementations§
Source§impl Migration
impl Migration
Sourcepub fn new(tag: &str, sql: &str) -> Migration
pub fn new(tag: &str, sql: &str) -> Migration
Create a new migration from embedded SQL
The hash is computed from the SQL content.
SQL is split on "--> statement-breakpoint" markers.
Sourcepub fn with_hash(
tag: impl Into<String>,
hash: impl Into<String>,
created_at: i64,
sql: Vec<String>,
) -> Migration
pub fn with_hash( tag: impl Into<String>, hash: impl Into<String>, created_at: i64, sql: Vec<String>, ) -> Migration
Create a migration with explicit hash and timestamp
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the migration folder name used by drizzle-orm tracking metadata.
Sourcepub const fn created_at(&self) -> i64
pub const fn created_at(&self) -> i64
Get the creation timestamp
Sourcepub fn statements(&self) -> &[String]
pub fn statements(&self) -> &[String]
Get the raw SQL statements (already split).
SQLite transaction-owning adapters must use Self::sqlite_execution
instead so foreign-key suspension sentinels are handled outside the
transaction.
Sourcepub fn sqlite_execution(
&self,
) -> Result<SqliteMigrationExecution<'_>, SqliteMigrationExecutionError>
pub fn sqlite_execution( &self, ) -> Result<SqliteMigrationExecution<'_>, SqliteMigrationExecutionError>
Validate SQLite foreign-key suspension sentinels and prepare the statement stream for a transaction-owning runtime adapter.
§Errors
Returns SqliteMigrationExecutionError when foreign-key suspension
pragmas are nested, unbalanced, or use an unsupported assignment form.
Sourcepub fn has_postgres_concurrent_index(&self) -> bool
pub fn has_postgres_concurrent_index(&self) -> bool
Whether this migration contains a PostgreSQL concurrent-index command.