added option do_migration_to_winix_fullmorm do the config (only temporarily)
if true then we make Item::do_migration() and exit
This commit is contained in:
parent
4b71530f4c
commit
ccda2bc2fd
|
@ -286,12 +286,16 @@ bool App::Init()
|
||||||
//model_connector.set_doc_connector(doc_html_connector);
|
//model_connector.set_doc_connector(doc_html_connector);
|
||||||
|
|
||||||
// temporary
|
// temporary
|
||||||
|
if( config.space.to_bool(L"do_migration_to_winix_fullmorm", false) )
|
||||||
|
{
|
||||||
Item item_temp;
|
Item item_temp;
|
||||||
item_temp.set_connector(model_connector);
|
item_temp.set_connector(model_connector);
|
||||||
item_temp.do_migration(&model_connector);
|
item_temp.do_migration(&model_connector, log);
|
||||||
//std::exit(0);
|
|
||||||
// -----------
|
|
||||||
|
|
||||||
|
log << log1 << "Migrations complete, now remove do_migration_to_winix_fullmorm from the config" << logend;
|
||||||
|
std::exit(0);
|
||||||
|
}
|
||||||
|
/////////////
|
||||||
|
|
||||||
db_conn.SetConnParam(config.db_database, config.db_user, config.db_pass);
|
db_conn.SetConnParam(config.db_database, config.db_user, config.db_pass);
|
||||||
db_conn.WaitForConnection();
|
db_conn.WaitForConnection();
|
||||||
|
|
|
@ -223,21 +223,23 @@ return !is_that_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Item::do_migration(morm::ModelConnector * model_connector)
|
void Item::do_migration(morm::ModelConnector * model_connector, Log & log)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
///////
|
|
||||||
|
|
||||||
morm::Finder<Item> finder(model_connector);
|
morm::Finder<Item> finder(model_connector);
|
||||||
|
|
||||||
std::list<Item> list = finder.select().where().eq(L"type", static_cast<int>(Item::dir)).eq(L"content_id", -1).get_list();
|
std::list<Item> list = finder.
|
||||||
|
select().
|
||||||
// for(Item & item : list)
|
where().
|
||||||
// {
|
eq(L"type", static_cast<int>(Item::dir)).
|
||||||
// item.item_content.set_save_mode(morm::Model::DO_INSERT_ON_SAVE);
|
eq(L"content_id", -1).
|
||||||
// item.save();
|
get_list();
|
||||||
// }
|
|
||||||
|
|
||||||
|
for(Item & item : list)
|
||||||
|
{
|
||||||
|
log << "updating item id: " << item.id << ", type: " << (int)item.type << ", url: " << item.url << ", subject: " << item.subject << logend << logsave;
|
||||||
|
item.item_content.set_save_mode(morm::Model::DO_INSERT_ON_SAVE);
|
||||||
|
item.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::propagate_connector()
|
void Item::propagate_connector()
|
||||||
|
|
|
@ -40,6 +40,11 @@
|
||||||
#include "models/itemcontent.h"
|
#include "models/itemcontent.h"
|
||||||
|
|
||||||
|
|
||||||
|
// temporary
|
||||||
|
#include "core/log.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Winix
|
namespace Winix
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -173,7 +178,7 @@ public:
|
||||||
/*
|
/*
|
||||||
* temporary
|
* temporary
|
||||||
*/
|
*/
|
||||||
static void do_migration(morm::ModelConnector * model_connector);
|
void do_migration(morm::ModelConnector * model_connector, Log & log);
|
||||||
|
|
||||||
void propagate_connector();
|
void propagate_connector();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue