This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
forked from fnc12/sqlite_orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_schema_result.h
61 lines (51 loc) · 2.01 KB
/
sync_schema_result.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <ostream>
namespace sqlite_orm {
enum class sync_schema_result {
/**
* created new table, table with the same tablename did not exist
*/
new_table_created,
/**
* table schema is the same as storage, nothing to be done
*/
already_in_sync,
/**
* removed excess columns in table (than storage) without dropping a table
*/
old_columns_removed,
/**
* lacking columns in table (than storage) added without dropping a table
*/
new_columns_added,
/**
* both old_columns_removed and new_columns_added
*/
new_columns_added_and_old_columns_removed,
/**
* old table is dropped and new is recreated. Reasons :
* 1. delete excess columns in the table than storage if preseve = false
* 2. Lacking columns in the table cannot be added due to NULL and DEFAULT constraint
* 3. Reasons 1 and 2 both together
* 4. data_type mismatch between table and storage.
*/
dropped_and_recreated,
};
inline std::ostream& operator<<(std::ostream& os, sync_schema_result value) {
switch(value) {
case sync_schema_result::new_table_created:
return os << "new table created";
case sync_schema_result::already_in_sync:
return os << "table and storage is already in sync.";
case sync_schema_result::old_columns_removed:
return os << "old excess columns removed";
case sync_schema_result::new_columns_added:
return os << "new columns added";
case sync_schema_result::new_columns_added_and_old_columns_removed:
return os << "old excess columns removed and new columns added";
case sync_schema_result::dropped_and_recreated:
return os << "old table dropped and recreated";
}
return os;
}
}