https://kotlinlang.org logo
#exposed
Title
# exposed
d

dave08

10/28/2021, 11:31 AM
It would be great if SchemaUtils.drop and .create would be smart enough to run the list in the varargs version in an order that would work using references info to know with foreign keys would get in the way...
e

Endre Deak

10/28/2021, 3:33 PM
I ususally do something like
Copy code
val tables = listOf(...) // creation order
then
Copy code
SchemaUtilts.create(*tables.toTypedArray())
SchemaUtils.drop(*tables.reversed().toTypedArray())
correct me if I’m wrong but I don’t think Exposed supposed to maintain some meta info about the table hierarchy
d

dave08

10/28/2021, 3:35 PM
They have
reference("some_field", SomeTable)
that lets it know about what foreign keys to create and how to join tables...
e

Endre Deak

10/28/2021, 5:36 PM
true.
t

tapac

11/05/2021, 2:16 PM
@dave08, it should work like this. Do you have an example when tables do not created/dropped in an right order?
4 Views