OpenCPN Partial API docs
Loading...
Searching...
No Matches
navobj_db_migrator.h
Go to the documentation of this file.
1
/***************************************************************************
2
* Copyright (C) 2026 by David S. Register *
3
* *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
8
* *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
13
* *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, see <https://www.gnu.org/licenses/>. *
16
**************************************************************************/
17
23
#ifndef _NAVOBJ_DB_MIGRATOR_H__
24
#define _NAVOBJ_DB_MIGRATOR_H__
25
26
#pragma once
27
#include <sqlite3.h>
28
#include <functional>
29
#include <vector>
30
#include <string>
31
32
class
DbMigrator
{
33
public
:
34
using
MigrationFn = std::function<void(sqlite3*)>;
35
36
struct
Migration
{
37
int
version;
38
MigrationFn fn;
39
};
40
41
explicit
DbMigrator
(sqlite3* db);
42
43
void
addMigration(
int
version, MigrationFn fn);
44
void
migrate();
45
46
private
:
47
sqlite3* db_;
48
std::vector<Migration> migrations_;
49
50
int
getUserVersion();
51
void
setUserVersion(
int
v);
52
53
void
exec(
const
std::string& sql);
54
void
begin();
55
void
commit();
56
void
rollback();
57
};
58
59
#endif
DbMigrator
Definition
navobj_db_migrator.h:32
DbMigrator::Migration
Definition
navobj_db_migrator.h:36
model
include
model
navobj_db_migrator.h
Generated on Fri Apr 10 2026 04:13:01 for OpenCPN Partial API docs by
1.9.8