add primary keys definition to migration rules
This commit is contained in:
parent
9c0cd6eb5e
commit
4583ab28ed
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Tomasz Sowa
|
||||
* Copyright (c) 2021-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -81,6 +81,7 @@ bool Group::do_migration(int & current_table_version)
|
|||
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 1, this, &Group::do_migration_to_1);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &Group::do_migration_to_2);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 3, this, &Group::do_migration_to_3);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -110,6 +111,15 @@ bool Group::do_migration_to_2()
|
|||
}
|
||||
|
||||
|
||||
bool Group::do_migration_to_3()
|
||||
{
|
||||
const char * str[] = {
|
||||
"ALTER TABLE core.\"group\" ADD CONSTRAINT group_pkey PRIMARY KEY (id);",
|
||||
};
|
||||
|
||||
size_t len = sizeof(str) / sizeof(const char*);
|
||||
return db_query(str, len);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -61,14 +61,14 @@ public:
|
|||
|
||||
void Clear();
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
bool do_migration_to_1();
|
||||
bool do_migration_to_2();
|
||||
|
||||
bool do_migration_to_3();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -199,6 +199,7 @@ bool Item::do_migration(int & current_table_version)
|
|||
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &Item::do_migration_to_2);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 3, this, &Item::do_migration_to_3);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 4, this, &Item::do_migration_to_4);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 5, this, &Item::do_migration_to_5);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -313,6 +314,17 @@ bool Item::do_migration_to_4()
|
|||
}
|
||||
|
||||
|
||||
bool Item::do_migration_to_5()
|
||||
{
|
||||
const char * str[] = {
|
||||
"ALTER TABLE core.item ADD CONSTRAINT item_pkey PRIMARY KEY (id);",
|
||||
};
|
||||
|
||||
size_t len = sizeof(str) / sizeof(const char*);
|
||||
return db_query(str, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Item::can_remove_child(const User * current_user, long child_user_id) const
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -174,7 +174,6 @@ public:
|
|||
*/
|
||||
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
|
||||
void propagate_connector();
|
||||
|
||||
|
@ -203,10 +202,12 @@ protected:
|
|||
|
||||
CalcItemsHelper calc_items_by_url(long parent_id, const std::wstring & url);
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
bool do_migration_to_1();
|
||||
bool do_migration_to_2();
|
||||
bool do_migration_to_3();
|
||||
bool do_migration_to_4();
|
||||
bool do_migration_to_5();
|
||||
|
||||
void print_dir(EzcEnv & env);
|
||||
void print_dir_without_slash(EzcEnv & env);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Tomasz Sowa
|
||||
* Copyright (c) 2021-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -196,6 +196,7 @@ bool ItemContent::do_migration(int & current_table_version)
|
|||
ok = ok && morm::Model::do_migration(current_table_version, 3, this, &ItemContent::do_migration_to_3);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 4, this, &ItemContent::do_migration_to_4);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 5, this, &ItemContent::do_migration_to_5);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 6, this, &ItemContent::do_migration_to_6);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -289,6 +290,13 @@ bool ItemContent::do_migration_to_5()
|
|||
}
|
||||
|
||||
|
||||
bool ItemContent::do_migration_to_6()
|
||||
{
|
||||
const char * str = "ALTER TABLE core.content ADD CONSTRAINT content_pkey PRIMARY KEY (id);";
|
||||
return db_query(str);
|
||||
}
|
||||
|
||||
|
||||
bool ItemContent::has_access(const User * current_user, int mask) const
|
||||
{
|
||||
if( current_user )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Tomasz Sowa
|
||||
* Copyright (c) 2021-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -273,7 +273,6 @@ public:
|
|||
* what about clear() from Model?
|
||||
*/
|
||||
void Clear();
|
||||
bool do_migration(int & current_table_version);
|
||||
|
||||
static bool CanContentBeHtmlFiltered(ItemContent::ContentType ct);
|
||||
static void print_content(HtmlTextStream & out, const pt::WTextStream & content, ItemContent::ContentType content_type, bool is_html_filter_on);
|
||||
|
@ -312,11 +311,13 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
bool do_migration_to_1();
|
||||
bool do_migration_to_2();
|
||||
bool do_migration_to_3();
|
||||
bool do_migration_to_4();
|
||||
bool do_migration_to_5();
|
||||
bool do_migration_to_6();
|
||||
|
||||
bool has_access(const User * current_user, int mask) const;
|
||||
bool content_type_is(const std::wstring & type);
|
||||
|
|
|
@ -150,6 +150,7 @@ bool User::do_migration(int & current_table_version)
|
|||
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 1, this, &User::do_migration_to_1);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &User::do_migration_to_2);
|
||||
ok = ok && morm::Model::do_migration(current_table_version, 3, this, &User::do_migration_to_3);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -197,6 +198,17 @@ bool User::do_migration_to_2()
|
|||
}
|
||||
|
||||
|
||||
bool User::do_migration_to_3()
|
||||
{
|
||||
const char * str[] = {
|
||||
"ALTER TABLE core.\"user\" ADD CONSTRAINT user_pkey PRIMARY KEY (id);",
|
||||
};
|
||||
|
||||
size_t len = sizeof(str) / sizeof(const char*);
|
||||
return db_query(str, len);
|
||||
}
|
||||
|
||||
|
||||
void User::display_name(EzcEnv & env)
|
||||
{
|
||||
std::wstring * dname = admin_env.get_wstr(L"display_name");
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -145,8 +145,6 @@ public:
|
|||
|
||||
void clear_passwords();
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
|
||||
void display_name(EzcEnv & env);
|
||||
|
||||
|
||||
|
@ -156,8 +154,10 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
bool do_migration_to_1();
|
||||
bool do_migration_to_2();
|
||||
bool do_migration_to_3();
|
||||
|
||||
void id_is(EzcEnv & env); // takes one argument as a user id
|
||||
bool is_guest();
|
||||
|
|
Loading…
Reference in New Issue