An easy way to migrate the database schema from your application in C++/Qt.
Add a json file in the resources of your Qt application.
Enter your first migration.
{
"Migrations": [
{
"Description": "CREATE MY FIRST TABLE",
"DownVersion": [
"DROP TABLE USERS;"
],
"UpVersion": [
"CREATE TABLE "USERS" ",
"(",
" "ID" serial NOT NULL, ",
" "NAME" character varying ",
")",
"WITH (",
" OIDS=FALSE",
");",
"ALTER TABLE "USERS" ",
" OWNER TO postgres;"
],
"Version": "1"
}
]
}
And simply migrate.
#include "laycan.h"
Laycan laycan;
bool ok = laycan.Migrate(":/MyMigrations.json"); //Your Migration File
if(!ok) {
QMessageBox::critical(this, "An error occurred during migration", laycan.lastError());
}