mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Implement drop table for the table builder, fix a warning, and made the message page's migration runnable multiple times (for now).
This commit is contained in:
parent
b99cbf0164
commit
53a2a651d6
@ -8,6 +8,7 @@ void Database::connect(const std::string &connection_str) {
|
||||
}
|
||||
|
||||
QueryResult *Database::query(const std::string &query) {
|
||||
return nullptr;
|
||||
}
|
||||
void Database::query_run(const std::string &query) {
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ TableBuilder *TableBuilder::next_row() {
|
||||
return this;
|
||||
}
|
||||
|
||||
TableBuilder *TableBuilder::drop_table(const std::string &name) {
|
||||
|
||||
}
|
||||
|
||||
void TableBuilder::finalize() {
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
virtual TableBuilder *primary_key();
|
||||
virtual TableBuilder *next_row();
|
||||
|
||||
virtual TableBuilder *drop_table(const std::string &name);
|
||||
|
||||
virtual void finalize();
|
||||
|
||||
TableBuilder();
|
||||
|
@ -64,6 +64,11 @@ void MysqlTableBuilder::finalize() {
|
||||
result += ");";
|
||||
}
|
||||
|
||||
TableBuilder *MysqlTableBuilder::drop_table(const std::string &name) {
|
||||
result += "DROP TABLE " + name + ";";
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
MysqlTableBuilder::MysqlTableBuilder() {
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ public:
|
||||
TableBuilder *primary_key();
|
||||
TableBuilder *next_row();
|
||||
|
||||
TableBuilder *drop_table(const std::string &name);
|
||||
|
||||
void finalize();
|
||||
|
||||
MysqlTableBuilder();
|
||||
|
@ -43,6 +43,13 @@ void MessagePage::index(Request *request) {
|
||||
void MessagePage::migrate() {
|
||||
TableBuilder *t = db->get_table_builder();
|
||||
|
||||
t->drop_table("message_page");
|
||||
db->query_run(t->result);
|
||||
|
||||
printf("%s\n", t->result.c_str());
|
||||
|
||||
t->result.clear();
|
||||
|
||||
t->create_table("message_page")->integer("id")->auto_increment()->primary_key()->next_row()->varchar("text", 30)->finalize();
|
||||
|
||||
printf("%s\n", t->result.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user