pub struct PgBackend { /* private fields */ }Expand description
A PostgreSQL database behind an sqlx pool.
Implementations§
Source§impl PgBackend
impl PgBackend
Sourcepub async fn migrate(
&self,
migrations: &[Migration],
) -> Result<MigrateReport, MigrateError>
pub async fn migrate( &self, migrations: &[Migration], ) -> Result<MigrateReport, MigrateError>
Apply migrations in version order, skipping those already applied, in the ledger
_sqlx_migrations of the connection’s current schema.
Each migration runs in its own transaction. Refuses (applying nothing further) if an applied migration’s text has changed, if the database has applied a version the program does not know, or if a migration is recorded as dirty.
Sourcepub async fn applied_versions(&self) -> Result<Vec<i64>, MigrateError>
pub async fn applied_versions(&self) -> Result<Vec<i64>, MigrateError>
The versions the ledger says succeeded, ascending; empty if there is no ledger yet.
Source§impl PgBackend
impl PgBackend
Sourcepub async fn connect_with(
secret: &ConnectionSecret,
options: &ConnectOptions,
) -> Result<Self, RelError>
pub async fn connect_with( secret: &ConnectionSecret, options: &ConnectOptions, ) -> Result<Self, RelError>
Connect with an explicit TLS policy and pool bounds, to a connection string held as a
ConnectionSecret (resolved here, never printed).
Sourcepub async fn connection_is_encrypted(&self) -> Result<bool, RelError>
pub async fn connection_is_encrypted(&self) -> Result<bool, RelError>
Whether the connection this backend uses is encrypted, as the server reports it
(pg_stat_ssl), not as the client was asked.
Source§impl PgBackend
impl PgBackend
Sourcepub async fn connect(url: &str) -> Result<Self, RelError>
pub async fn connect(url: &str) -> Result<Self, RelError>
Connect with default pool settings and read the server version.
Prefer PgBackend::connect_secret: a &str URL is one Debug print from a log file.
Sourcepub async fn connect_secret(secret: &ConnectionSecret) -> Result<Self, RelError>
pub async fn connect_secret(secret: &ConnectionSecret) -> Result<Self, RelError>
Connect with a connection string held as a persistant_relational::ConnectionSecret:
resolved here, never printed, never part of an error.
Trait Implementations§
Source§impl RelationalBackend for PgBackend
impl RelationalBackend for PgBackend
Source§type Tx<'a> = PgTx<'a>
type Tx<'a> = PgTx<'a>
commit rolls it back.Source§async fn execute(&self, sql: &str, params: &[Value]) -> Result<u64, RelError>
async fn execute(&self, sql: &str, params: &[Value]) -> Result<u64, RelError>
Auto Trait Implementations§
impl !RefUnwindSafe for PgBackend
impl !UnwindSafe for PgBackend
impl Freeze for PgBackend
impl Send for PgBackend
impl Sync for PgBackend
impl Unpin for PgBackend
impl UnsafeUnpin for PgBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more