fix: create core schema before making a first select request
Migration uses Finder to get the current table version.
This commit is contained in:
parent
c8edd241d5
commit
e182c0a21b
|
@ -287,6 +287,8 @@ bool App::DoDatabaseMigration()
|
|||
Item item;
|
||||
Group group;
|
||||
|
||||
migration.set_connector(model_connector);
|
||||
migration.create_winix_schema();
|
||||
ok = ok && Migration::do_migration(&model_connector, migration);
|
||||
ok = ok && Migration::do_migration(&model_connector, user);
|
||||
|
||||
|
|
|
@ -103,29 +103,25 @@ bool Migration::do_migration(int & current_table_version)
|
|||
bool ok = true;
|
||||
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 1, this, &Migration::do_migration_to_1);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &Migration::do_migration_to_2);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool Migration::do_migration_to_1()
|
||||
bool Migration::create_winix_schema()
|
||||
{
|
||||
// may the name of a schema (core) should be a parameter in the config?
|
||||
|
||||
const char * str = R"sql(
|
||||
create schema core
|
||||
);
|
||||
create schema if not exists core
|
||||
)sql";
|
||||
|
||||
return db_query(str);
|
||||
}
|
||||
|
||||
|
||||
bool Migration::do_migration_to_2()
|
||||
bool Migration::do_migration_to_1()
|
||||
{
|
||||
// IMPROVEME
|
||||
// what about 'create schema core'?
|
||||
// may the name of a schema (core) should be a parameter in the config?
|
||||
|
||||
const char * str = R"sql(
|
||||
create table core.migration (
|
||||
id serial,
|
||||
|
|
|
@ -78,13 +78,12 @@ public:
|
|||
static bool do_migration(morm::ModelConnector * model_connector, morm::Model & model);
|
||||
|
||||
|
||||
bool create_winix_schema();
|
||||
bool do_migration(int & current_table_version);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
bool do_migration_to_1();
|
||||
bool do_migration_to_2();
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue