relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
relx::migrations Namespace Reference

Namespaces

namespace  cli
 

Classes

class  AddColumnOperation
 ADD COLUMN migration operation. More...
 
class  AddColumnOperation< ColumnMetadata >
 Specialized AddColumnOperation for ColumnMetadata. More...
 
class  AddConstraintOperation
 ADD CONSTRAINT migration operation. More...
 
struct  ColumnMetadata
 Metadata about a column extracted from PFR analysis. More...
 
struct  ConstraintMetadata
 Metadata about a constraint extracted from PFR analysis. More...
 
class  CreateTableOperation
 CREATE TABLE migration operation. More...
 
class  DropColumnOperation
 DROP COLUMN migration operation. More...
 
class  DropColumnOperation< ColumnMetadata >
 Specialized DropColumnOperation for ColumnMetadata. More...
 
class  DropConstraintOperation
 DROP CONSTRAINT migration operation. More...
 
class  DropTableOperation
 DROP TABLE migration operation. More...
 
class  Migration
 Container for migration operations. More...
 
struct  MigrationError
 Error information for migration operations. More...
 
class  MigrationOperation
 Base class for migration operations. More...
 
struct  MigrationOptions
 Options for controlling migration generation. More...
 
class  ModifyColumnOperation
 MODIFY COLUMN migration operation. More...
 
class  RenameColumnOperation
 RENAME COLUMN migration operation. More...
 
class  RenameConstraintOperation
 RENAME CONSTRAINT migration operation. More...
 
struct  TableMetadata
 Complete metadata about a table. More...
 
class  UpdateDataOperation
 UPDATE DATA migration operation for column transformations. More...
 

Typedefs

template<typename T >
using MigrationResult = std::expected< T, MigrationError >
 Result type for migration operations.
 

Enumerations

enum class  MigrationErrorType {
  INVALID_TABLE_STRUCTURE , UNSUPPORTED_OPERATION , COLUMN_NOT_FOUND , CONSTRAINT_NOT_FOUND ,
  INCOMPATIBLE_TYPES , MIGRATION_GENERATION_FAILED , SQL_GENERATION_FAILED , VALIDATION_FAILED
}
 Error types for migration operations. More...
 
enum class  OperationType {
  CREATE_TABLE , DROP_TABLE , ADD_COLUMN , DROP_COLUMN ,
  RENAME_COLUMN , MODIFY_COLUMN , UPDATE_DATA , ADD_CONSTRAINT ,
  DROP_CONSTRAINT , RENAME_CONSTRAINT , ADD_INDEX , DROP_INDEX
}
 Enum for migration operation types. More...
 

Functions

template<schema::TableConcept Table>
MigrationResult< TableMetadataextract_table_metadata (const Table &table_instance)
 Extract table metadata using Boost.PFR.
 
MigrationResult< Migrationdiff_tables (const TableMetadata &old_metadata, const TableMetadata &new_metadata, const MigrationOptions &options={})
 Generate migration from table metadata differences.
 
template<schema::TableConcept OldTable, schema::TableConcept NewTable>
MigrationResult< Migrationgenerate_migration (const OldTable &old_table, const NewTable &new_table, const MigrationOptions &options={})
 Generate migration from old table to new table.
 
template<schema::TableConcept Table>
MigrationResult< Migrationgenerate_create_table_migration (const Table &table)
 Generate migration to create a new table.
 
template<schema::TableConcept Table>
MigrationResult< Migrationgenerate_drop_table_migration (const Table &table)
 Generate migration to drop a table.
 

Typedef Documentation

◆ MigrationResult

template<typename T >
using relx::migrations::MigrationResult = typedef std::expected<T, MigrationError>

Result type for migration operations.

Definition at line 53 of file core.hpp.

Enumeration Type Documentation

◆ MigrationErrorType

Error types for migration operations.

Enumerator
INVALID_TABLE_STRUCTURE 
UNSUPPORTED_OPERATION 
COLUMN_NOT_FOUND 
CONSTRAINT_NOT_FOUND 
INCOMPATIBLE_TYPES 
MIGRATION_GENERATION_FAILED 
SQL_GENERATION_FAILED 
VALIDATION_FAILED 

Definition at line 19 of file core.hpp.

◆ OperationType

Enum for migration operation types.

Enumerator
CREATE_TABLE 
DROP_TABLE 
ADD_COLUMN 
DROP_COLUMN 
RENAME_COLUMN 
MODIFY_COLUMN 
UPDATE_DATA 
ADD_CONSTRAINT 
DROP_CONSTRAINT 
RENAME_CONSTRAINT 
ADD_INDEX 
DROP_INDEX 

Definition at line 56 of file core.hpp.

Function Documentation

◆ diff_tables()

MigrationResult< Migration > relx::migrations::diff_tables ( const TableMetadata old_metadata,
const TableMetadata new_metadata,
const MigrationOptions options = {} 
)

Generate migration from table metadata differences.

Parameters
old_metadataMetadata for the old table version
new_metadataMetadata for the new table version
optionsMigration options including column/constraint mappings
Returns
Migration containing the necessary operations

◆ extract_table_metadata()

template<schema::TableConcept Table>
MigrationResult< TableMetadata > relx::migrations::extract_table_metadata ( const Table &  table_instance)

Extract table metadata using Boost.PFR.

Extract table metadata from a table instance.

Template Parameters
TableThe table type
Parameters
table_instanceInstance of the table
Returns
Metadata about the table structure
Template Parameters
TableThe table type
Parameters
tableInstance of the table
Returns
Table metadata for migration diffing

Definition at line 82 of file diff.hpp.

◆ generate_create_table_migration()

template<schema::TableConcept Table>
MigrationResult< Migration > relx::migrations::generate_create_table_migration ( const Table &  table)

Generate migration to create a new table.

Template Parameters
TableThe table type
Parameters
tableInstance of the table to create
Returns
Migration to create the table

Definition at line 218 of file diff.hpp.

◆ generate_drop_table_migration()

template<schema::TableConcept Table>
MigrationResult< Migration > relx::migrations::generate_drop_table_migration ( const Table &  table)

Generate migration to drop a table.

Template Parameters
TableThe table type
Parameters
tableInstance of the table to drop
Returns
Migration to drop the table

Definition at line 229 of file diff.hpp.

◆ generate_migration()

template<schema::TableConcept OldTable, schema::TableConcept NewTable>
MigrationResult< Migration > relx::migrations::generate_migration ( const OldTable &  old_table,
const NewTable &  new_table,
const MigrationOptions options = {} 
)

Generate migration from old table to new table.

Template Parameters
OldTableThe old table type
NewTableThe new table type
Parameters
old_tableInstance of the old table
new_tableInstance of the new table
optionsMigration options including column/constraint mappings
Returns
Migration containing the necessary operations

Definition at line 195 of file diff.hpp.