Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Versioning.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Database_SQL_ORM_Versioning_h_
5#define _Stroika_Foundation_Database_SQL_ORM_Versioning_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
12
13/**
14 * \file
15 *
16 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
17 *
18 * TODO:
19 * \todo Store and pass along actually stored version, and do upgrading.
20 *
21 * \todo Provide configuration options and ability to EITHER version# tables (table-v) or do
22 * that at the database level (differnt connection) - so must be able to construct the connection
23 * from here). A sensible pattern is what I do for WTF, where I say db-v3, db-v4 etccc each time
24 * I change db version, and have migration code to migrate data from v3 to v4.
25 *
26 * todo this maybe have IN-ConnectionPtr and OUT-Connection-Ptr in TableProvisioner API? or
27 * pair<Connection::Ptr,optional<Version>> from, and same-type to. maybe optional<pair> for the
28 * from for the case of no DB to start with.
29 *
30 * Extend versioninfo so we track actual app code version and format version; (so instead of pair<>
31 * probably struct).
32 */
33
34namespace Stroika::Foundation::Database::SQL::ORM {
35
36 using namespace Containers;
37 using namespace DataExchange;
38
39 /**
40 */
41 struct TableProvisioner {
42 String fTableName;
43 function<void (SQL::Connection::Ptr, optional<Common::Version> existingVersion, Common::Version targetVersion)> fProvisioner;
44 };
45
46 /**
47 * @todo HANDLE THE VERSIONING piece - have hardwired version table, and add support to provisioner to UPGRADE tables
48 * EVENTAULLY even support upgrade by migrating to new DB, but for now in-place is good enuf
49 */
50 void ProvisionForVersion (SQL::Connection::Ptr conn, Common::Version targetDBVersion, const Traversal::Iterable<Schema::Table>& tables);
51 void ProvisionForVersion (SQL::Connection::Ptr conn, Common::Version targetDBVersion, const Traversal::Iterable<TableProvisioner>& tables);
52
53}
54
55/*
56 ********************************************************************************
57 ***************************** Implementation Details ***************************
58 ********************************************************************************
59 */
60#include "Versioning.inl"
61
62#endif /*_Stroika_Foundation_Database_SQL_ORM_Versioning_h_*/
void ProvisionForVersion(SQL::Connection::Ptr conn, Common::Version targetDBVersion, const Traversal::Iterable< Schema::Table > &tables)