Lightweight 0.20251202.0
Loading...
Searching...
No Matches
Lightweight::SqlMigration::Migration Class Reference

#include <SqlMigration.hpp>

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

Public Member Functions

 Migration (MigrationTimestamp timestamp, std::string_view title, std::function< void(SqlMigrationQueryBuilder &)> const &up, std::function< void(SqlMigrationQueryBuilder &)> const &down={})
 
void Up (SqlMigrationQueryBuilder &builder) const override
 
void Down (SqlMigrationQueryBuilder &builder) const override
 
bool HasDownImplementation () const noexcept override
 
- Public Member Functions inherited from Lightweight::SqlMigration::MigrationBase
 MigrationBase (MigrationBase const &)=default
 
 MigrationBase (MigrationBase &&)=delete
 
MigrationBaseoperator= (MigrationBase const &)=default
 
MigrationBaseoperator= (MigrationBase &&)=delete
 
 MigrationBase (MigrationTimestamp timestamp, std::string_view title)
 
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.

This class is a convenience class that can be used to create a migration.

Definition at line 317 of file SqlMigration.hpp.

Constructor & Destructor Documentation

◆ Migration()

Lightweight::SqlMigration::Migration::Migration ( MigrationTimestamp  timestamp,
std::string_view  title,
std::function< void(SqlMigrationQueryBuilder &)> const &  up,
std::function< void(SqlMigrationQueryBuilder &)> const &  down = {} 
)
inline

Create a new migration.

Parameters
timestampTimestamp of the migration.
titleTitle of the migration.
upFunction to apply the migration.
downFunction to revert the migration (optional).

Definition at line 326 of file SqlMigration.hpp.

Member Function Documentation

◆ Up()

void Lightweight::SqlMigration::Migration::Up ( SqlMigrationQueryBuilder builder) const
inlineoverridevirtual

Apply the migration.

Parameters
builderQuery builder to use for building the migration plan.

Implements Lightweight::SqlMigration::MigrationBase.

Definition at line 339 of file SqlMigration.hpp.

◆ Down()

void Lightweight::SqlMigration::Migration::Down ( SqlMigrationQueryBuilder builder) const
inlineoverridevirtual

Revert the migration.

Parameters
builderQuery builder to use for building the migration plan.

Reimplemented from Lightweight::SqlMigration::MigrationBase.

Definition at line 347 of file SqlMigration.hpp.

◆ HasDownImplementation()

bool Lightweight::SqlMigration::Migration::HasDownImplementation ( ) const
inlineoverridevirtualnoexcept

Check if this migration has a Down() implementation.

Returns
true if a down function was provided.

Reimplemented from Lightweight::SqlMigration::MigrationBase.

Definition at line 356 of file SqlMigration.hpp.


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