mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
MIgrations for the rbac module.
This commit is contained in:
parent
e1ceb543f3
commit
32d370bfa3
@ -14,6 +14,10 @@ void RBACController::handle_request_main(Request *request) {
|
||||
void RBACController::create_validators() {
|
||||
}
|
||||
|
||||
void RBACController::admin_handle_request_main(Request *request) {
|
||||
|
||||
}
|
||||
|
||||
void RBACController::admin_add_section_links(Vector<AdminSectionLinkInfo> *links) {
|
||||
links->push_back(AdminSectionLinkInfo("Test", "test"));
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
void handle_request_main(Request *request);
|
||||
void create_validators();
|
||||
|
||||
void admin_handle_request_main(Request *request);
|
||||
void admin_add_section_links(Vector<AdminSectionLinkInfo> *links);
|
||||
|
||||
static RBACController *get_singleton();
|
||||
|
@ -6,29 +6,46 @@
|
||||
#include "core/database/query_result.h"
|
||||
#include "core/database/table_builder.h"
|
||||
|
||||
#define RBAC_RANK_TABLE "rbac_ranks"
|
||||
#define RBAC_PERMISSION_TABLE "rbac_permissions"
|
||||
|
||||
void RBACModel::create_table() {
|
||||
Ref<TableBuilder> tb = DatabaseManager::get_singleton()->ddb->get_table_builder();
|
||||
|
||||
tb->create_table(_table_name);
|
||||
tb->create_table(RBAC_RANK_TABLE);
|
||||
tb->integer("id")->auto_increment()->next_row();
|
||||
tb->varchar("username", 60)->not_null()->next_row();
|
||||
tb->varchar("email", 100)->not_null()->next_row();
|
||||
tb->integer("rank")->not_null()->next_row();
|
||||
tb->varchar("pre_salt", 100)->next_row();
|
||||
tb->varchar("post_salt", 100)->next_row();
|
||||
tb->varchar("password_hash", 100)->next_row();
|
||||
tb->integer("banned")->next_row();
|
||||
tb->varchar("password_reset_token", 100)->next_row();
|
||||
tb->integer("locked")->next_row();
|
||||
tb->varchar("name", 60)->not_null()->next_row();
|
||||
tb->varchar("name_internal", 100)->not_null()->next_row();
|
||||
tb->varchar("settings", 200)->not_null()->next_row();
|
||||
tb->integer("rank_permissions")->not_null()->next_row();
|
||||
tb->primary_key("id");
|
||||
tb->ccreate_table();
|
||||
//tb->run_query();
|
||||
//tb->print();
|
||||
|
||||
//tb->result = "";
|
||||
|
||||
tb->create_table(RBAC_PERMISSION_TABLE);
|
||||
tb->integer("id")->auto_increment()->next_row();
|
||||
tb->integer("rank_id")->not_null()->next_row();
|
||||
tb->varchar("name", 60)->not_null()->next_row();
|
||||
tb->varchar("url", 100)->not_null()->next_row();
|
||||
|
||||
tb->integer("revoke")->not_null()->next_row();
|
||||
tb->integer("sort_order")->not_null()->next_row();
|
||||
tb->integer("permissions")->not_null()->next_row();
|
||||
|
||||
tb->primary_key("id");
|
||||
tb->foreign_key("rank_id")->references(RBAC_RANK_TABLE, "id");
|
||||
tb->ccreate_table();
|
||||
tb->run_query();
|
||||
//tb->print();
|
||||
}
|
||||
void RBACModel::drop_table() {
|
||||
Ref<TableBuilder> tb = DatabaseManager::get_singleton()->ddb->get_table_builder();
|
||||
|
||||
tb->drop_table_if_exists(_table_name)->run_query();
|
||||
tb->drop_table_if_exists(RBAC_PERMISSION_TABLE)->drop_table_if_exists(RBAC_RANK_TABLE)->run_query();
|
||||
//tb->print();
|
||||
}
|
||||
void RBACModel::migrate() {
|
||||
drop_table();
|
||||
|
@ -5,7 +5,6 @@ RBACPermission::RBACPermission() :
|
||||
|
||||
id = 0;
|
||||
rank_id = 0;
|
||||
permission_id = 0;
|
||||
revoke = false;
|
||||
sort_order = 0;
|
||||
permissions = 0;
|
||||
|
@ -11,7 +11,6 @@ class RBACPermission : public Resource {
|
||||
public:
|
||||
int id;
|
||||
int rank_id;
|
||||
int permission_id;
|
||||
std::string name;
|
||||
std::string url;
|
||||
bool revoke;
|
||||
|
@ -4,8 +4,9 @@ RBACRank::RBACRank() :
|
||||
Resource() {
|
||||
|
||||
id = 0;
|
||||
rank_permissions = 0;
|
||||
}
|
||||
|
||||
RBACRank::~RBACRank() {
|
||||
groups.clear();
|
||||
permissions.clear();
|
||||
}
|
||||
|
@ -18,7 +18,9 @@ public:
|
||||
std::string name_internal;
|
||||
std::string settings;
|
||||
|
||||
std::vector<Ref<RBACPermission> > groups;
|
||||
int rank_permissions;
|
||||
|
||||
std::vector<Ref<RBACPermission> > permissions;
|
||||
|
||||
RBACRank();
|
||||
~RBACRank();
|
||||
|
Loading…
Reference in New Issue
Block a user