Browse Source

added fk methods to TableBuilder

main
Stefan Pranger 3 years ago
parent
commit
76c496e068
  1. 10
      db/migrations/builder/TableBuilder.h

10
db/migrations/builder/TableBuilder.h

@ -60,6 +60,16 @@ namespace db {
return *this;
}
CreateTableBuilder &fk(const std::string &key, const std::string &reference_table, const std::string &foreign_key, const std::string &opts = "") {
m_table.body += "\tFOREIGN KEY (" + key + ") REFERENCES " + reference_table + "(" + foreign_key + ")" + opts + ",\n";
return *this;
}
CreateTableBuilder &constraint(const std::string &name, const std::string &opts) {
m_table.body += "\tCONSTRAINT " + name + " UNIQUE (" + opts + "),\n";
return *this;
}
CreateTableBuilder &close() {
m_table.body.pop_back();
m_table.body.pop_back();

Loading…
Cancel
Save