Lightweight 0.20251202.0
Loading...
Searching...
No Matches
Lightweight::SqlMigration::MigrationBase Class Referenceabstract

#include <SqlMigration.hpp>

Inheritance diagram for Lightweight::SqlMigration::MigrationBase:
Lightweight::SqlMigration::Migration

Public Member Functions

 MigrationBase (MigrationBase const &)=default
 
 MigrationBase (MigrationBase &&)=delete
 
MigrationBaseoperator= (MigrationBase const &)=default
 
MigrationBaseoperator= (MigrationBase &&)=delete
 
 MigrationBase (MigrationTimestamp timestamp, std::string_view title)
 
virtual void Up (SqlMigrationQueryBuilder &plan) const =0
 
virtual void Down (SqlMigrationQueryBuilder &) const
 
virtual bool HasDownImplementation () const noexcept
 
MigrationTimestamp GetTimestamp () const noexcept
 
std::string_view GetTitle () const noexcept
 
LIGHTWEIGHT_API std::string ComputeChecksum (SqlQueryFormatter const &formatter) const
 

Detailed Description

Represents a single unique SQL migration.

Definition at line 243 of file SqlMigration.hpp.

Constructor & Destructor Documentation

◆ MigrationBase()

Lightweight::SqlMigration::MigrationBase::MigrationBase ( MigrationTimestamp  timestamp,
std::string_view  title 
)
inline

Definition at line 250 of file SqlMigration.hpp.

Member Function Documentation

◆ Up()

virtual void Lightweight::SqlMigration::MigrationBase::Up ( SqlMigrationQueryBuilder plan) const
pure virtual

Apply the migration.

Parameters
planQuery builder to use for building the migration plan.

Implemented in Lightweight::SqlMigration::Migration.

◆ Down()

virtual void Lightweight::SqlMigration::MigrationBase::Down ( SqlMigrationQueryBuilder ) const
inlinevirtual

Revert the migration.

Parameters
planQuery builder to use for building the migration plan.

Reimplemented in Lightweight::SqlMigration::Migration.

Definition at line 267 of file SqlMigration.hpp.

◆ HasDownImplementation()

virtual bool Lightweight::SqlMigration::MigrationBase::HasDownImplementation ( ) const
inlinevirtualnoexcept

Check if this migration has a Down() implementation for rollback.

This method determines whether the migration can be safely reverted. The default implementation returns false. Derived classes that implement Down() should override this to return true.

Returns
true if Down() is implemented and can revert this migration.

Reimplemented in Lightweight::SqlMigration::Migration.

Definition at line 276 of file SqlMigration.hpp.

◆ GetTimestamp()

MigrationTimestamp Lightweight::SqlMigration::MigrationBase::GetTimestamp ( ) const
inlinenoexcept

Get the timestamp of the migration.

Returns
Timestamp of the migration.

Definition at line 284 of file SqlMigration.hpp.

◆ GetTitle()

std::string_view Lightweight::SqlMigration::MigrationBase::GetTitle ( ) const
inlinenoexcept

Get the title of the migration.

Returns
Title of the migration.

Definition at line 292 of file SqlMigration.hpp.

◆ ComputeChecksum()

LIGHTWEIGHT_API std::string Lightweight::SqlMigration::MigrationBase::ComputeChecksum ( SqlQueryFormatter const &  formatter) const

Compute SHA-256 checksum of migration's Up() SQL statements.

The checksum is computed from the SQL statements that would be executed by this migration. This allows detecting if a migration has been modified after it was applied.

Parameters
formatterThe SQL query formatter to use for generating SQL.
Returns
SHA-256 hex string (64 characters).

The documentation for this class was generated from the following file: