schema progress
This commit is contained in:
parent
0d08ad4179
commit
d6de8da3c8
|
|
@ -87,18 +87,19 @@ matador::utils::result<void, matador::utils::error> matador::orm::schema::drop()
|
||||||
drop_sql_commands.push_back(ctx.sql);
|
drop_sql_commands.push_back(ctx.sql);
|
||||||
// determine constraints and drop them
|
// determine constraints and drop them
|
||||||
for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
|
for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
|
||||||
const auto ctx = query::query::alter()
|
const auto& endpoint = *(it->second);
|
||||||
.table( "" )
|
if (endpoint.type() == object::relation_type::BELONGS_TO) {
|
||||||
.add_constraint( it->second->node().name() )
|
continue;
|
||||||
.foreign_key( "" )
|
}
|
||||||
.references( "" ).compile(*c);
|
const auto drop_fk_ctx = query::query::alter()
|
||||||
|
.table( endpoint.node().name() )
|
||||||
|
.drop_constraint( "FK_" + endpoint.node().name() + "_" + endpoint.foreign_endpoint()->field_name() )
|
||||||
|
.compile(*c);
|
||||||
|
std::cout << drop_fk_ctx.sql << std::endl;
|
||||||
|
if (auto result = c->execute(drop_fk_ctx.sql); !result) {
|
||||||
|
return utils::failure(result.err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// for ( const auto& [sql, command] : ctx.additional_commands ) {
|
|
||||||
// if (auto result = c->execute(ctx.sql); !result) {
|
|
||||||
// return utils::failure(result.err());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute additional commands (e.g. ALTER TABLE ADD FK)
|
// execute additional commands (e.g. ALTER TABLE ADD FK)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
using namespace matador;
|
using namespace matador;
|
||||||
using namespace matador::test;
|
using namespace matador::test;
|
||||||
|
|
||||||
TEST_CASE_METHOD(SchemaFixture, "Test schema", "[schema]") {
|
TEST_CASE_METHOD(SchemaFixture, "Test schema one-two-many", "[schema]") {
|
||||||
using namespace matador::test;
|
using namespace matador::test;
|
||||||
matador::orm::schema repo(pool/*, "NoopSchema"*/);
|
matador::orm::schema repo(pool/*, "NoopSchema"*/);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue