|
Lightweight 0.20251202.0
|
Query builder for building SQL migration queries. More...
#include <Migrate.hpp>
Public Member Functions | |
| SqlMigrationQueryBuilder (SqlQueryFormatter const &formatter) | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | WithSchema (std::string schemaName) |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | CreateDatabase (std::string_view databaseName) |
| Creates a new database. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | DropDatabase (std::string_view databaseName) |
| Drops a database. | |
| LIGHTWEIGHT_API SqlCreateTableQueryBuilder | CreateTable (std::string_view tableName) |
| Creates a new table. | |
| LIGHTWEIGHT_API SqlCreateTableQueryBuilder | CreateTableIfNotExists (std::string_view tableName) |
| LIGHTWEIGHT_API SqlAlterTableQueryBuilder | AlterTable (std::string_view tableName) |
| Alters an existing table. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | DropTable (std::string_view tableName) |
| Drops a table. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | DropTableIfExists (std::string_view tableName) |
| Drops a table if it exists. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | DropTableCascade (std::string_view tableName) |
| template<typename Record > | |
| SqlCreateTableQueryBuilder | CreateTable () |
| Creates a new table for the given record type. | |
| template<typename Record > | |
| SqlAlterTableQueryBuilder | AlterTable () |
| Alters an existing table. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | RawSql (std::string_view sql) |
| Executes raw SQL. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | CreateIndex (std::string indexName, std::string tableName, std::vector< std::string > columns, bool unique=false) |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | CreateUniqueIndex (std::string indexName, std::string tableName, std::vector< std::string > columns) |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | CreateIndex (std::string tableName, std::vector< std::string > columns, IndexType type=IndexType::NonUnique) |
| LIGHTWEIGHT_API SqlMigrationInsertBuilder | Insert (std::string_view tableName) |
| Creates an INSERT statement for the migration. | |
| LIGHTWEIGHT_API SqlMigrationUpdateBuilder | Update (std::string_view tableName) |
| Creates an UPDATE statement for the migration. | |
| LIGHTWEIGHT_API SqlMigrationDeleteBuilder | Delete (std::string_view tableName) |
| Creates a DELETE statement for the migration. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | Native (std::function< std::string(SqlConnection &)> callback) |
| Executes SQL interactively via a callback. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | BeginTransaction () |
| Starts a transaction. | |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & | CommitTransaction () |
| Commits a transaction. | |
| LIGHTWEIGHT_API SqlMigrationPlan const & | GetPlan () const & |
| Gets the migration plan. | |
| LIGHTWEIGHT_API SqlMigrationPlan | GetPlan () && |
Query builder for building SQL migration queries.
Definition at line 429 of file Migrate.hpp.
|
inlineexplicit |
Definition at line 432 of file Migrate.hpp.
| LIGHTWEIGHT_API SqlCreateTableQueryBuilder Lightweight::SqlMigrationQueryBuilder::CreateTableIfNotExists | ( | std::string_view | tableName | ) |
Creates a new table only if it does not already exist.
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & Lightweight::SqlMigrationQueryBuilder::DropTableCascade | ( | std::string_view | tableName | ) |
Drops a table and all foreign key constraints referencing it. On PostgreSQL, uses CASCADE. On MS SQL, drops FK constraints first.
|
inline |
Creates a new table for the given record type.
Definition at line 472 of file Migrate.hpp.
|
inline |
Alters an existing table.
Definition at line 483 of file Migrate.hpp.
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & Lightweight::SqlMigrationQueryBuilder::CreateIndex | ( | std::string | indexName, |
| std::string | tableName, | ||
| std::vector< std::string > | columns, | ||
| bool | unique = false |
||
| ) |
Creates an index on a table.
| indexName | The name of the index to create. |
| tableName | The name of the table to create the index on. |
| columns | The columns to include in the index. |
| unique | If true, creates a UNIQUE index. |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & Lightweight::SqlMigrationQueryBuilder::CreateUniqueIndex | ( | std::string | indexName, |
| std::string | tableName, | ||
| std::vector< std::string > | columns | ||
| ) |
Creates a unique index on a table.
| indexName | The name of the index to create. |
| tableName | The name of the table to create the index on. |
| columns | The columns to include in the index. |
| LIGHTWEIGHT_API SqlMigrationQueryBuilder & Lightweight::SqlMigrationQueryBuilder::CreateIndex | ( | std::string | tableName, |
| std::vector< std::string > | columns, | ||
| IndexType | type = IndexType::NonUnique |
||
| ) |
Creates an index on a table with auto-generated name.
The index name is automatically generated as idx_{tableName}_{col1}_{col2}_...
| tableName | The name of the table to create the index on. |
| columns | The columns to include in the index. |
| type | The type of index (NonUnique or Unique). |
| LIGHTWEIGHT_API SqlMigrationPlan Lightweight::SqlMigrationQueryBuilder::GetPlan | ( | ) | && |
Gets the migration plan.