Browse Source

run migrations on db init

main
Stefan Pranger 3 years ago
parent
commit
806e9e5c5a
  1. 11
      db/create.h

11
db/create.h

@ -1,12 +1,17 @@
#pragma once
#include <db/db.h>
#include <db/Schema.h>
#include <string>
namespace db {
sql::Database init(std::string name) {
sql::Database db(name, SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
DEBUG << "SQLite database file '" << db.getFilename().c_str() << "' opened successfully\n";
sql::Database* init(std::string name) {
sql::Database* db = new sql::Database(name, SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
DEBUG << "SQLite database file '" << db->getFilename().c_str() << "' opened successfully\n";
Schema* schema = new Schema(db);
schema->run_migrations();
return db;
}
}
Loading…
Cancel
Save