diff --git a/db/migrations/builder/TableBuilder.h b/db/migrations/builder/TableBuilder.h index a26f6f4..897a9cb 100644 --- a/db/migrations/builder/TableBuilder.h +++ b/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();