Lightweight 0.20260303.0
Loading...
Searching...
No Matches
SQL Migration

Classes and functions for SQL schema migrations. More...

Classes

struct  Lightweight::SqlMigration::MigrationTimestamp
 
struct  Lightweight::SqlMigration::ChecksumVerificationResult
 
struct  Lightweight::SqlMigration::RevertResult
 
struct  Lightweight::SqlMigration::MigrationStatus
 
class  Lightweight::SqlMigration::MigrationManager
 
class  Lightweight::SqlMigration::MigrationBase
 
class  Lightweight::SqlMigration::Migration
 
class  Lightweight::SqlMigration::MigrationLock
 

Macros

#define LIGHTWEIGHT_MIGRATION_PLUGIN()
 
#define LIGHTWEIGHT_MIGRATION_INSTANCE(timestamp)   migration_##timestamp
 Represents the C++ migration object for a given timestamped migration.
 
#define LIGHTWEIGHT_SQL_MIGRATION(timestamp, description)
 Creates a new migration.
 

Detailed Description

Classes and functions for SQL schema migrations.

Macro Definition Documentation

◆ LIGHTWEIGHT_MIGRATION_PLUGIN

#define LIGHTWEIGHT_MIGRATION_PLUGIN ( )
Value:
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
extern "C" LIGHTWEIGHT_EXPORT Lightweight::SqlMigration::MigrationManager* AcquireMigrationManager() \
{ \
}
static LIGHTWEIGHT_API MigrationManager & GetInstance()

Requires the user to call LIGHTWEIGHT_MIGRATION_PLUGIN() in exactly one CPP file of the migration plugin.

Definition at line 240 of file SqlMigration.hpp.

◆ LIGHTWEIGHT_MIGRATION_INSTANCE

#define LIGHTWEIGHT_MIGRATION_INSTANCE (   timestamp)    migration_##timestamp

Represents the C++ migration object for a given timestamped migration.

Parameters
timestampTimestamp of the migration.

Definition at line 386 of file SqlMigration.hpp.

◆ LIGHTWEIGHT_SQL_MIGRATION

#define LIGHTWEIGHT_SQL_MIGRATION (   timestamp,
  description 
)
Value:
struct Migration_##timestamp: public Lightweight::SqlMigration::MigrationBase \
{ \
explicit Migration_##timestamp(): \
Lightweight::SqlMigration::MigrationBase(Lightweight::SqlMigration::MigrationTimestamp { timestamp }, \
description) \
{ \
} \
\
void Up(Lightweight::SqlMigrationQueryBuilder& plan) const override; \
void Down(Lightweight::SqlMigrationQueryBuilder& /*plan*/) const override {} \
}; \
\
static Migration_##timestamp _LIGHTWEIGHT_CONCATENATE(migration_, timestamp); \
\
void Migration_##timestamp::Up(Lightweight::SqlMigrationQueryBuilder& plan) const
Query builder for building SQL migration queries.
Definition Migrate.hpp:436

Creates a new migration.

Parameters
timestampTimestamp of the migration.
descriptionDescription of the migration.
Note
The migration will be registered with the migration manager automatically.
#include <Lightweight/SqlMigration.hpp>
LIGHTWEIGHT_SQL_MIGRATION(20260117234120, "Create table 'MyTable'")
{
// Use 'plan' to define the migration steps, for example creating tables.
}
#define LIGHTWEIGHT_SQL_MIGRATION(timestamp, description)
Creates a new migration.
See also
Lightweight::SqlMigrationQueryBuilder

Definition at line 406 of file SqlMigration.hpp.